From c3e651e34bcfbf7045b0f72ca69a1d30cd1e121c Mon Sep 17 00:00:00 2001 From: Tal Moran Date: Mon, 16 Nov 2015 14:44:06 +0200 Subject: [PATCH] Added encrypted message protobuf, and updated encryption API. --- .../src/main/java/meerkat/crypto/Encryption.java | 10 +++++++++- .../main/java/meerkat/crypto/mixnet/Mixer.java | 3 +-- .../java/meerkat/voting/EncryptedBallot.java | 16 ---------------- .../src/main/proto/meerkat/crypto.proto | 8 +++++++- .../src/main/proto/meerkat/voting.proto | 6 ++++++ 5 files changed, 23 insertions(+), 20 deletions(-) delete mode 100644 meerkat-common/src/main/java/meerkat/voting/EncryptedBallot.java diff --git a/meerkat-common/src/main/java/meerkat/crypto/Encryption.java b/meerkat-common/src/main/java/meerkat/crypto/Encryption.java index a1a023b..0ec6c11 100644 --- a/meerkat-common/src/main/java/meerkat/crypto/Encryption.java +++ b/meerkat-common/src/main/java/meerkat/crypto/Encryption.java @@ -7,6 +7,14 @@ import static meerkat.protobuf.Crypto.*; * Created by talm on 11/2/15. */ public interface Encryption { - Message encrypt(Message plaintext, EncryptionRandomness rnd); + /** + * Encrypt the serialized form of a message plaintext. + * @param plaintext + * @param rnd + * @return + */ + RerandomizableEncryptedMessage encrypt(Message plaintext, EncryptionRandomness rnd); // TODO: type of exception; throws + + RerandomizableEncryptedMessage rerandomize(RerandomizableEncryptedMessage msg, EncryptionRandomness rnd); } diff --git a/meerkat-common/src/main/java/meerkat/crypto/mixnet/Mixer.java b/meerkat-common/src/main/java/meerkat/crypto/mixnet/Mixer.java index 44b113b..52e8844 100644 --- a/meerkat-common/src/main/java/meerkat/crypto/mixnet/Mixer.java +++ b/meerkat-common/src/main/java/meerkat/crypto/mixnet/Mixer.java @@ -1,8 +1,7 @@ package meerkat.crypto.mixnet; -import meerkat.voting.EncryptedBallot; - import java.util.List; +import static meerkat.protobuf.Voting.*; /** * Created by talm on 25/10/15. diff --git a/meerkat-common/src/main/java/meerkat/voting/EncryptedBallot.java b/meerkat-common/src/main/java/meerkat/voting/EncryptedBallot.java deleted file mode 100644 index 8f86128..0000000 --- a/meerkat-common/src/main/java/meerkat/voting/EncryptedBallot.java +++ /dev/null @@ -1,16 +0,0 @@ -package meerkat.voting; - -import com.google.protobuf.Message; - -/** - * Created by talm on 25/10/15. - */ -public interface EncryptedBallot { - /** - * Return the public portion of the ballot (this can be published to the bulletin board without violating privacy). - * @return - */ - Message getPublicPortion(); - - -} diff --git a/meerkat-common/src/main/proto/meerkat/crypto.proto b/meerkat-common/src/main/proto/meerkat/crypto.proto index feafc1c..ecd9478 100644 --- a/meerkat-common/src/main/proto/meerkat/crypto.proto +++ b/meerkat-common/src/main/proto/meerkat/crypto.proto @@ -41,4 +41,10 @@ message EncryptionRandomness { // A proof that randomness is correctly generated message RandomnessGenerationProof { bytes data = 1; -} \ No newline at end of file +} + +// An encrypted message (rerandomizable) +message RerandomizableEncryptedMessage { + bytes data = 1; +} + diff --git a/meerkat-common/src/main/proto/meerkat/voting.proto b/meerkat-common/src/main/proto/meerkat/voting.proto index 5d2586a..f7195e2 100644 --- a/meerkat-common/src/main/proto/meerkat/voting.proto +++ b/meerkat-common/src/main/proto/meerkat/voting.proto @@ -49,6 +49,12 @@ message PlaintextBallot { repeated BallotAnswer answers = 2; } +message EncryptedBallot { + uint64 serialNumber = 1; // Ballot serial number + + RerandomizableEncryptedMessage data = 2; +} + message BallotSecrets { PlaintextBallot plaintext_ballot = 1;