[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32381 - in gnunet-java/src/main/java/org/gnunet: . secrets
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32381 - in gnunet-java/src/main/java/org/gnunet: . secretsharing secretsharing/callbacks secretsharing/messages |
Date: |
Mon, 17 Feb 2014 17:55:22 +0100 |
Author: dold
Date: 2014-02-17 17:55:22 +0100 (Mon, 17 Feb 2014)
New Revision: 32381
Added:
gnunet-java/src/main/java/org/gnunet/secretsharing/
gnunet-java/src/main/java/org/gnunet/secretsharing/Ciphertext.java
gnunet-java/src/main/java/org/gnunet/secretsharing/Decryption.java
gnunet-java/src/main/java/org/gnunet/secretsharing/FieldElement.java
gnunet-java/src/main/java/org/gnunet/secretsharing/KeyGeneration.java
gnunet-java/src/main/java/org/gnunet/secretsharing/Parameters.java
gnunet-java/src/main/java/org/gnunet/secretsharing/Plaintext.java
gnunet-java/src/main/java/org/gnunet/secretsharing/Share.java
gnunet-java/src/main/java/org/gnunet/secretsharing/ThresholdPublicKey.java
gnunet-java/src/main/java/org/gnunet/secretsharing/callbacks/
gnunet-java/src/main/java/org/gnunet/secretsharing/callbacks/DecryptCallback.java
gnunet-java/src/main/java/org/gnunet/secretsharing/callbacks/SecretReadyCallback.java
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/ClientDecryptMessage.java
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/DecryptDoneMessage.java
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/GenerateMessage.java
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/SecretReadyMessage.java
Log:
- java api for secretsharing
Added: gnunet-java/src/main/java/org/gnunet/secretsharing/Ciphertext.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/secretsharing/Ciphertext.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/secretsharing/Ciphertext.java
2014-02-17 16:55:22 UTC (rev 32381)
@@ -0,0 +1,35 @@
+/*
+ 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.secretsharing;
+
+import org.gnunet.construct.FixedSizeIntegerArray;
+import org.gnunet.construct.Message;
+
+/**
+ * ElGamal ciphertext
+ */
+public class Ciphertext implements Message {
+ @FixedSizeIntegerArray(signed = true, bitSize = 8, length =
Parameters.elgamalBits / 8)
+ public byte[] c_1;
+
+ @FixedSizeIntegerArray(signed = true, bitSize = 8, length =
Parameters.elgamalBits / 8)
+ public byte[] c_2;
+}
Added: gnunet-java/src/main/java/org/gnunet/secretsharing/Decryption.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/secretsharing/Decryption.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/secretsharing/Decryption.java
2014-02-17 16:55:22 UTC (rev 32381)
@@ -0,0 +1,88 @@
+/*
+ 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.secretsharing;
+
+import org.gnunet.secretsharing.callbacks.DecryptCallback;
+import org.gnunet.secretsharing.messages.ClientDecryptMessage;
+import org.gnunet.secretsharing.messages.DecryptDoneMessage;
+import org.gnunet.util.AbsoluteTime;
+import org.gnunet.util.Client;
+import org.gnunet.util.Configuration;
+import org.gnunet.util.RunaboutMessageReceiver;
+
+/**
+ * Cooperatively decrypt a ciphertext.
+ */
+public class Decryption {
+ private Client client;
+ private DecryptCallback decryptCallback;
+
+ private class DecryptionReceiver extends RunaboutMessageReceiver {
+ public void visit(DecryptDoneMessage m) {
+ if (m.success != 0) {
+ decryptCallback.onResult(m.plaintext);
+ } else {
+ decryptCallback.onResult(null);
+ }
+ client.disconnect();
+ client = null;
+ }
+ @Override
+ public void handleError() {
+ decryptCallback.onResult(null);
+ }
+ }
+
+ /**
+ * Cooperatively decrypt a ciphertext encrypted with a
+ * threshold key.
+ *
+ * @param configuration configuration to use for connecting to the
+ * secretsharing service
+ * @param share the local peer's share of the threshold key
+ * @param ciphertext ciphertext to decrypt
+ * @param start when should we start decrypting?
+ * @param deadline when should decryption be finished?
+ * @param decryptCallback called when the decryption finished, or
+ * an error occurred.
+ */
+ public Decryption(Configuration configuration, Share share, Ciphertext
ciphertext,
+ AbsoluteTime start, AbsoluteTime deadline,
DecryptCallback decryptCallback) {
+ this.decryptCallback = decryptCallback;
+ client = new Client("secretsharing", configuration);
+ client.installReceiver(new DecryptionReceiver());
+
+ ClientDecryptMessage m = new ClientDecryptMessage();
+ m.ciphertext = ciphertext;
+ m.deadline = deadline.asMessage();
+ m.start = start.asMessage();
+ m.share = share;
+
+ client.send(m);
+ }
+
+ public void disconnect() {
+ if (null != client) {
+ client.disconnect();
+ client = null;
+ }
+ }
+}
Added: gnunet-java/src/main/java/org/gnunet/secretsharing/FieldElement.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/secretsharing/FieldElement.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/secretsharing/FieldElement.java
2014-02-17 16:55:22 UTC (rev 32381)
@@ -0,0 +1,29 @@
+/*
+ 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.secretsharing;
+
+import org.gnunet.construct.FixedSizeIntegerArray;
+import org.gnunet.construct.Message;
+
+public class FieldElement implements Message {
+ @FixedSizeIntegerArray(signed = true, bitSize = 8, length =
Parameters.elgamalBits / 8)
+ public byte[] bits;
+}
Added: gnunet-java/src/main/java/org/gnunet/secretsharing/KeyGeneration.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/secretsharing/KeyGeneration.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/secretsharing/KeyGeneration.java
2014-02-17 16:55:22 UTC (rev 32381)
@@ -0,0 +1,88 @@
+/*
+ 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.secretsharing;
+
+import org.gnunet.secretsharing.callbacks.SecretReadyCallback;
+import org.gnunet.secretsharing.messages.GenerateMessage;
+import org.gnunet.secretsharing.messages.SecretReadyMessage;
+import org.gnunet.util.*;
+
+/**
+ * Key generation session.
+ */
+public class KeyGeneration {
+ private Client client;
+ private SecretReadyCallback secretReadyCallback;
+
+ private class KeyGenerationReceiver extends RunaboutMessageReceiver {
+ public void visit(SecretReadyMessage m) {
+ secretReadyCallback.onSecretReady(m.share);
+ client.disconnect();
+ client = null;
+ }
+ @Override
+ public void handleError() {
+ secretReadyCallback.onSecretReady(null);
+ }
+ }
+
+ /**
+ * Generate a threshold key pair.
+ *
+ * @param configuration configuratio to use
+ * @param peers peers in the session, the local peer is optional
+ * @param sessionId session id
+ * @param start when should we start to generate the key with other peers?
+ * @param deadline when should the key generation be finished?
+ * @param threshold minimum number of peers required to decrypt a
ciphertext
+ * @param secretReadyCallback called when the key has been generated or
+ * an error occured
+ */
+ public KeyGeneration(Configuration configuration, PeerIdentity[] peers,
+ HashCode sessionId, AbsoluteTime start, AbsoluteTime
deadline,
+ int threshold, SecretReadyCallback
secretReadyCallback) {
+ this.client = new Client("secretsharing", configuration);
+ this.secretReadyCallback = secretReadyCallback;
+
+ client.installReceiver(new KeyGenerationReceiver());
+
+ GenerateMessage m = new GenerateMessage();
+ m.start = start.asMessage();
+ m.deadline = deadline.asMessage();
+ m.threshold = threshold;
+ m.numPeers = peers.length;
+ m.peers = peers;
+ m.sessionId = sessionId;
+
+ client.send(m);
+ }
+
+ /**
+ * Disconnect from the secretsharing service and cancel the operation.
+ * The SecretReadyCallback will not be called after calling disconnect.
+ */
+ public void disconnect() {
+ if (null != client) {
+ client.disconnect();
+ client = null;
+ }
+ }
+}
Added: gnunet-java/src/main/java/org/gnunet/secretsharing/Parameters.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/secretsharing/Parameters.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/secretsharing/Parameters.java
2014-02-17 16:55:22 UTC (rev 32381)
@@ -0,0 +1,69 @@
+/*
+ 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.secretsharing;
+
+import java.math.BigInteger;
+
+/**
+ * Constants used by the crypto of the secretsharing API.
+ */
+public interface Parameters {
+ /**
+ * Size of the key.
+ */
+ public static final int elgamalBits = 1024;
+
+ /**
+ * Order of the group.
+ */
+ public static final BigInteger elgamalQ = new BigInteger(
+ "0451a3e9eb4f4596ebe8d895046fde65f5fa65" +
+ "37a134d040a70ac51a1894b26ca359f79144118b" +
+ "95e7987e047bb93ba65a027cde001537b3584d3c" +
+ "ec086b3e27c659df6e303071e477c3a58db26fb8" +
+ "b63e958016d4407134a1c6ad3bb735af929e46fa" +
+ "b50b58e3e72c6f783e01eda411c556fe2951aa51" +
+ "3f6942d860b3ae569f9", 16);
+
+ /**
+ * Modulus of the group.
+ */
+ public static final BigInteger elgamalP = new BigInteger(
+ "08a347d3d69e8b2dd7d1b12a08dfbccbebf4ca" +
+ "6f4269a0814e158a34312964d946b3ef22882317" +
+ "2bcf30fc08f772774cb404f9bc002a6f66b09a79" +
+ "d810d67c4f8cb3bedc6060e3c8ef874b1b64df71" +
+ "6c7d2b002da880e269438d5a776e6b5f253c8df5" +
+ "6a16b1c7ce58def07c03db48238aadfc52a354a2" +
+ "7ed285b0c1675cad3f3", 16);
+
+ /**
+ * Generator of the group.
+ */
+ public static final BigInteger elgamalG = new BigInteger(
+ "05c00c36d2e822950087ef09d8252994adc4e4" +
+ "8fe3ec70269f035b46063aff0c99b633fd64df43" +
+ "02442e1914c829a41505a275438871f365e91c12" +
+ "3d5303ef9e90f4b8cb89bf86cc9b513e74a72634" +
+ "9cfd9f953674fab5d511e1c078fc72d72b34086f" +
+ "c82b4b951989eb85325cb203ff98df76bc366bba" +
+ "1d7024c3650f60d0da", 16);
+}
Added: gnunet-java/src/main/java/org/gnunet/secretsharing/Plaintext.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/secretsharing/Plaintext.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/secretsharing/Plaintext.java
2014-02-17 16:55:22 UTC (rev 32381)
@@ -0,0 +1,90 @@
+/*
+ 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.secretsharing;
+
+import com.google.common.base.Preconditions;
+import org.gnunet.construct.FixedSizeIntegerArray;
+import org.gnunet.construct.Message;
+
+import java.math.BigInteger;
+import java.security.SecureRandom;
+
+public class Plaintext implements Message {
+ @FixedSizeIntegerArray(signed = true, bitSize = 8, length =
Parameters.elgamalBits / 8)
+ public byte[] bits;
+
+ public static Plaintext generate(BigInteger exp) {
+ BigInteger val;
+ val = Parameters.elgamalG.modPow(exp, Parameters.elgamalP);
+ Plaintext plaintext = new Plaintext();
+ plaintext.bits = serializeBigIntUnsigned(val, Parameters.elgamalBits);
+ return plaintext;
+ }
+
+ /**
+ * Serialize a BigInteger, but do not add an extra bit for a
+ * sign.
+ *
+ * @param bigInteger
+ * @param bits
+ * @return
+ */
+ private static byte[] serializeBigIntUnsigned(BigInteger bigInteger, int
bits) {
+ byte[] bytes = bigInteger.toByteArray();
+ int start;
+ Preconditions.checkArgument(bigInteger.bitCount() <= bits);
+ // skip byte that was only added to fit the sign
+ if (bytes[0] == 0) {
+ start = 1;
+ } else {
+ start = 0;
+ }
+ byte[] fixedBytes = new byte[(bits + 7) / 8];
+ System.arraycopy(bytes, start, fixedBytes,
+ fixedBytes.length - bytes.length + start, bytes.length -
start);
+ return fixedBytes;
+ }
+
+ public Ciphertext encrypt(ThresholdPublicKey publicKey) {
+ SecureRandom secureRandom = new SecureRandom();
+ BigInteger c_1;
+ BigInteger c_2;
+ BigInteger y;
+ BigInteger m;
+ BigInteger h;
+
+ m = new BigInteger(1, this.bits);
+ h = new BigInteger(1, publicKey.bits);
+
+ do {
+ y = new BigInteger(Parameters.elgamalBits - 1, secureRandom);
+ } while (y.compareTo(BigInteger.ONE) == 0 ||
y.compareTo(Parameters.elgamalQ) >= 0);
+
+ c_1 = Parameters.elgamalG.modPow(y, Parameters.elgamalP);
+ c_2 = m.multiply(h.modPow(y,
Parameters.elgamalP)).mod(Parameters.elgamalP);
+
+ Ciphertext ciphertext = new Ciphertext();
+ ciphertext.c_1 = serializeBigIntUnsigned(c_1, Parameters.elgamalBits);
+ ciphertext.c_2 = serializeBigIntUnsigned(c_2, Parameters.elgamalBits);
+
+ return ciphertext;
+ }
+}
Added: gnunet-java/src/main/java/org/gnunet/secretsharing/Share.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/secretsharing/Share.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/secretsharing/Share.java
2014-02-17 16:55:22 UTC (rev 32381)
@@ -0,0 +1,63 @@
+package org.gnunet.secretsharing;
+
+import org.gnunet.construct.*;
+import org.gnunet.util.PeerIdentity;
+
+/**
+ * Share of the threshold secret key. Contains both the
+ * public key as well as one peer's private share.
+ */
+public class Share implements Message {
+ /**
+ * Threshold for the key this share belongs to.
+ */
+ @UInt16
+ public int threshold;
+
+ /**
+ * Peers that have the share.
+ */
+ @UInt16
+ public int numPeers;
+
+ /**
+ * Index of our peer in the list.
+ */
+ @UInt16
+ public int myPeer;
+
+ /**
+ * Padding, always zero.
+ */
+ @UInt16
+ public int padding;
+
+ /**
+ * Public key. Must correspond to the product of
+ * the homomorphic share commitments.
+ */
+ @NestedMessage
+ public ThresholdPublicKey publicKey;
+
+ /**
+ * Share of 'my_peer'
+ */
+ @NestedMessage
+ public FieldElement myShare;
+
+ /**
+ * Peers that have a share of the secret.
+ */
+ @VariableSizeArray(lengthField = "numPeers")
+ public PeerIdentity[] peerIdentities;
+
+ /**
+ * Sigma for each peer. The sigma is pow(g,s)
+ * where g is the generator and s is the peer's share.
+ */
+ @VariableSizeArray(lengthField = "numPeers")
+ public FieldElement[] sigmas;
+
+ @VariableSizeIntegerArray(lengthField = "numPeers", bitSize = 16, signed =
false)
+ public int[] originalIndices;
+}
Added:
gnunet-java/src/main/java/org/gnunet/secretsharing/ThresholdPublicKey.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/secretsharing/ThresholdPublicKey.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/secretsharing/ThresholdPublicKey.java
2014-02-17 16:55:22 UTC (rev 32381)
@@ -0,0 +1,32 @@
+/*
+ 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.secretsharing;
+
+import org.gnunet.construct.FixedSizeIntegerArray;
+import org.gnunet.construct.Message;
+
+/**
+ * Threshold public key.
+ */
+public class ThresholdPublicKey implements Message {
+ @FixedSizeIntegerArray(signed = true, bitSize = 8, length =
Parameters.elgamalBits / 8)
+ public byte[] bits;
+}
Added:
gnunet-java/src/main/java/org/gnunet/secretsharing/callbacks/DecryptCallback.java
===================================================================
---
gnunet-java/src/main/java/org/gnunet/secretsharing/callbacks/DecryptCallback.java
(rev 0)
+++
gnunet-java/src/main/java/org/gnunet/secretsharing/callbacks/DecryptCallback.java
2014-02-17 16:55:22 UTC (rev 32381)
@@ -0,0 +1,35 @@
+/*
+ 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.secretsharing.callbacks;
+
+import org.gnunet.secretsharing.Plaintext;
+
+/**
+ * Callback for when the secretsharing service has decrypted a ciphertext.
+ */
+public interface DecryptCallback {
+ /**
+ * Called when the secretsharing service has decrypted a ciphertext.
+ *
+ * @param plaintext the plaintext, or null on error
+ */
+ void onResult(Plaintext plaintext);
+}
Added:
gnunet-java/src/main/java/org/gnunet/secretsharing/callbacks/SecretReadyCallback.java
===================================================================
---
gnunet-java/src/main/java/org/gnunet/secretsharing/callbacks/SecretReadyCallback.java
(rev 0)
+++
gnunet-java/src/main/java/org/gnunet/secretsharing/callbacks/SecretReadyCallback.java
2014-02-17 16:55:22 UTC (rev 32381)
@@ -0,0 +1,35 @@
+/*
+ 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.secretsharing.callbacks;
+
+import org.gnunet.secretsharing.Share;
+
+/**
+ * Callback for when shared secret key has been established.
+ */
+public interface SecretReadyCallback {
+ /**
+ * Called when the shared secret key has been established.
+ * @param share the share for the local peer, including the public key,
+ * or null on error
+ */
+ public void onSecretReady(Share share);
+}
Added:
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/ClientDecryptMessage.java
===================================================================
---
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/ClientDecryptMessage.java
(rev 0)
+++
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/ClientDecryptMessage.java
2014-02-17 16:55:22 UTC (rev 32381)
@@ -0,0 +1,59 @@
+/*
+ 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.secretsharing.messages;
+
+import org.gnunet.construct.NestedMessage;
+import org.gnunet.construct.UnionCase;
+import org.gnunet.secretsharing.Ciphertext;
+import org.gnunet.secretsharing.Share;
+import org.gnunet.util.AbsoluteTimeMessage;
+import org.gnunet.util.GnunetMessage;
+
+/**
+ * Sent by the client to the service to request the cooperative decryption of a
+ * ciphertext.
+ */
address@hidden(781)
+public class ClientDecryptMessage implements GnunetMessage.Body {
+ /**
+ * When should communication with other peers start?
+ */
+ @NestedMessage
+ public AbsoluteTimeMessage start;
+
+ /**
+ * When should the operation have finished?
+ */
+ @NestedMessage
+ public AbsoluteTimeMessage deadline;
+
+ /**
+ * Ciphertext to cooperatively decrypt.
+ */
+ @NestedMessage
+ public Ciphertext ciphertext;
+
+ /**
+ * Our share of the secret key.
+ */
+ @NestedMessage
+ public Share share;
+}
Added:
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/DecryptDoneMessage.java
===================================================================
---
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/DecryptDoneMessage.java
(rev 0)
+++
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/DecryptDoneMessage.java
2014-02-17 16:55:22 UTC (rev 32381)
@@ -0,0 +1,48 @@
+/*
+
+ 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.secretsharing.messages;
+
+import org.gnunet.construct.NestedMessage;
+import org.gnunet.construct.UInt32;
+import org.gnunet.construct.UnionCase;
+import org.gnunet.secretsharing.Plaintext;
+import org.gnunet.util.GnunetMessage;
+
+/**
+ * Created by dold on 2/2/14.
+ */
address@hidden(782)
+public class DecryptDoneMessage implements GnunetMessage.Body{
+
+ /**
+ * Was the decryption successful?
+ */
+ @UInt32
+ public int success;
+
+ /**
+ * Plaintext, only valid if 'success' is non-zero.
+ */
+ @NestedMessage
+ public Plaintext plaintext;
+}
Added:
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/GenerateMessage.java
===================================================================
---
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/GenerateMessage.java
(rev 0)
+++
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/GenerateMessage.java
2014-02-17 16:55:22 UTC (rev 32381)
@@ -0,0 +1,51 @@
+/*
+
+ 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.secretsharing.messages;
+
+import org.gnunet.construct.NestedMessage;
+import org.gnunet.construct.UInt16;
+import org.gnunet.construct.UnionCase;
+import org.gnunet.construct.VariableSizeArray;
+import org.gnunet.util.*;
+
+
address@hidden(780)
+public class GenerateMessage implements GnunetMessage.Body {
+ @NestedMessage
+ public HashCode sessionId;
+
+ @NestedMessage
+ public AbsoluteTimeMessage start;
+
+ @NestedMessage
+ public AbsoluteTimeMessage deadline;
+
+ @UInt16
+ public int threshold;
+
+ @UInt16
+ public int numPeers;
+
+ @VariableSizeArray(lengthField = "numPeers")
+ public PeerIdentity[] peers;
+}
Added:
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/SecretReadyMessage.java
===================================================================
---
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/SecretReadyMessage.java
(rev 0)
+++
gnunet-java/src/main/java/org/gnunet/secretsharing/messages/SecretReadyMessage.java
2014-02-17 16:55:22 UTC (rev 32381)
@@ -0,0 +1,39 @@
+/*
+ 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.secretsharing.messages;
+
+import org.gnunet.construct.NestedMessage;
+import org.gnunet.construct.UnionCase;
+import org.gnunet.secretsharing.Share;
+import org.gnunet.util.GnunetMessage;
+
+/**
+ * Sent by the service to the client when the key generation
+ * has been successful.
+ */
address@hidden(783)
+public class SecretReadyMessage implements GnunetMessage.Body {
+ /**
+ * Share for the local peer.
+ */
+ @NestedMessage
+ public Share share;
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32381 - in gnunet-java/src/main/java/org/gnunet: . secretsharing secretsharing/callbacks secretsharing/messages,
gnunet <=