[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r31962 - in gnunet-java: . src/main/java/org/gnunet src/mai
From: |
gnunet |
Subject: |
[GNUnet-SVN] r31962 - in gnunet-java: . src/main/java/org/gnunet src/main/java/org/gnunet/gns src/main/java/org/gnunet/gns/messages src/main/java/org/gnunet/requests |
Date: |
Mon, 20 Jan 2014 22:40:52 +0100 |
Author: dold
Date: 2014-01-20 22:40:51 +0100 (Mon, 20 Jan 2014)
New Revision: 31962
Added:
gnunet-java/src/main/java/org/gnunet/gns/
gnunet-java/src/main/java/org/gnunet/gns/GNS.java
gnunet-java/src/main/java/org/gnunet/gns/GnsRecord.java
gnunet-java/src/main/java/org/gnunet/gns/LookupResultProcessor.java
gnunet-java/src/main/java/org/gnunet/gns/messages/
gnunet-java/src/main/java/org/gnunet/gns/messages/ClientLookupMessage.java
gnunet-java/src/main/java/org/gnunet/gns/messages/ClientLookupResultMessage.java
Modified:
gnunet-java/ISSUES
gnunet-java/src/main/java/org/gnunet/requests/MatchingRequestContainer.java
gnunet-java/src/main/java/org/gnunet/requests/RequestContainer.java
Log:
- rudimentary support for GNS
- issues
Modified: gnunet-java/ISSUES
===================================================================
--- gnunet-java/ISSUES 2014-01-20 21:21:15 UTC (rev 31961)
+++ gnunet-java/ISSUES 2014-01-20 21:40:51 UTC (rev 31962)
@@ -1,58 +1,50 @@
-* even though my talk was quite horrible, I got to know
- some TOR people, who need distributed _nonce_ generation (which requires
byz-consensus ...)
+secretsharing
+ * plaintexts:
+ * due to the (sub-)group we chose, not every bit pattern is a valid
+ message
+ * => GNUNET_SECRETSHARING_message_generate (...)
-* in the current protocol, a rushing adversary may still _influence_ (but not
determine)
- the public key, will that be a problem?
- * the same "attack" as on tor's nonce generation scheme
+secretsharing working, both keygen and decryption
+ * debugging was a pain ...
-* secretsharing DKG and cooperative decryption implemented and working
- * ... but not robust yet (signatures!)
- * ... and without the ZKP that requires the gauss lattice reduction
+libgcrypt:
+The following code does not terminate.
-* how is work on multicast going, and is there any chance that
- gradecast could fit into there?
+ gcry_mpi_set_ui (x, 0);
+ gcry_mpi_sub_ui (x, x, 1);
+ gcry_mpi_set_ui (p, 17);
+ gcry_mpi_invm (x, x, p);
-* Distributed Key Generation and Its Applications, Aniket Pundlik Kate, 2010
- * a PhD thesis that discusses the first DKG protocol useable for "the
internet",
- but does never mention / cite Fouque and Stern
+... which was very "nice" to spot because
+ gcry_mpi_dump prints -1 as "01" ...
-* neither the documentation nor the C tutorial mention when to use
GNUNET_PACKED,
- and its relation to GNUNET_NETWORK_STRUCT_*
+ * it's kind of hard to trust any gcry_mpi_* op that involves
+ any kind of negative value ....
-* why is the purpose size uint32_t?
- * that bit me ...
+ * it's not documented what powm does when the exponent is negative, but the
inverse
+ does not exist!
+ * invm at least returns an error flag ...
-* currently i'm printing MPIs wrong in some places
-* dependencies: secretsharing_common.c / is it ok to
- include gnunet_secretsharing_service.h in the service itself?
- * well according to other services it is ...
+secretsharing:
+ * problem with valgrind+testbed: slows stuff down, serialized due to testbed
+ * consensi get out of sync, but are started at the very beginning
+ * proposal: also specify start time for DKG,
+ crypto setup is done *before* start time (of consensus)
-* there now is GNUNET_new_array
+paillier is now in util!
-* crashing services after tests are not reported
+next: implement ZKPs
-* consensus now properly requires an absolute time deadline
-* gnunet-java has gnunet-elgamal, which I used to generate keys
-
address@hidden:~/repos/gnunet-java$ ./bin/gnunet-elgamal -C 32 -b 1024
-Generating parameters with bitlength 1024 and certainty 32
-p:
0x08a347d3d69e8b2dd7d1b12a08dfbccbebf4ca6f4269a0814e158a34312964d946b3ef228823172bcf30fc08f772774cb404f9bc002a6f66b09a79d810d67c4f8cb3bedc6060e3c8ef874b1b64df716c7d2b002da880e269438d5a776e6b5f253c8df56a16b1c7ce58def07c03db48238aadfc52a354a27ed285b0c1675cad3f3
-q:
0x0451a3e9eb4f4596ebe8d895046fde65f5fa6537a134d040a70ac51a1894b26ca359f79144118b95e7987e047bb93ba65a027cde001537b3584d3cec086b3e27c659df6e303071e477c3a58db26fb8b63e958016d4407134a1c6ad3bb735af929e46fab50b58e3e72c6f783e01eda411c556fe2951aa513f6942d860b3ae569f9
-g:
0x05c00c36d2e822950087ef09d8252994adc4e48fe3ec70269f035b46063aff0c99b633fd64df4302442e1914c829a41505a275438871f365e91c123d5303ef9e90f4b8cb89bf86cc9b513e74a726349cfd9f953674fab5d511e1c078fc72d72b34086fc82b4b951989eb85325cb203ff98df76bc366bba1d7024c3650f60d0da
-
-q, p=2q+1 are primes with failure prob. < 2^{-32}, g is just a generator
-
-* where's the best place to store the constants when both the service api and
- service implementation need to access it?
-
-
-
-On the topic of randomness, aren't e.g. identities generated "in process",
i.e. with quick random
-enabled?
-
-/* we only generate ephemeral keys in-process; for those,
- we are fine with "just" using GCRY_STRONG_RANDOM */
-if ((rc = gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0)))
-
+GNS:
+ * rudimentary implementation in gnunet-java
+ * why is record type in gns_api int, and not unsigned int?
+ * gnsrecord: we're lost in java with the plugins
+ * call some helper bin for e.g. record type printing?
+ * use JNA (ctypes-style library for Java)
+ LookupMessage: string termination not documented
+ * fixed, but can't we agree on one way?
+ LookupResultMessage:
+ /* followed by rd_count GNUNET_GNSRECORD_Data structs*/
+ can't be true, as the struct contains a pointer ...
Added: gnunet-java/src/main/java/org/gnunet/gns/GNS.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/gns/GNS.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/gns/GNS.java 2014-01-20 21:40:51 UTC
(rev 31962)
@@ -0,0 +1,145 @@
+/*
+ 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.gns;
+
+import org.gnunet.gns.messages.ClientLookupMessage;
+import org.gnunet.gns.messages.ClientLookupResultMessage;
+import org.gnunet.mq.Envelope;
+import org.gnunet.requests.MatchingRequestContainer;
+import org.gnunet.requests.RequestContainer;
+import org.gnunet.util.*;
+import org.gnunet.util.crypto.EcdsaPrivateKey;
+import org.gnunet.util.crypto.EcdsaPublicKey;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * API to the GNUnet name system.
+ */
+public class GNS {
+ private static final Logger logger = LoggerFactory
+ .getLogger(GNS.class);
+ /**
+ * All pending and active lookup requests.
+ */
+ private MatchingRequestContainer<Long, LookupRequest> lookupRequests;
+
+ private class LookupRequest extends RequestContainer.Request {
+ long uid;
+ String name;
+ EcdsaPublicKey zone;
+ int type;
+ boolean onlyCached;
+ EcdsaPrivateKey shortenZoneKey;
+ LookupResultProcessor proc;
+
+ public LookupRequest(String name,
+ EcdsaPublicKey zone,
+ int type,
+ boolean onlyCached,
+ EcdsaPrivateKey shortenZoneKey,
+ LookupResultProcessor proc) {
+ this.uid = nextUID++;
+ this.name = name;
+ this.zone = zone;
+ this.type = type;
+ this.onlyCached = onlyCached;
+ this.shortenZoneKey = shortenZoneKey;
+ this.proc = proc;
+ }
+
+ @Override
+ public Envelope assembleRequest() {
+ ClientLookupMessage m = new ClientLookupMessage();
+ if (null != shortenZoneKey) {
+ m.haveKey = 1;
+ } else {
+ m.shortenKey = shortenZoneKey;
+ }
+ m.id = uid;
+ m.name = name;
+ m.onlyCached = onlyCached ? 1 : 0;
+ m.type = type;
+ m.zone = zone;
+ return new Envelope(m);
+ }
+ }
+
+ public class GNSMessageReceiver extends RunaboutMessageReceiver {
+ public void visit(ClientLookupResultMessage m) {
+ LookupRequest r = lookupRequests.pollRequest(m.id);
+ if (null == r) {
+ logger.warn("no matching request for lookup result");
+ return;
+ }
+ r.proc.process(m.records);
+ }
+
+ @Override
+ public void handleError() {
+ }
+ }
+
+ /**
+ * Request ID for lookup requests.
+ */
+ private long nextUID = 1;
+
+ /**
+ * Client connected to the GNS service.
+ */
+ private Client client;
+
+ /**
+ * Connect to the GNS service
+ *
+ * @param cfg configuration to use
+ */
+ public GNS(Configuration cfg) {
+ client = new Client("gns", cfg);
+ lookupRequests = new MatchingRequestContainer<Long,
LookupRequest>(client);
+ client.installReceiver(new GNSMessageReceiver());
+ }
+
+ /**
+ * Perform an asynchronous lookup operation on the GNS.
+ *
+ * @param name the name to look up
+ * @param zone zone to look in
+ * @param type the GNS record type to look for
+ * @param onlyCached true to only check locally (not in the DHT)
+ * @param shortenZoneKey the private key of the shorten zone (can be NULL);
+ * specify to enable automatic shortening (given a PSEU
+ * record, if a given pseudonym is not yet used in the
+ * shorten zone, we automatically add the respective
zone
+ * under that name)
+ * @param proc function to call on result
+ * @return handle to the queued request
+ */
+ public Cancelable lookup(String name,
+ EcdsaPublicKey zone,
+ int type, boolean onlyCached,
+ EcdsaPrivateKey shortenZoneKey,
+ LookupResultProcessor proc) {
+ LookupRequest r = new LookupRequest(name, zone, type, onlyCached,
shortenZoneKey, proc);
+ return lookupRequests.addRequest(r.uid, r);
+ }
+}
Added: gnunet-java/src/main/java/org/gnunet/gns/GnsRecord.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/gns/GnsRecord.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/gns/GnsRecord.java 2014-01-20
21:40:51 UTC (rev 31962)
@@ -0,0 +1,86 @@
+/*
+ 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.gns;
+
+import org.gnunet.construct.Message;
+import org.gnunet.construct.UInt32;
+import org.gnunet.construct.UInt64;
+import org.gnunet.construct.VariableSizeIntegerArray;
+
+/**
+ * A GNS record.
+ */
+public class GnsRecord implements Message {
+ /**
+ * No special options.
+ */
+ public static final int FLAG_NONE = 0;
+ /**
+ * No special options.
+ */
+ public static final int FLAG_PRIVATE = 2;
+ /**
+ * This record was added automatically by the system
+ * and is pending user confimation.
+ */
+ public static final int FLAG_PENDING = 4;
+ /**
+ * This expiration time of the record is a relative
+ * time (not an absolute time).
+ */
+ public static final int FLAG_RELATIVE_EXPIRATION = 8;
+ /**
+ * This record should not be used unless all (other) records with an
absolute
+ * expiration time have expired.
+ */
+ public static final int FLAG_SHADOW_RECOD = 8;
+ /**
+ * Either absolute or relative expiration time,
+ * depending on 'flags'.
+ */
+ @UInt64
+ public long expirationTime;
+
+ /**
+ * Size of the record data.
+ */
+ @UInt32
+ public int dataSize;
+
+ /**
+ * Type of the record.
+ */
+ @UInt32
+ public int recordType;
+
+ /**
+ * Flags for the record.
+ */
+ @UInt32
+ int flags;
+
+ /**
+ * Binary value stored in the GNS record.
+ */
+ @VariableSizeIntegerArray(lengthField = "dataSize", bitSize = 8, signed =
false)
+ byte[] data;
+
+}
Added: gnunet-java/src/main/java/org/gnunet/gns/LookupResultProcessor.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/gns/LookupResultProcessor.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/gns/LookupResultProcessor.java
2014-01-20 21:40:51 UTC (rev 31962)
@@ -0,0 +1,34 @@
+/*
+ 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.gns;
+
+
+/**
+ * Processor for GNS request results.
+ */
+public interface LookupResultProcessor {
+ /**
+ * Process an array of records.
+ *
+ * @param records Records to process.
+ */
+ void process(GnsRecord[] records);
+}
Added:
gnunet-java/src/main/java/org/gnunet/gns/messages/ClientLookupMessage.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/gns/messages/ClientLookupMessage.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/gns/messages/ClientLookupMessage.java
2014-01-20 21:40:51 UTC (rev 31962)
@@ -0,0 +1,73 @@
+/*
+ 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.gns.messages;
+
+import org.gnunet.construct.*;
+import org.gnunet.util.GnunetMessage;
+import org.gnunet.util.crypto.EcdsaPrivateKey;
+import org.gnunet.util.crypto.EcdsaPublicKey;
+
+/**
+ * Message from client to GNS service to lookup records.
+ */
address@hidden(500)
+public class ClientLookupMessage implements GnunetMessage.Body {
+ /**
+ * Unique identifier for this request (for key collisions).
+ */
+ @UInt32
+ public long id;
+
+ /**
+ * Zone that is to be used for lookup
+ */
+ @NestedMessage
+ public EcdsaPublicKey zone;
+ /**
+ * Only check cached results
+ */
+ @Int16
+ public int onlyCached;
+
+ /**
+ * Is a shorten key attached?
+ */
+ @Int16
+ public int haveKey;
+
+ /**
+ * the type of record to look up
+ */
+ @Int32
+ public int type;
+
+ /**
+ * The key for shorten, if haveKey is set
+ */
+ @NestedMessage
+ public EcdsaPrivateKey shortenKey;
+
+ /**
+ * The name.
+ */
+ @ZeroTerminatedString
+ public String name;
+}
Added:
gnunet-java/src/main/java/org/gnunet/gns/messages/ClientLookupResultMessage.java
===================================================================
---
gnunet-java/src/main/java/org/gnunet/gns/messages/ClientLookupResultMessage.java
(rev 0)
+++
gnunet-java/src/main/java/org/gnunet/gns/messages/ClientLookupResultMessage.java
2014-01-20 21:40:51 UTC (rev 31962)
@@ -0,0 +1,66 @@
+/*
+ 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.
+ */
+
+/*
+ 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.gns.messages;
+
+import org.gnunet.construct.*;
+import org.gnunet.gns.GnsRecord;
+import org.gnunet.util.GnunetMessage;
+import org.gnunet.util.crypto.EcdsaPrivateKey;
+import org.gnunet.util.crypto.EcdsaPublicKey;
+
+/**
+ * Message GNS service to client as a response to a lookup request.
+ */
address@hidden(501)
+public class ClientLookupResultMessage implements GnunetMessage.Body {
+ /**
+ * Unique identifier for this request.
+ */
+ @UInt32
+ public long id;
+
+ @UInt32
+ public long recordCount;
+
+ @VariableSizeArray(lengthField = "recordCount")
+ public
+ GnsRecord[] records;
+}
Modified:
gnunet-java/src/main/java/org/gnunet/requests/MatchingRequestContainer.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/requests/MatchingRequestContainer.java
2014-01-20 21:21:15 UTC (rev 31961)
+++ gnunet-java/src/main/java/org/gnunet/requests/MatchingRequestContainer.java
2014-01-20 21:40:51 UTC (rev 31962)
@@ -11,7 +11,14 @@
* Container for requests that are responded to with a matching request
identification
*/
public class MatchingRequestContainer<K, T extends RequestContainer.Request>
extends RequestContainer {
+ /**
+ * All queued requests.
+ */
private Map<K,T> requests = Maps.newHashMap();
+
+ /**
+ * Message queue to send to requests over.
+ */
private final MessageQueue mq;
public MatchingRequestContainer(MessageQueue mq) {
Modified: gnunet-java/src/main/java/org/gnunet/requests/RequestContainer.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/requests/RequestContainer.java
2014-01-20 21:21:15 UTC (rev 31961)
+++ gnunet-java/src/main/java/org/gnunet/requests/RequestContainer.java
2014-01-20 21:40:51 UTC (rev 31962)
@@ -4,14 +4,38 @@
import org.gnunet.mq.Envelope;
import org.gnunet.util.Cancelable;
+/**
+ * Container for requests to a service.
+ */
public abstract class RequestContainer {
+ /**
+ * Do we allow sending pending requests while
+ * other requests are still active (true), or do we send
+ * requests one-by-one (false)?
+ */
protected boolean overlap = true;
+ /**
+ * A request that can be put in a request container.
+ */
public abstract static class Request {
private boolean transmitting;
private boolean canceled;
private Cancelable cancelRequest;
+
+ /**
+ * Create an envelope for executing the request.
+ *
+ * @return Envelope to be sent to the service with the request message.
+ */
public abstract Envelope assembleRequest();
+
+ /**
+ * Implement cancellation logic for requests.
+ * Only called when the request has already been sent to the service.
+ *
+ * By default, canceling a request throws an exception.
+ */
public void cancel() {
throw new AssertionError("request of type " + this.getClass() + "
can not be canceled (not implemented)");
}
@@ -31,6 +55,13 @@
this.overlap = overlap;
}
+ /**
+ * Check if the given request is transmitting, that is, the request
+ * is waiting to be sent to the service.
+ *
+ * @param r request
+ * @return whether the request is still being transmitted
+ */
protected boolean isRequestTransmitting(Request r) {
return r.transmitting;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r31962 - in gnunet-java: . src/main/java/org/gnunet src/main/java/org/gnunet/gns src/main/java/org/gnunet/gns/messages src/main/java/org/gnunet/requests,
gnunet <=