Changed the SimpleRegistry file

Managed to create the signatory and add empty builder
vote-registry
Vladimir Eliezer Tokarev 2016-01-15 02:28:02 -08:00
parent 717c2e6e65
commit 87e8ad9470
1 changed files with 24 additions and 12 deletions

View File

@ -1,14 +1,21 @@
package meerkat;
import com.google.protobuf.ByteString;
import com.google.protobuf.Message;
import meerkat.ProtobufsMessages.BasicMessage;
import meerkat.ProtobufsMessages.Tag;
import meerkat.bulletinboard.BulletinBoardClient;
import meerkat.bulletinboard.SimpleBulletinBoardClient;
import meerkat.comm.CommunicationException;
import meerkat.crypto.DigitalSignature;
import meerkat.crypto.Encryption;
import meerkat.crypto.concrete.ECElGamalEncryption;
import meerkat.protobuf.BulletinBoardAPI;
import meerkat.protobuf.Crypto;
import meerkat.protobuf.ConcreteCrypto
import java.io.IOException;
import java.util.List;
import java.util.Random;
/**
* Created by Vladimir Eliezer Tokarev on 1/8/2016.
@ -17,17 +24,22 @@ import java.util.List;
*/
public class SimpleRegistry {
protected DigitalSignature signatory;
protected Encryption signatory;
protected BulletinBoardClient communicator;
public SimpleRegistry() {
signatory = new ECElGamalEncryption();
communicator = new SimpleBulletinBoardClient();
}
/**
* @param signatory implements the DigitalSignature interface
* @param communicator implements the BulletinBoardClient interface
*/
public SimpleRegistry(DigitalSignature signatory, BulletinBoardClient communicator){
this.signatory = signatory;
this.communicator = communicator;
public SimpleRegistry(Encryption signatory, BulletinBoardClient communicator){
signatory = signatory;
communicator = communicator;
}
/**
@ -49,7 +61,7 @@ public class SimpleRegistry {
basicMessage.addTag(idTag);
basicMessage.addTag(voterEntryTag);
communicator.postMessage(CreateBulletinBoardMessage(basicMessage), null);
communicator.postMessage(CreateBulletinBoardMessage(basicMessage.build()), null);
}
/**
@ -74,7 +86,7 @@ public class SimpleRegistry {
basicMessage.addTag(groupIDTag);
basicMessage.addTag(actionTag);
communicator.postMessage(CreateBulletinBoardMessage(basicMessage), null);
communicator.postMessage(CreateBulletinBoardMessage(basicMessage.build()), null);
}
/**
@ -99,7 +111,7 @@ public class SimpleRegistry {
basicMessage.addTag(groupIDTag);
basicMessage.addTag(actionTag);
communicator.postMessage(CreateBulletinBoardMessage(basicMessage), null);
communicator.postMessage(CreateBulletinBoardMessage(basicMessage.build()), null);
}
/**
@ -119,18 +131,18 @@ public class SimpleRegistry {
basicMessage.addTag(idTag);
basicMessage.addTag(voteAction);
communicator.postMessage(CreateBulletinBoardMessage(basicMessage), null);
communicator.postMessage(CreateBulletinBoardMessage(basicMessage.build()), null);
}
/**
* Creates bulletin board message from basic message (with the signatures parts)
* @param basicMessage BasicMessage.Builder
* @param basicMessage BasicMessage
* @return BulletinBoardAPI.BulletinBoardMessage
*/
private BulletinBoardAPI.BulletinBoardMessage CreateBulletinBoardMessage(BasicMessage.Builder basicMessage) {
private BulletinBoardAPI.BulletinBoardMessage CreateBulletinBoardMessage(BasicMessage basicMessage) throws IOException {
BulletinBoardAPI.BulletinBoardMessage.Builder bulletinBoardmessage =
BulletinBoardAPI.BulletinBoardMessage.newBuilder();
signatory.updateContent((ProtobufsMessages)basicMessage);
signatory.encrypt(basicMessage, signatory.generateRandomness(new Random()));
/**
* encode the basic message
* create bulletin board message