use of com.quorum.tessera.transaction.exception.PrivacyViolationException in project tessera by ConsenSys.
the class PrivacyGroupManagerImpl method createPrivacyGroup.
@Override
public PrivacyGroup createPrivacyGroup(String name, String description, PublicKey from, List<PublicKey> members, byte[] seed) {
final Set<PublicKey> localKeys = enclave.getPublicKeys();
if (!members.contains(from)) {
throw new PrivacyViolationException("The list of members in a privacy group should include self");
}
final byte[] groupIdBytes = privacyGroupUtil.generateId(members, seed);
final PrivacyGroup created = PrivacyGroup.Builder.create().withPrivacyGroupId(groupIdBytes).withName(name).withDescription(description).withMembers(members).withSeed(seed).withType(PrivacyGroup.Type.PANTHEON).withState(PrivacyGroup.State.ACTIVE).build();
final byte[] lookupId = privacyGroupUtil.generateLookupId(members);
final byte[] encodedData = privacyGroupUtil.encode(created);
final List<PublicKey> forwardingMembers = members.stream().filter(Predicate.not(localKeys::contains)).collect(Collectors.toList());
privacyGroupDAO.save(new PrivacyGroupEntity(groupIdBytes, lookupId, encodedData), () -> {
publisher.publishPrivacyGroup(encodedData, forwardingMembers);
return null;
});
return created;
}
Aggregations