aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/gnunet/voting/Ballot.java
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2013-11-19 11:15:52 +0000
committerFlorian Dold <florian.dold@gmail.com>2013-11-19 11:15:52 +0000
commite1dbf0dae09d3ecddc992a5a7b04a82ca03dcd2a (patch)
tree2447f7f92541c738d13a7659c7ba791146defa27 /src/main/java/org/gnunet/voting/Ballot.java
parent3d17385928f938d170230be1b334ff159355775d (diff)
downloadgnunet-java-e1dbf0dae09d3ecddc992a5a7b04a82ca03dcd2a.tar.gz
gnunet-java-e1dbf0dae09d3ecddc992a5a7b04a82ca03dcd2a.zip
- crypto + crypto tests
Diffstat (limited to 'src/main/java/org/gnunet/voting/Ballot.java')
-rw-r--r--src/main/java/org/gnunet/voting/Ballot.java10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/main/java/org/gnunet/voting/Ballot.java b/src/main/java/org/gnunet/voting/Ballot.java
index 72d444f..e300010 100644
--- a/src/main/java/org/gnunet/voting/Ballot.java
+++ b/src/main/java/org/gnunet/voting/Ballot.java
@@ -180,13 +180,13 @@ public class Ballot {
180 if (!optCaPub.isPresent()) { 180 if (!optCaPub.isPresent()) {
181 throw new InvalidBallotException("no CA pub key given"); 181 throw new InvalidBallotException("no CA pub key given");
182 } 182 }
183 caPub = EcdsaPublicKey.fromStringUncompressed(optCaPub.get()); 183 caPub = EcdsaPublicKey.fromString(optCaPub.get());
184 if (null == caPub) { 184 if (null == caPub) {
185 throw new InvalidBallotException("CA pub key invalid"); 185 throw new InvalidBallotException("CA pub key invalid");
186 } 186 }
187 Optional<String> optIssuerPub = cfg.getValueString("election", "ISSUER_PUB"); 187 Optional<String> optIssuerPub = cfg.getValueString("election", "ISSUER_PUB");
188 if (optIssuerPub.isPresent()) { 188 if (optIssuerPub.isPresent()) {
189 issuerPub = EcdsaPublicKey.fromStringUncompressed(optIssuerPub.get()); 189 issuerPub = EcdsaPublicKey.fromString(optIssuerPub.get());
190 Optional<String> optIssuerSig = cfg.getValueString("election", "ISSUER_SIG"); 190 Optional<String> optIssuerSig = cfg.getValueString("election", "ISSUER_SIG");
191 if (!optIssuerSig.isPresent()) { 191 if (!optIssuerSig.isPresent()) {
192 throw new InvalidBallotException("issuer public key present, but no signature"); 192 throw new InvalidBallotException("issuer public key present, but no signature");
@@ -227,7 +227,7 @@ public class Ballot {
227 227
228 Optional<String> optVoterPub = cfg.getValueString("vote", "VOTER_PUB"); 228 Optional<String> optVoterPub = cfg.getValueString("vote", "VOTER_PUB");
229 if (optVoterPub.isPresent()) { 229 if (optVoterPub.isPresent()) {
230 voterPub = EcdsaPublicKey.fromStringUncompressed(optVoterPub.get()); 230 voterPub = EcdsaPublicKey.fromString(optVoterPub.get());
231 if (null == voterPub) { 231 if (null == voterPub) {
232 throw new InvalidBallotException("voter public key present but invalid"); 232 throw new InvalidBallotException("voter public key present but invalid");
233 } 233 }
@@ -268,15 +268,13 @@ public class Ballot {
268 digest.update(x.getKey().getBytes()); 268 digest.update(x.getKey().getBytes());
269 digest.update(x.getValue().data); 269 digest.update(x.getValue().data);
270 } 270 }
271 digest.update(issuerPub.x);
272 digest.update(issuerPub.y); 271 digest.update(issuerPub.y);
273 digest.update(caPub.x);
274 digest.update(caPub.y); 272 digest.update(caPub.y);
275 digest.update(Longs.toByteArray(startTime.getSeconds())); 273 digest.update(Longs.toByteArray(startTime.getSeconds()));
276 digest.update(Longs.toByteArray(endTime.getSeconds())); 274 digest.update(Longs.toByteArray(endTime.getSeconds()));
277 digest.update(Longs.toByteArray(closingTime.getSeconds())); 275 digest.update(Longs.toByteArray(closingTime.getSeconds()));
278 digest.update(Longs.toByteArray(queryTime.getSeconds())); 276 digest.update(Longs.toByteArray(queryTime.getSeconds()));
279 return new HashCode(digest.digest()); 277 return HashCode.fromHashCode(digest.digest());
280 } 278 }
281 279
282 /** 280 /**