[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24163 - in gnunet-java: . doc src/org/gnunet/construct/par
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24163 - in gnunet-java: . doc src/org/gnunet/construct/parsers src/org/gnunet/core src/org/gnunet/dht src/org/gnunet/mesh src/org/gnunet/statistics src/org/gnunet/testing src/org/gnunet/util src/org/gnunet/voting test/org/gnunet/construct test/org/gnunet/util/getopt |
Date: |
Wed, 3 Oct 2012 17:23:39 +0200 |
Author: dold
Date: 2012-10-03 17:23:39 +0200 (Wed, 03 Oct 2012)
New Revision: 24163
Added:
gnunet-java/doc/voting.bib
gnunet-java/doc/voting.pdf
gnunet-java/doc/voting.tex
gnunet-java/src/org/gnunet/voting/Cyphertext.java
gnunet-java/src/org/gnunet/voting/ElGamalScheme.java
Removed:
gnunet-java/src/org/gnunet/voting/ElGamalParameters.java
Modified:
gnunet-java/ISSUES
gnunet-java/src/org/gnunet/construct/parsers/FillParser.java
gnunet-java/src/org/gnunet/construct/parsers/IntegerFillParser.java
gnunet-java/src/org/gnunet/core/Core.java
gnunet-java/src/org/gnunet/dht/DistributedHashTable.java
gnunet-java/src/org/gnunet/mesh/Mesh.java
gnunet-java/src/org/gnunet/statistics/Statistics.java
gnunet-java/src/org/gnunet/testing/TestingServer.java
gnunet-java/src/org/gnunet/testing/TestingSubsystem.java
gnunet-java/src/org/gnunet/util/Connection.java
gnunet-java/src/org/gnunet/util/Resolver.java
gnunet-java/src/org/gnunet/util/Server.java
gnunet-java/src/org/gnunet/voting/CryptoUtil.java
gnunet-java/src/org/gnunet/voting/VotingSimulation.java
gnunet-java/test/org/gnunet/construct/ConstructTest.java
gnunet-java/test/org/gnunet/construct/FixedSizeTest.java
gnunet-java/test/org/gnunet/construct/StringTuple.java
gnunet-java/test/org/gnunet/util/getopt/GetoptTest.java
Log:
added documentation for the voting protocol,
fixed some bugs detected by coverty,
implemented most of the cryptographic primitives for voting
Modified: gnunet-java/ISSUES
===================================================================
--- gnunet-java/ISSUES 2012-10-02 14:54:16 UTC (rev 24162)
+++ gnunet-java/ISSUES 2012-10-03 15:23:39 UTC (rev 24163)
@@ -279,4 +279,25 @@
what about the signing process in [Ped91]?
notation: what is Zp(z)? polynomials with variable z over Zp*?
-(ped91, §3.1, choosing a random polynomial)
\ No newline at end of file
+(ped91, §3.1, choosing a random polynomial)
+
+
+--------------------------------------------------------
+
+* voting.tex
+ * i learned a lot of latex, and a lot the math while writing this
+ * should we keep it?
+
+* key distribution (including verification of shares) implemented
+* key can be correctly recovered from the shares
+* cooperative decryption implemented
+* first zero knowledge proof implemented
+ * what kind of hash should I use for making the ZK-proofs non-interactive?
+
+* what generator should be used for voting? G=g?
+ * can a cyclic group even have more than one generator? don't they mean
high-order element?
+
+* what makes more sense: passing the RNG handle explicitly every time, or
storing it in e.G. ElGamalScheme?
+
+
+* what about the 10138: DP: Use doPrivileged in runabout?
\ No newline at end of file
Added: gnunet-java/doc/voting.bib
===================================================================
--- gnunet-java/doc/voting.bib (rev 0)
+++ gnunet-java/doc/voting.bib 2012-10-03 15:23:39 UTC (rev 24163)
@@ -0,0 +1,47 @@
address@hidden,
+ author = {Pedersen, Torben Pryds},
+ title = {A threshold cryptosystem without a trusted party},
+ booktitle = {Proceedings of the 10th annual international conference on
Theory and application of cryptographic techniques},
+ series = {EUROCRYPT'91},
+ year = {1991},
+ isbn = {3-540-54620-0},
+ location = {Brighton, UK},
+ pages = {522--526},
+ numpages = {5},
+ url = {http://dl.acm.org/citation.cfm?id=1754868.1754929},
+ acmid = {1754929},
+ publisher = {Springer-Verlag},
+ address = {Berlin, Heidelberg},
+}
+
+
address@hidden,
+ author = {Cramer, Ronald and Gennaro, Rosario and Schoenmakers, Berry},
+ title = {A secure and optimally efficient multi-authority election scheme},
+ booktitle = {Proceedings of the 16th annual international conference on
Theory and application of cryptographic techniques},
+ series = {EUROCRYPT'97},
+ year = {1997},
+ isbn = {3-540-62975-0},
+ location = {Konstanz, Germany},
+ pages = {103--118},
+ numpages = {16},
+ url = {http://dl.acm.org/citation.cfm?id=1754542.1754554},
+ acmid = {1754554},
+ publisher = {Springer-Verlag},
+ address = {Berlin, Heidelberg},
+}
+
address@hidden,
+ author = {Cramer, Ronald and Damg{\aa}rd, Ivan and Schoenmakers, Berry},
+ title = {Proofs of Partial Knowledge and Simplified Design of Witness Hiding
Protocols},
+ booktitle = {Proceedings of the 14th Annual International Cryptology
Conference on Advances in Cryptology},
+ series = {CRYPTO '94},
+ year = {1994},
+ isbn = {3-540-58333-5},
+ pages = {174--187},
+ numpages = {14},
+ url = {http://dl.acm.org/citation.cfm?id=646759.705842},
+ acmid = {705842},
+ publisher = {Springer-Verlag},
+ address = {London, UK, UK},
+}
Added: gnunet-java/doc/voting.pdf
===================================================================
(Binary files differ)
Index: gnunet-java/doc/voting.pdf
===================================================================
--- gnunet-java/doc/voting.pdf 2012-10-02 14:54:16 UTC (rev 24162)
+++ gnunet-java/doc/voting.pdf 2012-10-03 15:23:39 UTC (rev 24163)
Property changes on: gnunet-java/doc/voting.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: gnunet-java/doc/voting.tex
===================================================================
--- gnunet-java/doc/voting.tex (rev 0)
+++ gnunet-java/doc/voting.tex 2012-10-03 15:23:39 UTC (rev 24163)
@@ -0,0 +1,168 @@
+\documentclass{article}
+\usepackage{amsmath}
+\usepackage{amssymb}
+\usepackage{multirow}
+
+\begin{document}
+
+\section{Parameters of the Encryption Scheme}
+\begin{itemize}
+ \item $p$ and $q$ are large primes, where $p=2q+1$ ($p$ is a so-called
Sophie Germain prime).
+ \item $\alpha$ is a generator of $Z_{p}^{*}$.
+ \item $G_q$ is the unique subgroup of $Z_{p}^{*}$ of order $q$. The discrete
logarithm is especially hard to solve for $G_q$.
+ \item $g$ is a generator of $G_q$. Note that this is different from the
standard ElGamal scheme, where $g$ would be a generator of $Z_p^*$.
+ \item $a \in Z_{p}^{*} \Leftrightarrow a^g \equiv 1 \mod{p}$
+ \item Generally, all computations involving powers of $g$ are modulo $p$,
while
+ polynomials / polynomial interpolation is done over modulo $q$.
+\end{itemize}
+
+
+\section{Key Distribution}
+\begin{itemize}
+ \item There are $n$ authorities, $P_1 \dots P_n$
+ \item $x = \sum_{i=1}^{n} x_i$ is the private key, every authority $P_i$
generates $x_i \in_R Z_q$.
+ Note that we do not select $x_i$ from $Z_p$, as $p > q$ and
+ $(\forall n \ge q) [ g^n = 1 ]$, by definition of $g$ as a generator of
$G_q$.
+ \item Every authority $P_i$ publishes $h_i = g^{x_i}$.
+ \item $h = g^{x}$ is the public key, and can be computed as $\prod_{i=1}^{n}
h_i$
+ \item Let $k$ be the minimum number of authorities who can jointly restore
the private key.
+ \item Every authority $P_i$ generates a random polynomial $f_i(z) =
\sum_{l=0}^{k-1} f_{il}^{l}$,
+ where $f_{il} \in_R Z_q$ for $l \neq 0$ and $f_{i0}=x_0$. Note that
$f_i(0) = x_i$.
+
+ \emph{Important}: The polynomials are evaluated over $Z_q$.
+ \item Every authority $P_i$ publishes $(F_{ij})_{j=1,\dots,k-1}$, where
$F_{ij} = g^{f_{ij}}$.
+ \item Now every authority $P_i$ secretly sends $s_{ij} = f_i(j)$ to each
authority $P_j$.
+ \item $P_i$ verifies the shares received from $P_j$ is consistent with the
previously published values by
+ verifying that
+ \[
+ g^{s_{ij}} = \prod_{l=0}^{k-1} F_{jl}^{(i^l)}.
+ \]
+ This equation follows directly from raising $g$ to both
+ sides of $s_{ij} = \sum_{l=0}^{k-1} f_{il}^{l}$.
+ \item $P_i$ computes his share of $x$ as $s_i = \sum_{j=1}^n s_{ji}$. This
works because evaluating $f(z) = \sum_{i=1}^{n} f_i(x)$ at $z=0$ gives $f(0) =
x$, and as $s_{ij}$ is interpolated by $f_i(z)$, the sum of all received shares
$s_j$ is interpolated by $f(z)$.
+\end{itemize}
+
+\section{ElGamal}
+To encrypt a cyphertext $m \in G_q$, the sender chooses a random $y \in_R Z_q$
and sends the pair $(c_1, c_2) = (g^y, m h^y)$.
+The decrypt the cyphertext, the receiver recovers the plaintext as $c_2 /
c_1^x = (m h^y) / g^{yx} = (m h^y) / h^y = m$.
+
+
+
+\section{Cooperative Decryption}
+\begin{itemize}
+ \item The full private key can be restored by a set at least $k$ cooperating
authorities $\Lambda \subseteq \{P_1,\dots,P_n\}$, where $k \ge |\Lambda|$ the
decryption theshold set during the key distribution phase.
+ \item This could be done using Lagrange interpolation, where the Lagrange
coefficients are
+ \[
+ \lambda_{j,\Lambda} = \prod_{\substack{
+ P_l \in \Lambda \\ l \neq j} } \frac{l}{l-k}
+ \]
+ \item While the full private key $x$ should never be learned by a single
authority, it could be restored as
+ \begin{equation} \label{eq:pkey}
+ x = \sum_{P_j \in \Lambda} s_j \lambda_{j,\Lambda}
+ \end{equation}
+ \item Let $\sigma_i$ denote $g^{s_i}$.
+ \item To decrypt a cyphertext $(c_1, c_2) = (g^y, h^y m)$ each authority
$P_j$ broadcasts $w_j = c_1^{s_j}$.
+ \item To prove that an authority has computed $w_j$ correctly, it has to
prove in zero-knowledge that
+ \[
+ s_j = \log_g \sigma_j = \log_{c_1} w_j,
+ \]
+ in words that $w_j$ has actually been computed with the authority's share.
+ \item By raising $c_1$ to both sides of equation \eqref{eq:pkey}, we get
+ \[
+ m = c_2 / \prod_{P_j \in \Lambda} w_j^{\lambda_{j,\Lambda}}.
+ \]
+\end{itemize}
+
+\section{Zero-knowledge-proof for discrete logarithms}
+\begin{itemize}
+ \item The Prover wants to prove
+ \[
+ s_j = \log_g \sigma_j = \log_{c_1} w_j
+ \]
+ without revealing the value of $s_j$.
+ \item The Prover sends $(g^\beta, c_1^\beta)$, with $\beta \in_R Z_q$
+ \item The Verifier sends $c \in_R Z_q$
+ \item The Prover sends $r = \beta + s_i c$
+ \item The Verifier checks the two equalities
+ \[
+ g^r = g^\beta \sigma^c
+ \]
+ \[
+ c_1^r = c_1^\beta w_i^c
+ \]
+\end{itemize}
+This proof utilizes the fact that it is hard to compute $g^{ab}$ from $g$ and
$a$ without having $b$.
+
+
+\section{Casting a vote}
+\begin{itemize}
+ \item A vote has the form $(g^y, h^yG^b)$, where $G$ is a generator of $G_q$
(one could just use $G=q$), $b \in \{-1,1\}$ denotes the value of the vote, and
$y \in_R Z_q$.
+\end{itemize}
+
+\section{Verifying a vote}
+The details on how this protocol can be constructed from the discrete log
protocol can be found in \cite{Cramer94}.
+
+\newcommand{\?}{\stackrel{?}{=}}
+
+\begin{table}[!h]
+ \begin{tabular}{ c|ccp{\columnwidth} }
+ \multicolumn{2}{c}{ Voter } & &
+ Verifier \\ \\
+ $v=1$ & $v=-1$ & & \\ \cline{1-2}
+ $\alpha,w,r_1,d_1 \in_R Z_q$ & $\alpha,w,r_2,d_2 \in_R Z_q$ \\ \\
+ $x \leftarrow g^\alpha$ & $x \leftarrow g^\alpha$ \\
+ $y \leftarrow g^\alpha G$ & $y \leftarrow g^\alpha / G$ \\
+ $a_1 \leftarrow g^{r_1}x^{d_1}$ & $y \leftarrow g^w$ \\
+ $b_1 \leftarrow h^{r_1}(yG)^{d_1}$ & $b_1 \leftarrow g^w$ \\
+ $a_2 \leftarrow g^w$ & $y \leftarrow g^{r_2}x^{d_2}$ \\
+ $b_2 \leftarrow h^w$ & $b_2 \leftarrow h^{r_2}(y/G)^{d_2}$ &
+ $\xrightarrow{x,y,a_1,b_1,a_2,b_2}$ \\ \\
+ $d_2 \leftarrow c - d_1$ & $d_1 \leftarrow c - d_2$ &
+
+ $\xleftarrow{c}$ & $c \in_R Z_q$ \\ \\
+
+ $r_2 \leftarrow w - \alpha d_2$ & $r_1 \leftarrow w - \alpha d_1$ &
+ $\xrightarrow{d_1,d_2,r_1,r_2}$ & $c \? d_1 + d_2$ \\
+ \multicolumn{3}{c}{} & $a_1 \? g^{r1} x^{d_1}$ \\
+ \multicolumn{3}{c}{} & $b_1 \? h^{r1} (yG)^{d_1}$ \\
+ \multicolumn{3}{c}{} & $a_2 \? g^{r2} x^{d_2}$ \\
+ \multicolumn{3}{c}{} & $b_2 \? h^{r2} (y/G)^{d_2}$ \\
+ \end{tabular}
+\end{table}
+
+
+\clearpage
+
+\section{Counting votes}
+\begin{itemize}
+ \item Let $(x_i, y_i)$ be the vote casted by Voter $V_i$
+ \item $(X,Y) = (\prod_{i=1}^{l}x_i,\prod_{i=1}^{l} y_i)$ is computed by all
authorities.
+ \item $(X,Y)$ is decrypted cooperatively, obtaining $G^T$,
+ where $T$ is the outcome of the election.
+ \item Let $l$ be the number of votes. As $T \in \{-t,...,t\}$ holds,
+ the number of votes can be found by brute-force.
+\end{itemize}
+
+
+\section{Notes on Notation}
+
+\begin{table}[!h]
+ \begin{tabular}{ | c | c | c | c | }
+ \hline
+ \cite{Cramer97} & \cite{Pedersen} & this document & source code \\ \hline
+ $s$ & $x$ & $x$ & BigInteger x \\
+ -- & $x_i$ & $x_i$ & BigInteger\lbrack\rbrack \, xParts; xParts\lbrack
i\rbrack \\
+ \hline
+ \end{tabular}
+\end{table}
+
+
+\clearpage
+
+\bibliographystyle{alpha}
+\bibliography{voting} % expects file "voting.bib"
+
+\end{document}
+
+
+
Modified: gnunet-java/src/org/gnunet/construct/parsers/FillParser.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/parsers/FillParser.java
2012-10-02 14:54:16 UTC (rev 24162)
+++ gnunet-java/src/org/gnunet/construct/parsers/FillParser.java
2012-10-03 15:23:39 UTC (rev 24163)
@@ -62,8 +62,12 @@
public int parse(ByteBuffer srcBuf, int frameOffset,
Message frameObj, final Message dstObj, List<Field>
frameSizePath) {
+ if (frameSizePath == null) {
+ throw new AssertionError("FillParser expects a non-null
frameSizePath. Does the message have a @FrameSizePath annotation?");
+ }
+
final int frameSize = ReflectUtil.justGetInt(dstObj, frameSizePath);
int remaining = frameOffset + frameSize - srcBuf.position();
int size = 0;
Modified: gnunet-java/src/org/gnunet/construct/parsers/IntegerFillParser.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/parsers/IntegerFillParser.java
2012-10-02 14:54:16 UTC (rev 24162)
+++ gnunet-java/src/org/gnunet/construct/parsers/IntegerFillParser.java
2012-10-03 15:23:39 UTC (rev 24163)
@@ -55,6 +55,9 @@
@Override
public int parse(ByteBuffer srcBuf, int frameStart, Message frameObj,
Message dstObj, List<Field> frameSizePath) {
+ if (frameSizePath == null) {
+ throw new AssertionError("IntegerFillParser expects a non-null
frameSizePath. Did you specify a @FrameSize field?");
+ }
final int frameSize = ReflectUtil.justGetInt(frameObj, frameSizePath);
int remaining = frameStart + frameSize - srcBuf.position();
@@ -96,6 +99,9 @@
@Override
public void patch(Message m, int frameSize, List<Field> frameSizePath,
Message frameObj) {
+ if (frameSizePath == null) {
+ throw new AssertionError("IntegerFillParser expects a non-null
frameSizePath. Did you specify a @FrameSize field?");
+ }
ReflectUtil.justSetInt(frameObj, frameSizePath, frameSize);
}
Modified: gnunet-java/src/org/gnunet/core/Core.java
===================================================================
--- gnunet-java/src/org/gnunet/core/Core.java 2012-10-02 14:54:16 UTC (rev
24162)
+++ gnunet-java/src/org/gnunet/core/Core.java 2012-10-03 15:23:39 UTC (rev
24163)
@@ -101,14 +101,14 @@
@Override
public AbsoluteTime getDeadline() {
- return origin.deadline;
+ return origin.getDeadline();
}
@Override
public void transmit(Connection.MessageSink sink) {
SendMessage sm = new SendMessage();
sm.cork = 0;
- sm.deadline = origin.deadline.asMessage();
+ sm.deadline = origin.getDeadline().asMessage();
sm.peer = origin.target;
sm.priority = origin.priority;
sm.payloadMessage = message;
@@ -126,7 +126,6 @@
* Sent after we get a SendMessageReady
*/
private static class NotifyTransmitReadyRequest extends Request {
- public AbsoluteTime deadline;
public int size;
public int priority;
public PeerIdentity target;
@@ -134,10 +133,6 @@
public int smrId;
public Cancelable transmitRequestCancel;
- @Override
- public AbsoluteTime getDeadline() {
- return deadline;
- }
@Override
public void transmit(Connection.MessageSink sink) {
@@ -313,10 +308,10 @@
PeerIdentity target, int size, final
MessageTransmitter transmitter) {
NotifyTransmitReadyRequest notifyRequest = new
NotifyTransmitReadyRequest();
notifyRequest.priority = priority;
- notifyRequest.deadline = maxdelay.toAbsolute();
notifyRequest.size = size;
notifyRequest.target = target;
notifyRequest.transmitter = transmitter;
+ notifyRequest.setDeadline(maxdelay.toAbsolute());
ConnectedPeerInfo cpi = connectedPeers.get(target);
if (cpi == null) {
Modified: gnunet-java/src/org/gnunet/dht/DistributedHashTable.java
===================================================================
--- gnunet-java/src/org/gnunet/dht/DistributedHashTable.java 2012-10-02
14:54:16 UTC (rev 24162)
+++ gnunet-java/src/org/gnunet/dht/DistributedHashTable.java 2012-10-03
15:23:39 UTC (rev 24163)
@@ -70,7 +70,6 @@
}
private class PutRequest extends Request {
- public AbsoluteTime deadline;
public byte[] data;
public HashCode key;
public int replicationLevel;
@@ -84,11 +83,6 @@
}
@Override
- public AbsoluteTime getDeadline() {
- return deadline;
- }
-
- @Override
public void transmit(Connection.MessageSink sink) {
final ClientPutMessage cpm = new ClientPutMessage();
cpm.data = data;
@@ -273,7 +267,7 @@
pr.key = key;
pr.data = data;
pr.replicationLevel = replicationLevel;
- pr.deadline = timeout.toAbsolute();
+ pr.setDeadline(timeout.toAbsolute());
pr.expiration = expiration;
pr.type = type;
pr.cont = cont;
Modified: gnunet-java/src/org/gnunet/mesh/Mesh.java
===================================================================
--- gnunet-java/src/org/gnunet/mesh/Mesh.java 2012-10-02 14:54:16 UTC (rev
24162)
+++ gnunet-java/src/org/gnunet/mesh/Mesh.java 2012-10-03 15:23:39 UTC (rev
24163)
@@ -202,7 +202,7 @@
}
}
- public class TunnelCreateRequest extends Request {
+ public static class TunnelCreateRequest extends Request {
public RootTunnel tunnel;
public TunnelCreateRequest(RootTunnel rootTunnel) {
Modified: gnunet-java/src/org/gnunet/statistics/Statistics.java
===================================================================
--- gnunet-java/src/org/gnunet/statistics/Statistics.java 2012-10-02
14:54:16 UTC (rev 24162)
+++ gnunet-java/src/org/gnunet/statistics/Statistics.java 2012-10-03
15:23:39 UTC (rev 24163)
@@ -79,7 +79,6 @@
private abstract class StatisticsRequest extends Request {
public String name;
public String subsystem;
- public AbsoluteTime deadline;
}
private class StatisticsGetRequest extends StatisticsRequest {
@@ -89,11 +88,6 @@
currentGetReceiver = null;
}
- public AbsoluteTime getDeadline() {
- return deadline;
- }
-
-
public void transmit(Connection.MessageSink sink) {
GetMessage rm = new GetMessage();
rm.statisticsName = name;
@@ -255,7 +249,7 @@
currentGetContinuation = continuation;
final StatisticsGetRequest getRequest = new StatisticsGetRequest();
- getRequest.deadline = timeout.toAbsolute();
+ getRequest.setDeadline(timeout.toAbsolute());
getRequest.name = (name == null) ? "" : name;
getRequest.subsystem = (subsystem == null) ? "" : subsystem;
getRequest.receiver = receiver;
@@ -274,7 +268,7 @@
*/
public Cancelable set(final String subsystem, final String name, final
long value, boolean persist) {
StatisticsSetRequest setRequest = new StatisticsSetRequest();
- setRequest.deadline = SET_TIMEOUT.toAbsolute();
+ setRequest.setDeadline(SET_TIMEOUT.toAbsolute());
setRequest.subsystem = subsystem;
setRequest.name = name;
setRequest.value = value;
@@ -293,7 +287,7 @@
*/
public Cancelable update(final String subsystem, final String name, final
long delta, boolean persist) {
StatisticsSetRequest setRequest = new StatisticsSetRequest();
- setRequest.deadline = SET_TIMEOUT.toAbsolute();
+ setRequest.setDeadline(SET_TIMEOUT.toAbsolute());
setRequest.subsystem = subsystem;
setRequest.name = name;
setRequest.value = delta;
@@ -304,7 +298,7 @@
public Cancelable watch(final String subsystem, final String name,
StatisticsReceiver receiver) {
StatisticsWatchRequest watchRequest = new StatisticsWatchRequest();
- watchRequest.deadline = AbsoluteTime.FOREVER;
+ watchRequest.setDeadline(AbsoluteTime.FOREVER);
watchRequest.name = name;
watchRequest.subsystem = subsystem;
watchRequest.receiver = receiver;
Modified: gnunet-java/src/org/gnunet/testing/TestingServer.java
===================================================================
--- gnunet-java/src/org/gnunet/testing/TestingServer.java 2012-10-02
14:54:16 UTC (rev 24162)
+++ gnunet-java/src/org/gnunet/testing/TestingServer.java 2012-10-03
15:23:39 UTC (rev 24163)
@@ -53,7 +53,13 @@
}
InetSocketAddress saddr = (InetSocketAddress) socketAddress;
- return new Client(saddr.getHostName(),
srvChan.socket().getLocalPort());
+ String hostname = saddr.getHostName();
+
+ if (hostname == null) {
+ throw new RuntimeException("localhost SocketAddress has no
hostname");
+ }
+
+ return new Client(hostname, srvChan.socket().getLocalPort());
}
}
Modified: gnunet-java/src/org/gnunet/testing/TestingSubsystem.java
===================================================================
--- gnunet-java/src/org/gnunet/testing/TestingSubsystem.java 2012-10-02
14:54:16 UTC (rev 24162)
+++ gnunet-java/src/org/gnunet/testing/TestingSubsystem.java 2012-10-03
15:23:39 UTC (rev 24163)
@@ -77,6 +77,11 @@
} catch (IOException e) {
throw new TestingSetup.SetupException(e);
}
+
+ if (cfgFileName == null) {
+ throw new TestingSetup.SetupException("could not start subsystem
for testing: no config file received from helper");
+ }
+
cfg = new Configuration();
cfg.parse(cfgFileName);
@@ -129,7 +134,7 @@
} catch (IOException e) {
throw new TestingSetup.SetupException(e);
}
- if (!response.equals("restarted")) {
+ if (response == null || !response.equals("restarted")) {
throw new TestingSetup.SetupException("wrapper did not cooperate");
}
}
Modified: gnunet-java/src/org/gnunet/util/Connection.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Connection.java 2012-10-02 14:54:16 UTC
(rev 24162)
+++ gnunet-java/src/org/gnunet/util/Connection.java 2012-10-03 15:23:39 UTC
(rev 24163)
@@ -628,7 +628,6 @@
}
disconnected = true;
-
if (currentTransmitHelper != null) {
currentTransmitHelper.cancel();
currentTransmitHelper = null;
Modified: gnunet-java/src/org/gnunet/util/Resolver.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Resolver.java 2012-10-02 14:54:16 UTC
(rev 24162)
+++ gnunet-java/src/org/gnunet/util/Resolver.java 2012-10-03 15:23:39 UTC
(rev 24163)
@@ -261,7 +261,6 @@
final AbsoluteTime deadline = rh.deadline;
-
logger.debug("deadline is " + deadline + " | now is " +
AbsoluteTime.now());
logger.debug("remaining is " + deadline.getRemaining());
@@ -273,6 +272,7 @@
public void transmit(Connection.MessageSink sink) {
if (sink == null) {
onTimeout(rh);
+ return;
}
sink.send(req);
rh.transmitTask = null;
Modified: gnunet-java/src/org/gnunet/util/Server.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Server.java 2012-10-02 14:54:16 UTC (rev
24162)
+++ gnunet-java/src/org/gnunet/util/Server.java 2012-10-03 15:23:39 UTC (rev
24163)
@@ -506,4 +506,13 @@
}
}
}
+
+ @Override
+ public void finalize() throws Throwable {
+ super.finalize();
+ if (!destroyed) {
+ logger.warn("Server instance not destroyed, but finalizer called");
+ }
+ destroy();
+ }
}
Modified: gnunet-java/src/org/gnunet/voting/CryptoUtil.java
===================================================================
--- gnunet-java/src/org/gnunet/voting/CryptoUtil.java 2012-10-02 14:54:16 UTC
(rev 24162)
+++ gnunet-java/src/org/gnunet/voting/CryptoUtil.java 2012-10-03 15:23:39 UTC
(rev 24163)
@@ -2,6 +2,7 @@
import java.math.BigInteger;
import java.security.SecureRandom;
+import java.util.Random;
/**
* Miscellaneous helper functions.
@@ -19,7 +20,7 @@
*/
public static BigInteger createRandomInRange(BigInteger min,
BigInteger max,
- SecureRandom random) {
+ Random random) {
int cmp = min.compareTo(max);
if (cmp >= 0) {
if (cmp > 0) {
Added: gnunet-java/src/org/gnunet/voting/Cyphertext.java
===================================================================
--- gnunet-java/src/org/gnunet/voting/Cyphertext.java
(rev 0)
+++ gnunet-java/src/org/gnunet/voting/Cyphertext.java 2012-10-03 15:23:39 UTC
(rev 24163)
@@ -0,0 +1,19 @@
+package org.gnunet.voting;
+
+import java.math.BigInteger;
+
+/**
+ * ElGamal encryption of a message.
+ *
+ * @author Florian Dold
+ */
+public class Cyphertext {
+ public final BigInteger c1;
+ public final BigInteger c2;
+
+
+ public Cyphertext(BigInteger c1, BigInteger c2) {
+ this.c1 = c1;
+ this.c2 = c2;
+ }
+}
Deleted: gnunet-java/src/org/gnunet/voting/ElGamalParameters.java
===================================================================
--- gnunet-java/src/org/gnunet/voting/ElGamalParameters.java 2012-10-02
14:54:16 UTC (rev 24162)
+++ gnunet-java/src/org/gnunet/voting/ElGamalParameters.java 2012-10-03
15:23:39 UTC (rev 24163)
@@ -1,101 +0,0 @@
-package org.gnunet.voting;
-
-import java.math.BigInteger;
-import java.security.SecureRandom;
-
-/**
- * Parameters for the ElGamal algorithms.
- *
- * p is a large prime, and g is a high-order element (or even a generator) of
Zp*
- *
- * @author Florian Dold
- */
-public class ElGamalParameters {
-
- private BigInteger p;
- private BigInteger g;
-
- public ElGamalParameters(BigInteger p, BigInteger g) {
- this.p = p;
- this.g = g;
- }
-
- /**
- * which generates the p and g values from the given parameters,
- * returning the ElGamalParameters object.
- * <p/>
- * Note: can take a while...
- */
- public static ElGamalParameters generate(int size, int certainty,
SecureRandom random) {
- BigInteger[] safePrimes = generateSafePrimes(size, certainty, random);
-
- BigInteger p = safePrimes[0];
- BigInteger q = safePrimes[1];
- BigInteger g = selectGenerator(p, q, random);
-
- return new ElGamalParameters(p, g);
- }
-
- /**
- * Finds a pair of prime BigInteger's {p, q: p = 2q + 1}, called safe
primes.
- *
- * (see: Handbook of Applied Cryptography 4.86)
- *
- * @return A 2-element array {p,q} of safe primes.
- */
- private static BigInteger[] generateSafePrimes(int size, int certainty,
SecureRandom random) {
- BigInteger p, q;
- int qLength = size - 1;
-
- while (true) {
- q = new BigInteger(qLength, 2, random);
-
- // p <- 2q + 1
- p = q.shiftLeft(1).add(BigInteger.ONE);
-
- // XXX(dold): why do we test q for primality again?
- if (p.isProbablePrime(certainty) && (certainty <= 2 ||
q.isProbablePrime(certainty))) {
- break;
- }
- }
-
- return new BigInteger[]{p, q};
- }
-
- /*
- * Select a high order element of the multiplicative group Zp*
- *
- * p and q must be s.t. p = 2*q + 1, where p and q are prime (see
generateSafePrimes)
- */
- private static BigInteger selectGenerator(BigInteger p, BigInteger q,
SecureRandom random) {
- BigInteger g;
- final BigInteger pMinusTwo = p.subtract(BigInteger.valueOf(2));
- /*
- * RFC 2631 2.2.1.2 (and see: Handbook of Applied Cryptography 4.81)
- */
- do {
- BigInteger h =
CryptoUtil.createRandomInRange(BigInteger.valueOf(2), pMinusTwo, random);
- g = h.modPow(BigInteger.valueOf(2), p);
- }
- while (g.equals(BigInteger.ONE));
-
- return g;
- }
-
- /**
- * Get the size of the cyclic group Gp used for ElGamal
- *
- * @return the size of the cyclic group Gp used for ElGamal
- */
- public BigInteger getP() {
- return p;
- }
-
- /**
- * Get the generator of Zp*
- * @return the generator of Zp*
- */
- public BigInteger getG() {
- return g;
- }
-}
Copied: gnunet-java/src/org/gnunet/voting/ElGamalScheme.java (from rev 24153,
gnunet-java/src/org/gnunet/voting/ElGamalParameters.java)
===================================================================
--- gnunet-java/src/org/gnunet/voting/ElGamalScheme.java
(rev 0)
+++ gnunet-java/src/org/gnunet/voting/ElGamalScheme.java 2012-10-03
15:23:39 UTC (rev 24163)
@@ -0,0 +1,163 @@
+package org.gnunet.voting;
+
+import java.math.BigInteger;
+import java.security.SecureRandom;
+import java.util.Random;
+
+/**
+ * Utilities the modified ElGamal algorithms.
+ * <p/>
+ * p is a large prime, and g is a high-order element (or even a generator) of
Zp*
+ *
+ * @author Florian Dold
+ */
+public class ElGamalScheme {
+ // large prime, p = 2q + 1
+ private final BigInteger p;
+ // large prime, so that q divides (p-1)
+ private final BigInteger q;
+ // generator of Gq
+ private final BigInteger g;
+
+ public ElGamalScheme(BigInteger p, BigInteger q, BigInteger g) {
+ this.p = p;
+ this.q = q;
+ this.g = g;
+ }
+
+ /**
+ * which generates the p and g values from the given parameters,
+ * returning the ElGamalScheme object.
+ * <p/>
+ * Note: can take a while...
+ */
+ public static ElGamalScheme generateRandomParameters(int size, int
certainty, Random random) {
+ BigInteger[] safePrimes = generateSafePrimes(size, certainty, random);
+
+ BigInteger p = safePrimes[0];
+ BigInteger q = safePrimes[1];
+ BigInteger alpha = selectGenerator(p, q, random);
+ BigInteger g = selectSubgroupHigherOrderElement(alpha, p, q);
+ if (!g.modPow(q, p).equals(BigInteger.ONE)) {
+ throw new AssertionError();
+ }
+ return new ElGamalScheme(p, q, g);
+ }
+
+ /**
+ * Finds a pair of prime BigInteger's {p, q: p = 2q + 1}, called safe
primes.
+ * <p/>
+ * (see: Handbook of Applied Cryptography 4.86)
+ *
+ * @return A 2-element array {p,q} of safe primes.
+ */
+ private static BigInteger[] generateSafePrimes(int size, int certainty,
Random random) {
+ BigInteger p, q;
+ int qLength = size - 1;
+
+ while (true) {
+ q = new BigInteger(qLength, 2, random);
+
+ // p <- 2q + 1
+ p = q.shiftLeft(1).add(BigInteger.ONE);
+
+ // XXX(dold): why do we test q for primality again?
+ if (p.isProbablePrime(certainty) && (certainty <= 2 ||
q.isProbablePrime(certainty))) {
+ break;
+ }
+ }
+
+ return new BigInteger[]{p, q};
+ }
+
+ /*
+ * Select a high order element of the multiplicative group Zn*
+ */
+ private static BigInteger selectHighOrderElement(BigInteger n,
SecureRandom random) {
+ BigInteger g;
+ final BigInteger nMinusTwo = n.subtract(BigInteger.valueOf(2));
+ do {
+ BigInteger h =
CryptoUtil.createRandomInRange(BigInteger.valueOf(2), nMinusTwo, random);
+
+ g = h.modPow(BigInteger.valueOf(2), n);
+ }
+ while (g.equals(BigInteger.valueOf(1)));
+
+ return g;
+ }
+
+ /**
+ * Returns a higher-order-element of Gq, the subgroup of Zp*, with order q
where alpha is a generator of Zp*
+ *
+ * (see Handbook of Applied Cryptography 4.81)
+ */
+ private static BigInteger selectSubgroupHigherOrderElement(BigInteger
alpha, BigInteger p, BigInteger q) {
+ return alpha.modPow(p.subtract(BigInteger.ONE).divide(q), p);
+ }
+
+ /**
+ * Get the size of the cyclic group Gp used for ElGamal
+ *
+ * @return the size of the cyclic group Gp used for ElGamal
+ */
+ public BigInteger getP() {
+ return p;
+ }
+
+ /**
+ * Get the generator of Gq
+ *
+ * @return the generator of Gq
+ */
+ public BigInteger getG() {
+ return g;
+ }
+
+ /**
+ * Get the generator of Zp*
+ *
+ * @return the generator of Zp*
+ */
+ public BigInteger getQ() {
+ return q;
+ }
+
+ public BigInteger generateGq(Random random) {
+ BigInteger r;
+ while (true) {
+ r = CryptoUtil.createRandomInRange(BigInteger.ZERO, this.p,
random);
+ if (r.modPow(q, p).equals(BigInteger.ONE)) {
+ break;
+ }
+ }
+ return r;
+ }
+
+ public static BigInteger selectGenerator(BigInteger p, BigInteger q,
Random random) {
+ BigInteger pMinusTwo = p.subtract(BigInteger.valueOf(2));
+ BigInteger g;
+ /*
+ * (see: Handbook of Applied Cryptography 4.80)
+ */
+ do {
+ g = CryptoUtil.createRandomInRange(BigInteger.valueOf(2),
pMinusTwo, random);
+ }
+ while (g.modPow(BigInteger.valueOf(2), p).equals(BigInteger.ONE) ||
g.modPow(q, p).equals(BigInteger.ONE));
+ return g;
+ }
+
+ public BigInteger generateZp(Random random) {
+ return CryptoUtil.createRandomInRange(BigInteger.ZERO,
this.p.subtract(BigInteger.ONE), random);
+ }
+
+ public BigInteger generateZq(Random random) {
+ return CryptoUtil.createRandomInRange(BigInteger.ZERO,
this.q.subtract(BigInteger.ONE), random);
+ }
+
+ public Cyphertext encrypt(BigInteger message, BigInteger pubKey, Random
random) {
+ BigInteger secret = generateZq(random);
+ return new Cyphertext(g.modPow(secret, p),
message.multiply(pubKey.modPow(secret, p).mod(p)));
+ }
+
+
+}
Modified: gnunet-java/src/org/gnunet/voting/VotingSimulation.java
===================================================================
--- gnunet-java/src/org/gnunet/voting/VotingSimulation.java 2012-10-02
14:54:16 UTC (rev 24162)
+++ gnunet-java/src/org/gnunet/voting/VotingSimulation.java 2012-10-03
15:23:39 UTC (rev 24163)
@@ -1,37 +1,41 @@
package org.gnunet.voting;
import java.math.BigInteger;
-import java.security.SecureRandom;
import java.util.Random;
public class VotingSimulation {
-
/**
- * Evaluate a polynomial over Zp*.
+ * Evaluate a polynomial over Zp*. Uses Horner's scheme.
*
* @param coeffs coefficients of the polynomial, where coeffs[i] is the
coefficient of x^i
* @param x the polynomial is evaluated at this value
- * @param p order or group Zp*
+ * @param p what group are we operating in?
* @return the result of evaluating the polynomial at x
*/
- public static BigInteger evaluateHorner(BigInteger[] coeffs, BigInteger x,
BigInteger p) {
+ public static BigInteger evaluate(BigInteger[] coeffs, BigInteger x,
BigInteger p) {
BigInteger z = BigInteger.ZERO;
- for (int i = coeffs.length - 1; i != 0; --i) {
- z = coeffs[i].add(z.multiply(x).mod(p)).mod(p);
+ for (int i = 0; i < coeffs.length; ++i) {
+ // z <- zx + c
+ z = z.multiply(x).add(coeffs[coeffs.length - i - 1]);
}
return z;
}
public static void main(String... args) {
- final SecureRandom random = new SecureRandom();
- final ElGamalParameters parameters = ElGamalParameters.generate(64,
10, random);
+ final Random random = new Random();
+ final ElGamalScheme parameters =
ElGamalScheme.generateRandomParameters(64, 10, random);
final BigInteger p = parameters.getP();
- final BigInteger g = parameters.getP();
+ final BigInteger q = parameters.getQ();
+ final BigInteger g = parameters.getG();
- final int authorityCount = 5;
+ if (!(g.compareTo(p) < 0)) {
+ throw new AssertionError();
+ }
+
+ final int authorityCount = 10;
// minimum required number of cooperating authorities
- final int k = 3;
+ final int k = 6;
// parts of the private key x, one part for each authority
BigInteger[] xParts = new BigInteger[authorityCount];
@@ -44,10 +48,10 @@
BigInteger h = BigInteger.ONE;
for (int j = 0; j < authorityCount; ++j) {
- xParts[j] = CryptoUtil.createRandomInRange(BigInteger.ZERO,
p.subtract(BigInteger.ONE), random);
+ xParts[j] = parameters.generateZq(random);
hParts[j] = g.modPow(xParts[j], p);
- x = x.add(xParts[j]);
- h = h.multiply(hParts[j]);
+ x = x.add(xParts[j]).mod(q);
+ h = h.multiply(hParts[j]).mod(p);
}
if (!g.modPow(x, p).equals(h)) {
@@ -55,72 +59,141 @@
}
- // f[j][i] is the coefficient of x^i for the polynomial of authority j.
+ // f[j][i] is the coefficient of x^i for the polynomial of authority
j-1.
BigInteger[][] f = new BigInteger[authorityCount][];
- // checkF[j][i] = g^(f[j][i]) mod g
+ // checkF[j][i] = g^(f[j][i]) mod p
// used to check the share parts of each authority
BigInteger[][] checkF = new BigInteger[authorityCount][];
+ // generate the random polynomials
for (int j = 0; j < authorityCount; ++j) {
f[j] = new BigInteger[k];
- f[j][0] = hParts[j];
checkF[j] = new BigInteger[k];
for (int i = 1; i < k; ++i) {
- f[j][i] = CryptoUtil.createRandomInRange(BigInteger.ZERO,
p.subtract(BigInteger.ONE), random);
+ f[j][i] = parameters.generateZq(random);
checkF[j][i] = g.modPow(f[j][i], p);
}
+ f[j][0] = xParts[j];
+ checkF[j][0] = g.modPow(f[j][0], p);
}
// shareParts[j][i] is the polynomial f_j of authority j evaluated at i
// note that shareParts[j][0] is the private key part of authority j
BigInteger[][] shareParts = new BigInteger[authorityCount][];
+
+ // create the transmitted shared by evaluation the polynomials
for (int j = 0; j < authorityCount; ++j) {
shareParts[j] = new BigInteger[authorityCount];
for (int i = 0; i < authorityCount; ++i) {
- shareParts[j][i] = evaluateHorner(f[j], BigInteger.valueOf(i),
p);
+ shareParts[j][i] = evaluate(f[j], BigInteger.valueOf(i + 1),
q);
}
}
- // verification of the received shares: TODO (I can't read the formula
in the paper)
+ // verification of the received shares:
+ for (int j = 0; j < authorityCount; ++j) {
+ // P_j verifies that the shares he received are valid
+ for (int i = 0; i < authorityCount; ++i) {
+ BigInteger v = g.modPow(shareParts[i][j], p);
+ BigInteger prod = BigInteger.ONE;
+ for (int l = 0; l < k; ++l) {
+ BigInteger exp = BigInteger.valueOf(j+1).pow(l);
+ prod = prod.multiply(checkF[i][l].modPow(exp, p)).mod(p);
+ }
+ if (!v.equals(prod)) {
+ throw new AssertionError("verification of transmitted
shared failed");
+ }
+ }
+ }
+
+
+
+
BigInteger[] shares = new BigInteger[authorityCount];
// compute each authority's share as the sum of parts it received
for (int j = 0; j < authorityCount; j++) {
shares[j] = BigInteger.ZERO;
- for (int i = 0; i < k; ++i) {
- shares[j] = shares[j].add(shareParts[j][i]);
+ for (int i = 0; i < authorityCount; ++i) {
+ shares[j] = shares[j].add(shareParts[i][j]);
}
}
- // now we do lagrange interpolation with all shares as points
- BigInteger[] lagrangeBase = new BigInteger[authorityCount];
- // we assume here that all authorities participate
- for (int j = 0; j < authorityCount; ++j) {
- BigInteger z = BigInteger.ONE;
- for (int l = 0; l <= authorityCount; ++l) {
+
+ BigInteger[] lagrangeBase = new BigInteger[k];
+ for (int j = 1; j <= k; ++j) {
+ BigInteger n = BigInteger.ONE;
+ BigInteger d = BigInteger.ONE;
+ for (int l = 1; l <= k; ++l) {
if (l == j) {
- break;
+ continue;
}
- BigInteger n = BigInteger.valueOf(l);
- BigInteger d = BigInteger.valueOf(l-j);
- // todo: is this correct?
- BigInteger dInv = d.modInverse(p);
- z = z.multiply(n).multiply(dInv);
+ n = n.multiply(BigInteger.valueOf(l));
+ d =
d.multiply(BigInteger.valueOf(l).subtract(BigInteger.valueOf(j)));
}
- lagrangeBase[j] = z;
+ lagrangeBase[j-1] = n.multiply(d.modInverse(q)).mod(q);
}
BigInteger xReconstructed = BigInteger.ZERO;
- for (int j = 0; j < authorityCount; ++j) {
- xReconstructed =
xReconstructed.add(shares[j].multiply(lagrangeBase[j])).mod(g);
+ for (int j = 0; j < k; ++j) {
+ xReconstructed =
xReconstructed.add(shares[j].multiply(lagrangeBase[j])).mod(q);
}
- // todo: get this to work!
+ //System.out.println(xReconstructed);
+ //System.out.println(x);
- // todo: cooperative decryption
- // todo: zero knowledge proof for key
+ if (!g.modPow(xReconstructed, p).equals(h)) {
+ throw new AssertionError("key reconstruction failed");
+ }
+
+ BigInteger message = parameters.generateGq(random);
+ Cyphertext cyphertext = parameters.encrypt(message, h, random);
+
+ BigInteger[] w = new BigInteger[k];
+ for (int i = 0; i < k; ++i) {
+ w[i] = cyphertext.c1.modPow(shares[i], p);
+ }
+
+
+ // zero knowledge proof
+ for (int i = 0; i < k; ++i) {
+ // sigma is made public
+ BigInteger sigma = g.modPow(shares[i], p);
+ // prover
+ BigInteger beta = parameters.generateZq(random);
+ BigInteger a = g.modPow(beta, p);
+ BigInteger b = cyphertext.c1.modPow(beta, p);
+ // verifier
+ BigInteger c = parameters.generateZq(random);
+ // prover
+ BigInteger r = beta.add(shares[i].multiply(c));
+ // verifier
+ BigInteger expected1 = g.modPow(r, p);
+ BigInteger received1 = a.multiply(sigma.modPow(c, p)).mod(p);
+
+ BigInteger expected2 = cyphertext.c1.modPow(r, p);
+ BigInteger received2 = b.multiply(w[i].modPow(c, p)).mod(p);
+
+ if ((!expected1.equals(received1)) ||
(!expected2.equals(received2))) {
+ System.err.println(expected1);
+ System.err.println(received1);
+ throw new AssertionError("zero knowledge proof for decryption
failed");
+ }
+ }
+
+ BigInteger messageRestored = cyphertext.c2;
+
+ for (int i = 0; i < k; ++i) {
+ BigInteger v = w[i].modPow(lagrangeBase[i], p);
+ messageRestored = messageRestored.multiply(v.modInverse(p)).mod(p);
+ }
+
+ if (!message.equals(messageRestored)) {
+ throw new AssertionError("decryption failed");
+ }
+
+
}
-}
\ No newline at end of file
+}
Modified: gnunet-java/test/org/gnunet/construct/ConstructTest.java
===================================================================
--- gnunet-java/test/org/gnunet/construct/ConstructTest.java 2012-10-02
14:54:16 UTC (rev 24162)
+++ gnunet-java/test/org/gnunet/construct/ConstructTest.java 2012-10-03
15:23:39 UTC (rev 24163)
@@ -45,7 +45,7 @@
byte[] data = Construct.toBinary(im);
- IntMessage im_new = Construct.parseAs(data, IntMessage.class);
+ Construct.parseAs(data, IntMessage.class);
Assert.assertEquals((1+2+4+8)*2, data.length);
Assert.assertEquals((1+2+4+8)*2, Construct.getStaticSize(im));
@@ -55,7 +55,7 @@
public void test_PrivateMemberMessage() {
PrivateMemberMessage m1 = new PrivateMemberMessage();
byte[] data = Construct.toBinary(m1);
- PrivateMemberMessage m2 = Construct.parseAs(data,
PrivateMemberMessage.class);
+ Construct.parseAs(data, PrivateMemberMessage.class);
}
Modified: gnunet-java/test/org/gnunet/construct/FixedSizeTest.java
===================================================================
--- gnunet-java/test/org/gnunet/construct/FixedSizeTest.java 2012-10-02
14:54:16 UTC (rev 24162)
+++ gnunet-java/test/org/gnunet/construct/FixedSizeTest.java 2012-10-03
15:23:39 UTC (rev 24163)
@@ -47,6 +47,6 @@
public void test_sizeMismatch() {
FixedSizeTestMessage m = new FixedSizeTestMessage();
m.msgs = new Msg[]{new Msg(1), new Msg(2)};
- byte[] bytes = Construct.toBinary(m);
+ Construct.toBinary(m);
}
}
Modified: gnunet-java/test/org/gnunet/construct/StringTuple.java
===================================================================
--- gnunet-java/test/org/gnunet/construct/StringTuple.java 2012-10-02
14:54:16 UTC (rev 24162)
+++ gnunet-java/test/org/gnunet/construct/StringTuple.java 2012-10-03
15:23:39 UTC (rev 24163)
@@ -1,5 +1,8 @@
package org.gnunet.construct;
+import com.google.common.base.Objects;
+import com.google.common.hash.HashCodes;
+
/**
* ...
*
@@ -26,4 +29,9 @@
StringTuple otherT = (StringTuple) other;
return otherT.str1.equals(this.str1) && otherT.str2.equals(this.str2);
}
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(str1, str2);
+ }
}
Modified: gnunet-java/test/org/gnunet/util/getopt/GetoptTest.java
===================================================================
--- gnunet-java/test/org/gnunet/util/getopt/GetoptTest.java 2012-10-02
14:54:16 UTC (rev 24162)
+++ gnunet-java/test/org/gnunet/util/getopt/GetoptTest.java 2012-10-03
15:23:39 UTC (rev 24163)
@@ -258,9 +258,8 @@
Target t = new Target();
Parser p = new Parser(t);
- String[] rest;
- rest = p.parse(new String[]{"-w", "abc"});
+ p.parse(new String[]{"-w", "abc"});
Assert.assertEquals(5, t.intVal);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24163 - in gnunet-java: . doc src/org/gnunet/construct/parsers src/org/gnunet/core src/org/gnunet/dht src/org/gnunet/mesh src/org/gnunet/statistics src/org/gnunet/testing src/org/gnunet/util src/org/gnunet/voting test/org/gnunet/construct test/org/gnunet/util/getopt,
gnunet <=