Changed the SimpleRegistry file
Managed to create the signatory and add empty buildervote-registry
parent
717c2e6e65
commit
87e8ad9470
|
@ -1,14 +1,21 @@
|
||||||
package meerkat;
|
package meerkat;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
|
import com.google.protobuf.Message;
|
||||||
import meerkat.ProtobufsMessages.BasicMessage;
|
import meerkat.ProtobufsMessages.BasicMessage;
|
||||||
import meerkat.ProtobufsMessages.Tag;
|
import meerkat.ProtobufsMessages.Tag;
|
||||||
import meerkat.bulletinboard.BulletinBoardClient;
|
import meerkat.bulletinboard.BulletinBoardClient;
|
||||||
|
import meerkat.bulletinboard.SimpleBulletinBoardClient;
|
||||||
import meerkat.comm.CommunicationException;
|
import meerkat.comm.CommunicationException;
|
||||||
import meerkat.crypto.DigitalSignature;
|
import meerkat.crypto.Encryption;
|
||||||
|
import meerkat.crypto.concrete.ECElGamalEncryption;
|
||||||
import meerkat.protobuf.BulletinBoardAPI;
|
import meerkat.protobuf.BulletinBoardAPI;
|
||||||
|
import meerkat.protobuf.Crypto;
|
||||||
|
import meerkat.protobuf.ConcreteCrypto
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Vladimir Eliezer Tokarev on 1/8/2016.
|
* Created by Vladimir Eliezer Tokarev on 1/8/2016.
|
||||||
|
@ -17,17 +24,22 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class SimpleRegistry {
|
public class SimpleRegistry {
|
||||||
|
|
||||||
protected DigitalSignature signatory;
|
protected Encryption signatory;
|
||||||
|
|
||||||
protected BulletinBoardClient communicator;
|
protected BulletinBoardClient communicator;
|
||||||
|
|
||||||
|
public SimpleRegistry() {
|
||||||
|
signatory = new ECElGamalEncryption();
|
||||||
|
communicator = new SimpleBulletinBoardClient();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param signatory implements the DigitalSignature interface
|
* @param signatory implements the DigitalSignature interface
|
||||||
* @param communicator implements the BulletinBoardClient interface
|
* @param communicator implements the BulletinBoardClient interface
|
||||||
*/
|
*/
|
||||||
public SimpleRegistry(DigitalSignature signatory, BulletinBoardClient communicator){
|
public SimpleRegistry(Encryption signatory, BulletinBoardClient communicator){
|
||||||
this.signatory = signatory;
|
signatory = signatory;
|
||||||
this.communicator = communicator;
|
communicator = communicator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +61,7 @@ public class SimpleRegistry {
|
||||||
basicMessage.addTag(idTag);
|
basicMessage.addTag(idTag);
|
||||||
basicMessage.addTag(voterEntryTag);
|
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(groupIDTag);
|
||||||
basicMessage.addTag(actionTag);
|
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(groupIDTag);
|
||||||
basicMessage.addTag(actionTag);
|
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(idTag);
|
||||||
basicMessage.addTag(voteAction);
|
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)
|
* Creates bulletin board message from basic message (with the signatures parts)
|
||||||
* @param basicMessage BasicMessage.Builder
|
* @param basicMessage BasicMessage
|
||||||
* @return BulletinBoardAPI.BulletinBoardMessage
|
* @return BulletinBoardAPI.BulletinBoardMessage
|
||||||
*/
|
*/
|
||||||
private BulletinBoardAPI.BulletinBoardMessage CreateBulletinBoardMessage(BasicMessage.Builder basicMessage) {
|
private BulletinBoardAPI.BulletinBoardMessage CreateBulletinBoardMessage(BasicMessage basicMessage) throws IOException {
|
||||||
BulletinBoardAPI.BulletinBoardMessage.Builder bulletinBoardmessage =
|
BulletinBoardAPI.BulletinBoardMessage.Builder bulletinBoardmessage =
|
||||||
BulletinBoardAPI.BulletinBoardMessage.newBuilder();
|
BulletinBoardAPI.BulletinBoardMessage.newBuilder();
|
||||||
signatory.updateContent((ProtobufsMessages)basicMessage);
|
signatory.encrypt(basicMessage, signatory.generateRandomness(new Random()));
|
||||||
/**
|
/**
|
||||||
* encode the basic message
|
* encode the basic message
|
||||||
* create bulletin board message
|
* create bulletin board message
|
||||||
|
|
Loading…
Reference in New Issue