[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32478 - in gnunet-java/src/main/java/org/gnunet/voting: .
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32478 - in gnunet-java/src/main/java/org/gnunet/voting: . messages |
Date: |
Tue, 25 Feb 2014 12:16:59 +0100 |
Author: dold
Date: 2014-02-25 12:16:59 +0100 (Tue, 25 Feb 2014)
New Revision: 32478
Added:
gnunet-java/src/main/java/org/gnunet/voting/EncryptedVote.java
Removed:
gnunet-java/src/main/java/org/gnunet/voting/messages/QueryFailureMessage.java
gnunet-java/src/main/java/org/gnunet/voting/messages/QueryMessage.java
gnunet-java/src/main/java/org/gnunet/voting/messages/QueryResponseMessage.java
Log:
- add encrypted vote class
- remove unused / renamed messages
Added: gnunet-java/src/main/java/org/gnunet/voting/EncryptedVote.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/voting/EncryptedVote.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/voting/EncryptedVote.java
2014-02-25 11:16:59 UTC (rev 32478)
@@ -0,0 +1,64 @@
+/*
+ This file is part of GNUnet.
+ (C) 2014 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+package org.gnunet.voting;
+
+
+import com.google.common.base.Optional;
+import org.gnunet.construct.Message;
+import org.gnunet.construct.NestedMessage;
+import org.gnunet.secretsharing.Ciphertext;
+import org.gnunet.secretsharing.Plaintext;
+import org.gnunet.secretsharing.ThresholdPublicKey;
+import org.gnunet.util.Configuration;
+import org.gnunet.util.Strings;
+import org.gnunet.util.crypto.EcdsaPrivateKey;
+
+import java.math.BigInteger;
+
+public class EncryptedVote implements Message {
+ // TODO: zero knowledge proof
+ // TODO: signature
+
+ @NestedMessage
+ Ciphertext v;
+
+ public static EncryptedVote parseFromConfiguration(Configuration cfg) {
+ Optional<String> optVal = cfg.getValueString("vote",
"ENCRYPTED_VOTE_VAL");
+ if (!optVal.isPresent()) {
+ return null;
+ }
+ EncryptedVote encryptedVote = new EncryptedVote();
+ encryptedVote.v = Ciphertext.fromString(optVal.get());
+ return encryptedVote;
+ }
+
+ public void writeToConfiguration(Configuration cfg) {
+ cfg.setValueString("vote", "ENCRYPTED_VOTE_VAL", v.toString()); }
+
+ public static EncryptedVote fromChoice(int choiceId, ThresholdPublicKey
thresholdPublicKey,
+ EcdsaPrivateKey voterPrivateKey) {
+ // FIXME: can we use 'g', or should we use another generator?
+ Plaintext p = Plaintext.generate(BigInteger.valueOf(choiceId));
+ EncryptedVote encryptedVote = new EncryptedVote();
+ encryptedVote.v = p.encrypt(thresholdPublicKey);
+ return encryptedVote;
+ }
+}
Deleted:
gnunet-java/src/main/java/org/gnunet/voting/messages/QueryFailureMessage.java
===================================================================
---
gnunet-java/src/main/java/org/gnunet/voting/messages/QueryFailureMessage.java
2014-02-25 11:15:59 UTC (rev 32477)
+++
gnunet-java/src/main/java/org/gnunet/voting/messages/QueryFailureMessage.java
2014-02-25 11:16:59 UTC (rev 32478)
@@ -1,31 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2012, 2013 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-package org.gnunet.voting.messages;
-
-import org.gnunet.construct.UnionCase;
-import org.gnunet.construct.ZeroTerminatedString;
-import org.gnunet.util.GnunetMessage;
-
address@hidden(42009)
-public class QueryFailureMessage implements GnunetMessage.Body {
- @ZeroTerminatedString
- public String reason;
-}
Deleted: gnunet-java/src/main/java/org/gnunet/voting/messages/QueryMessage.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/voting/messages/QueryMessage.java
2014-02-25 11:15:59 UTC (rev 32477)
+++ gnunet-java/src/main/java/org/gnunet/voting/messages/QueryMessage.java
2014-02-25 11:16:59 UTC (rev 32478)
@@ -1,12 +0,0 @@
-package org.gnunet.voting.messages;
-
-import org.gnunet.construct.NestedMessage;
-import org.gnunet.construct.UnionCase;
-import org.gnunet.util.GnunetMessage;
-import org.gnunet.util.HashCode;
-
address@hidden(42005)
-public class QueryMessage implements GnunetMessage.Body {
- @NestedMessage
- public HashCode ballotGUID;
-}
Deleted:
gnunet-java/src/main/java/org/gnunet/voting/messages/QueryResponseMessage.java
===================================================================
---
gnunet-java/src/main/java/org/gnunet/voting/messages/QueryResponseMessage.java
2014-02-25 11:15:59 UTC (rev 32477)
+++
gnunet-java/src/main/java/org/gnunet/voting/messages/QueryResponseMessage.java
2014-02-25 11:16:59 UTC (rev 32478)
@@ -1,12 +0,0 @@
-package org.gnunet.voting.messages;
-
-
-import org.gnunet.construct.*;
-import org.gnunet.util.GnunetMessage;
-import org.gnunet.util.HashCode;
-
address@hidden(42006)
-public class QueryResponseMessage implements GnunetMessage.Body {
- @IntegerFill(signed = false, bitSize = 32)
- public int[] results;
-}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32478 - in gnunet-java/src/main/java/org/gnunet/voting: . messages,
gnunet <=