From 87e8ad947015c731c4e58fe062498a9af8f7fae4 Mon Sep 17 00:00:00 2001 From: Vladimir Eliezer Tokarev Date: Fri, 15 Jan 2016 02:28:02 -0800 Subject: [PATCH] Changed the SimpleRegistry file Managed to create the signatory and add empty builder --- .../src/main/java/meerkat/SimpleRegistry.java | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/voter-registry/src/main/java/meerkat/SimpleRegistry.java b/voter-registry/src/main/java/meerkat/SimpleRegistry.java index 8db83e0..93ce5c6 100644 --- a/voter-registry/src/main/java/meerkat/SimpleRegistry.java +++ b/voter-registry/src/main/java/meerkat/SimpleRegistry.java @@ -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