stop
parent
3e1f59ec2b
commit
d0951f8644
|
@ -2,8 +2,8 @@ package meerkat.bulletinboard;
|
||||||
|
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
import meerkat.comm.CommunicationException;
|
import meerkat.comm.CommunicationException;
|
||||||
import meerkat.crypto.Digest;
|
import meerkat.destributed_key_generation.Digest;
|
||||||
import meerkat.crypto.concrete.SHA256Digest;
|
import meerkat.destributed_key_generation.concrete.SHA256Digest;
|
||||||
import meerkat.protobuf.BulletinBoardAPI.*;
|
import meerkat.protobuf.BulletinBoardAPI.*;
|
||||||
import meerkat.rest.Constants;
|
import meerkat.rest.Constants;
|
||||||
import meerkat.rest.ProtobufMessageBodyReader;
|
import meerkat.rest.ProtobufMessageBodyReader;
|
||||||
|
|
|
@ -2,8 +2,8 @@ package meerkat.bulletinboard;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import meerkat.comm.CommunicationException;
|
import meerkat.comm.CommunicationException;
|
||||||
import meerkat.crypto.Digest;
|
import meerkat.destributed_key_generation.Digest;
|
||||||
import meerkat.crypto.concrete.SHA256Digest;
|
import meerkat.destributed_key_generation.concrete.SHA256Digest;
|
||||||
import meerkat.protobuf.BulletinBoardAPI.*;
|
import meerkat.protobuf.BulletinBoardAPI.*;
|
||||||
import meerkat.protobuf.Voting;
|
import meerkat.protobuf.Voting;
|
||||||
import meerkat.protobuf.Voting.BulletinBoardClientParams;
|
import meerkat.protobuf.Voting.BulletinBoardClientParams;
|
||||||
|
|
|
@ -6,8 +6,8 @@ import meerkat.bulletinboard.callbacks.GetRedundancyFutureCallback;
|
||||||
import meerkat.bulletinboard.callbacks.PostMessageFutureCallback;
|
import meerkat.bulletinboard.callbacks.PostMessageFutureCallback;
|
||||||
import meerkat.bulletinboard.callbacks.ReadMessagesFutureCallback;
|
import meerkat.bulletinboard.callbacks.ReadMessagesFutureCallback;
|
||||||
import meerkat.comm.CommunicationException;
|
import meerkat.comm.CommunicationException;
|
||||||
import meerkat.crypto.Digest;
|
import meerkat.destributed_key_generation.Digest;
|
||||||
import meerkat.crypto.concrete.SHA256Digest;
|
import meerkat.destributed_key_generation.concrete.SHA256Digest;
|
||||||
import meerkat.protobuf.BulletinBoardAPI.*;
|
import meerkat.protobuf.BulletinBoardAPI.*;
|
||||||
import meerkat.protobuf.Voting;
|
import meerkat.protobuf.Voting;
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ import meerkat.comm.CommunicationException;
|
||||||
import meerkat.protobuf.BulletinBoardAPI.*;
|
import meerkat.protobuf.BulletinBoardAPI.*;
|
||||||
import meerkat.protobuf.Crypto.Signature;
|
import meerkat.protobuf.Crypto.Signature;
|
||||||
import meerkat.protobuf.Crypto.SignatureVerificationKey;
|
import meerkat.protobuf.Crypto.SignatureVerificationKey;
|
||||||
import meerkat.crypto.Digest;
|
import meerkat.destributed_key_generation.Digest;
|
||||||
import meerkat.crypto.concrete.SHA256Digest;
|
import meerkat.destributed_key_generation.concrete.SHA256Digest;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.util.Random;
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
|
|
||||||
import meerkat.comm.CommunicationException;
|
import meerkat.comm.CommunicationException;
|
||||||
import meerkat.crypto.concrete.ECDSASignature;
|
import meerkat.destributed_key_generation.concrete.ECDSASignature;
|
||||||
import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage;
|
import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage;
|
||||||
import meerkat.protobuf.BulletinBoardAPI.FilterType;
|
import meerkat.protobuf.BulletinBoardAPI.FilterType;
|
||||||
import meerkat.protobuf.BulletinBoardAPI.MessageFilter;
|
import meerkat.protobuf.BulletinBoardAPI.MessageFilter;
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
package meerkat.crypto;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Tzlil on 4/8/2016.
|
|
||||||
*/
|
|
||||||
public interface KeyGeneration<T> {
|
|
||||||
|
|
||||||
T generateKey(Random random);
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package meerkat.crypto;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Tzlil on 4/8/2016.
|
|
||||||
*/
|
|
||||||
public class SecretSharing {
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package meerkat.crypto.utilitis;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Tzlil on 3/17/2016.
|
|
||||||
*/
|
|
||||||
public interface Arithmetic<T> {
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param a
|
|
||||||
* @param b
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
T add(T a, T b);
|
|
||||||
T sub(T a, T b);
|
|
||||||
T mul(T a, T b);
|
|
||||||
T div(T a, T b);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,36 +1,59 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.communication;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.communication;
|
||||||
|
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
import meerkat.crypto.utilitis.Channel;
|
import meerkat.destributed_key_generation.utilitis.Channel;
|
||||||
import meerkat.protobuf.DKGMessages;
|
import meerkat.protobuf.DKGMessages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Tzlil on 2/14/2016.
|
* Created by Tzlil on 2/14/2016.
|
||||||
|
*
|
||||||
|
* an implementation of ReceiverCallback
|
||||||
*/
|
*/
|
||||||
public abstract class MailHandler implements Channel.ReceiverCallback{
|
public abstract class MailHandler implements Channel.ReceiverCallback{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fixed value for broadcasting
|
||||||
|
*/
|
||||||
public static final int BROADCAST = 0;
|
public static final int BROADCAST = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* message handler
|
||||||
|
*/
|
||||||
private MessageHandler messageHandler;
|
private MessageHandler messageHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
* @param messageHandler
|
||||||
|
*/
|
||||||
public MailHandler(MessageHandler messageHandler){
|
public MailHandler(MessageHandler messageHandler){
|
||||||
this.messageHandler = messageHandler;
|
this.messageHandler = messageHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* extract message from mail
|
||||||
|
* @param mail
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public abstract Message extractMessage(DKGMessages.Mail mail);
|
public abstract Message extractMessage(DKGMessages.Mail mail);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is this mail was received by broadcast channel
|
||||||
|
* @param mail
|
||||||
|
* @return mail user destination == BROADCAST
|
||||||
|
*/
|
||||||
public boolean isBroadcast(DKGMessages.Mail mail){
|
public boolean isBroadcast(DKGMessages.Mail mail){
|
||||||
return mail.getDestination() == BROADCAST;
|
return mail.getDestination() == BROADCAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void receiveMail(DKGMessages.Mail mail){
|
public void receiveMail(DKGMessages.Mail mail){
|
||||||
|
|
||||||
Message message = extractMessage(mail);
|
Message message = extractMessage(mail);
|
||||||
if (message == null)
|
if (message == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (mail.getType()) {
|
switch (mail.getType()) {
|
||||||
case SHARE:
|
case SHARE:
|
||||||
messageHandler.handleSecretMessage(mail.getSender(), isBroadcast(mail),message);
|
messageHandler.handleShareMessage(mail.getSender(), isBroadcast(mail),message);
|
||||||
break;
|
break;
|
||||||
case COMMITMENT:
|
case COMMITMENT:
|
||||||
messageHandler.handleCommitmentMessage(mail.getSender(), isBroadcast(mail),message);
|
messageHandler.handleCommitmentMessage(mail.getSender(), isBroadcast(mail),message);
|
|
@ -1,15 +1,39 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.communication;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.communication;
|
||||||
|
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Tzlil on 2/14/2016.
|
* Created by Tzlil on 2/14/2016.
|
||||||
|
* an interface for handling received messages
|
||||||
*/
|
*/
|
||||||
public interface MessageHandler {
|
public interface MessageHandler {
|
||||||
void handleSecretMessage(int sender, boolean isBroadcast, Message message);
|
/**
|
||||||
|
* handle share message
|
||||||
|
*/
|
||||||
|
void handleShareMessage(int sender, boolean isBroadcast, Message message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handle commitment message
|
||||||
|
*/
|
||||||
void handleCommitmentMessage(int sender, boolean isBroadcast, Message message);
|
void handleCommitmentMessage(int sender, boolean isBroadcast, Message message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handle complaint message
|
||||||
|
*/
|
||||||
void handleComplaintMessage(int sender, boolean isBroadcast, Message message);
|
void handleComplaintMessage(int sender, boolean isBroadcast, Message message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handle done message
|
||||||
|
*/
|
||||||
void handleDoneMessage(int sender, boolean isBroadcast, Message message);
|
void handleDoneMessage(int sender, boolean isBroadcast, Message message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handle answer message
|
||||||
|
*/
|
||||||
void handleAnswerMessage(int sender, boolean isBroadcast, Message message);
|
void handleAnswerMessage(int sender, boolean isBroadcast, Message message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handle abort message
|
||||||
|
*/
|
||||||
void handleAbortMessage(int sender, boolean isBroadcast, Message message);
|
void handleAbortMessage(int sender, boolean isBroadcast, Message message);
|
||||||
}
|
}
|
|
@ -1,17 +1,26 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.gjkr_secure_protocol;
|
||||||
|
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
import meerkat.crypto.concrete.distributed_key_generation.communication.MessageHandler;
|
import meerkat.destributed_key_generation.concrete.distributed_key_generation.communication.MessageHandler;
|
||||||
import meerkat.protobuf.DKGMessages;
|
import meerkat.protobuf.DKGMessages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Tzlil on 2/29/2016.
|
* Created by Tzlil on 2/29/2016.
|
||||||
|
* an extension of MailHandler matching gjkr protocl
|
||||||
*/
|
*/
|
||||||
public class MailHandler extends meerkat.crypto.concrete.distributed_key_generation.communication.MailHandler {
|
public class MailHandler extends meerkat.destributed_key_generation.concrete.distributed_key_generation.communication.MailHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* flag that indicants whether the
|
||||||
|
* current run achieved stage 4 of the protocol or not
|
||||||
|
*/
|
||||||
private boolean isStage4;
|
private boolean isStage4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
* @param messageHandler
|
||||||
|
*/
|
||||||
public MailHandler(MessageHandler messageHandler) {
|
public MailHandler(MessageHandler messageHandler) {
|
||||||
super(messageHandler);
|
super(messageHandler);
|
||||||
this.isStage4 = false;
|
this.isStage4 = false;
|
||||||
|
@ -52,10 +61,10 @@ public class MailHandler extends meerkat.crypto.concrete.distributed_key_generat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStage4() {
|
/**
|
||||||
return isStage4;
|
* setter
|
||||||
}
|
* @param stage4
|
||||||
|
*/
|
||||||
public void setStage4(boolean stage4) {
|
public void setStage4(boolean stage4) {
|
||||||
isStage4 = stage4;
|
isStage4 = stage4;
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.gjkr_secure_protocol;
|
||||||
|
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -13,7 +13,7 @@ import java.util.Set;
|
||||||
* contains all relevant information on specific party during
|
* contains all relevant information on specific party during
|
||||||
* the run of the safe protocol
|
* the run of the safe protocol
|
||||||
*/
|
*/
|
||||||
public class Party<T> extends meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.Party<T> {
|
public class Party<T> extends meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol.Party<T> {
|
||||||
public Polynomial.Point shareT;
|
public Polynomial.Point shareT;
|
||||||
public boolean ysDoneFlag;
|
public boolean ysDoneFlag;
|
||||||
public ArrayList<T> verifiableValues;
|
public ArrayList<T> verifiableValues;
|
|
@ -1,7 +1,7 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.gjkr_secure_protocol;
|
||||||
|
|
||||||
import meerkat.crypto.concrete.secret_shring.feldman_verifiable.VerifiableSecretSharing;
|
import meerkat.destributed_key_generation.concrete.secret_shring.feldman_verifiable.VerifiableSecretSharing;
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import meerkat.protobuf.DKGMessages;
|
import meerkat.protobuf.DKGMessages;
|
||||||
import org.factcenter.qilin.primitives.Group;
|
import org.factcenter.qilin.primitives.Group;
|
||||||
|
@ -17,7 +17,7 @@ import java.util.Set;
|
||||||
* TODO: comments
|
* TODO: comments
|
||||||
* TODO: put Channel (ChannelImpl) in constructor
|
* TODO: put Channel (ChannelImpl) in constructor
|
||||||
*/
|
*/
|
||||||
public class Protocol<T> extends meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.Protocol<T> {
|
public class Protocol<T> extends meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol.Protocol<T> {
|
||||||
|
|
||||||
private VerifiableSecretSharing<T> maskingShares;
|
private VerifiableSecretSharing<T> maskingShares;
|
||||||
private final T h;
|
private final T h;
|
|
@ -1,10 +1,10 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.gjkr_secure_protocol;
|
||||||
|
|
||||||
import meerkat.crypto.utilitis.Arithmetic;
|
import meerkat.destributed_key_generation.utilitis.Arithmetic;
|
||||||
import meerkat.crypto.utilitis.concrete.Fp;
|
import meerkat.destributed_key_generation.utilitis.concrete.Fp;
|
||||||
import meerkat.crypto.utilitis.Channel;
|
import meerkat.destributed_key_generation.utilitis.Channel;
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.SecretSharing;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.SecretSharing;
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
import meerkat.protobuf.DKGMessages;
|
import meerkat.protobuf.DKGMessages;
|
||||||
|
|
||||||
|
@ -13,25 +13,48 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Tzlil on 3/16/2016.
|
* Created by Tzlil on 3/16/2016.
|
||||||
|
*
|
||||||
|
* implementation of gjkr protocol user.
|
||||||
|
*
|
||||||
|
* this protocol extends joint feldman protocol by splitting the protocol to commitment stage (stages 1,2,3)
|
||||||
|
* and reviling stage (stage 4).
|
||||||
|
*
|
||||||
|
* as in joint feldman, each party in QUAL has his own share of the generated random key.
|
||||||
|
* this key can be recover by any subset of QUAL of size at least t + 1.
|
||||||
*/
|
*/
|
||||||
public class User<T> extends meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.User<T> {
|
public class User<T> extends meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol.User<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All parties participating in key generation.
|
||||||
|
* parties[id-1] has my info.
|
||||||
|
*/
|
||||||
protected Party<T>[] parties;
|
protected Party<T>[] parties;
|
||||||
protected final Protocol<T> sdkg;
|
|
||||||
private Arithmetic<BigInteger> arithmetic;
|
|
||||||
private boolean isStage4;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gjkr secure protocol object
|
||||||
|
*/
|
||||||
|
protected final Protocol<T> sdkg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* message handler
|
||||||
|
*/
|
||||||
|
private MessageHandler messageHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
* @param sdkg gjkr protocol object
|
||||||
|
* @param channel channel object
|
||||||
|
*/
|
||||||
public User(Protocol<T> sdkg, Channel channel) {
|
public User(Protocol<T> sdkg, Channel channel) {
|
||||||
super(sdkg, channel);
|
super(sdkg, channel);
|
||||||
this.sdkg = sdkg;
|
this.sdkg = sdkg;
|
||||||
this.parties = sdkg.getParties();
|
this.parties = sdkg.getParties();
|
||||||
this.arithmetic = new Fp(sdkg.getQ());
|
|
||||||
this.isStage4 = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerReceiverCallback(){
|
protected void registerReceiverCallback(){
|
||||||
this.mailHandler = new MailHandler(new MessageHandler());
|
this.messageHandler = new MessageHandler();
|
||||||
|
this.mailHandler = new MailHandler(messageHandler);
|
||||||
this.channel.registerReceiverCallback(mailHandler);
|
this.channel.registerReceiverCallback(mailHandler);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +107,7 @@ public class User<T> extends meerkat.crypto.concrete.distributed_key_generation.
|
||||||
try {
|
try {
|
||||||
parties[i - 1].wait();
|
parties[i - 1].wait();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
//do nothing
|
if (stop) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +125,7 @@ public class User<T> extends meerkat.crypto.concrete.distributed_key_generation.
|
||||||
try {
|
try {
|
||||||
parties[i - 1].wait();
|
parties[i - 1].wait();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
//do nothing
|
if (stop) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,13 +145,13 @@ public class User<T> extends meerkat.crypto.concrete.distributed_key_generation.
|
||||||
try {
|
try {
|
||||||
parties[i - 1].wait();
|
parties[i - 1].wait();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
//do nothing
|
if (stop) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Arithmetic<BigInteger> arithmetic = new Fp(sdkg.getQ());
|
||||||
// restore necessary information
|
// restore necessary information
|
||||||
for (int i = 0; i < n ; i++) {
|
for (int i = 0; i < n ; i++) {
|
||||||
if(parties[i].recoverSharesSet.isEmpty()){
|
if(parties[i].recoverSharesSet.isEmpty()){
|
||||||
|
@ -152,10 +175,10 @@ public class User<T> extends meerkat.crypto.concrete.distributed_key_generation.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* notifies mail handler that stage 4 was started
|
* notifies mail handler and message handler that stage 4 was started
|
||||||
*/
|
*/
|
||||||
protected void setStage4(){
|
protected void setStage4(){
|
||||||
this.isStage4 = true;
|
this.messageHandler.isStage4 = true;
|
||||||
((MailHandler)this.mailHandler).setStage4(true);
|
((MailHandler)this.mailHandler).setStage4(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,11 +186,13 @@ public class User<T> extends meerkat.crypto.concrete.distributed_key_generation.
|
||||||
protected void stage4() {
|
protected void stage4() {
|
||||||
setStage4();
|
setStage4();
|
||||||
resolveQualifyingPublicKey();
|
resolveQualifyingPublicKey();
|
||||||
|
if (stop) return;
|
||||||
super.stage4();
|
super.stage4();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MessageHandler extends meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.User.MessageHandler {
|
private class MessageHandler extends meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol.User.MessageHandler {
|
||||||
|
|
||||||
|
boolean isStage4;
|
||||||
/**
|
/**
|
||||||
* as in super, with extension to double secret message
|
* as in super, with extension to double secret message
|
||||||
*/
|
*/
|
||||||
|
@ -184,7 +209,7 @@ public class User<T> extends meerkat.crypto.concrete.distributed_key_generation.
|
||||||
* as in super, with extension to double secret message
|
* as in super, with extension to double secret message
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void handleSecretMessage(int sender, boolean isBroadcast, Message message) {
|
public void handleShareMessage(int sender, boolean isBroadcast, Message message) {
|
||||||
DKGMessages.DoubleShareMessage doubleSecretMessage = (DKGMessages.DoubleShareMessage)message;
|
DKGMessages.DoubleShareMessage doubleSecretMessage = (DKGMessages.DoubleShareMessage)message;
|
||||||
if (isValidSecretMessage(sender,isBroadcast,doubleSecretMessage)) {
|
if (isValidSecretMessage(sender,isBroadcast,doubleSecretMessage)) {
|
||||||
int i = doubleSecretMessage.getI();
|
int i = doubleSecretMessage.getI();
|
||||||
|
@ -234,10 +259,10 @@ public class User<T> extends meerkat.crypto.concrete.distributed_key_generation.
|
||||||
synchronized (parties[i - 1]) {
|
synchronized (parties[i - 1]) {
|
||||||
if (!isStage4) {
|
if (!isStage4) {
|
||||||
if (sdkg.isValidShare(secret, secretT, parties[j - 1].verifiableValues, i)) {
|
if (sdkg.isValidShare(secret, secretT, parties[j - 1].verifiableValues, i)) {
|
||||||
parties[i - 1].complaints[j - 1] = meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.Protocol.ComplaintState.NonDisqualified;
|
parties[i - 1].complaints[j - 1] = meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol.Protocol.ComplaintState.NonDisqualified;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
parties[i - 1].complaints[j - 1] = meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.Protocol.ComplaintState.Disqualified;
|
parties[i - 1].complaints[j - 1] = meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol.Protocol.ComplaintState.Disqualified;
|
||||||
}
|
}
|
||||||
if (j == id) {
|
if (j == id) {
|
||||||
parties[i - 1].share = secret;
|
parties[i - 1].share = secret;
|
|
@ -1,15 +1,20 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol;
|
||||||
|
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
import meerkat.crypto.concrete.distributed_key_generation.communication.MessageHandler;
|
import meerkat.destributed_key_generation.concrete.distributed_key_generation.communication.MessageHandler;
|
||||||
import meerkat.protobuf.DKGMessages;
|
import meerkat.protobuf.DKGMessages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Tzlil on 2/29/2016.
|
* Created by Tzlil on 2/29/2016.
|
||||||
|
* an extension of MailHandler matching joint feldman protocol
|
||||||
*/
|
*/
|
||||||
public class MailHandler extends meerkat.crypto.concrete.distributed_key_generation.communication.MailHandler {
|
public class MailHandler extends meerkat.destributed_key_generation.concrete.distributed_key_generation.communication.MailHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
* @param messageHandler
|
||||||
|
*/
|
||||||
public MailHandler(MessageHandler messageHandler) {
|
public MailHandler(MessageHandler messageHandler) {
|
||||||
super(messageHandler);
|
super(messageHandler);
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol;
|
||||||
|
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -19,6 +19,12 @@ public class Party<T> {
|
||||||
public Protocol.ComplaintState[] complaints;
|
public Protocol.ComplaintState[] complaints;
|
||||||
public boolean aborted;
|
public boolean aborted;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param id party identifier - 1 <= id <= n
|
||||||
|
* @param n number of parties in current run protocol
|
||||||
|
* @param t protocol's threshold
|
||||||
|
*/
|
||||||
public Party(int id, int n, int t) {
|
public Party(int id, int n, int t) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.share = null;
|
this.share = null;
|
|
@ -1,8 +1,8 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol;
|
||||||
|
|
||||||
import meerkat.crypto.utilitis.Channel;
|
import meerkat.destributed_key_generation.utilitis.Channel;
|
||||||
import meerkat.crypto.concrete.secret_shring.feldman_verifiable.VerifiableSecretSharing;
|
import meerkat.destributed_key_generation.concrete.secret_shring.feldman_verifiable.VerifiableSecretSharing;
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import meerkat.protobuf.DKGMessages;
|
import meerkat.protobuf.DKGMessages;
|
||||||
import org.factcenter.qilin.primitives.Group;
|
import org.factcenter.qilin.primitives.Group;
|
||||||
|
@ -57,7 +57,6 @@ public class Protocol<T> extends VerifiableSecretSharing<T> {
|
||||||
*/
|
*/
|
||||||
protected Channel channel;
|
protected Channel channel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encode/Decode group elements
|
* Encode/Decode group elements
|
||||||
*/
|
*/
|
||||||
|
@ -76,9 +75,10 @@ public class Protocol<T> extends VerifiableSecretSharing<T> {
|
||||||
* @param g a generator of cyclic group of order q.
|
* @param g a generator of cyclic group of order q.
|
||||||
* the generated group is a subgroup of the given group.
|
* the generated group is a subgroup of the given group.
|
||||||
* it must be chosen such that computing discrete logarithms is hard in this group.
|
* it must be chosen such that computing discrete logarithms is hard in this group.
|
||||||
|
* @param encoder Encode/Decode group elements (of type T) to/from byte array
|
||||||
*/
|
*/
|
||||||
public Protocol(int t, int n, BigInteger zi, Random random, BigInteger q, T g
|
public Protocol(int t, int n, BigInteger zi, Random random, BigInteger q, T g
|
||||||
, Group<T> group, int id, ByteEncoder<T> byteEncoder) {
|
, Group<T> group, int id, ByteEncoder<T> encoder) {
|
||||||
super(t, n, zi, random, q, g,group);
|
super(t, n, zi, random, q, g,group);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.parties = new Party[n];
|
this.parties = new Party[n];
|
||||||
|
@ -86,7 +86,7 @@ public class Protocol<T> extends VerifiableSecretSharing<T> {
|
||||||
this.parties[i - 1] = new Party(i,n,t);
|
this.parties[i - 1] = new Party(i,n,t);
|
||||||
}
|
}
|
||||||
this.parties[id - 1].share = getShare(id);
|
this.parties[id - 1].share = getShare(id);
|
||||||
this.encoder = byteEncoder;
|
this.encoder = encoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,7 +1,7 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol;
|
||||||
|
|
||||||
import meerkat.crypto.utilitis.Channel;
|
import meerkat.destributed_key_generation.utilitis.Channel;
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
import meerkat.protobuf.DKGMessages;
|
import meerkat.protobuf.DKGMessages;
|
||||||
|
@ -13,27 +13,91 @@ import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Tzlil on 3/14/2016.
|
* Created by Tzlil on 3/14/2016.
|
||||||
* TODO: Comments
|
*
|
||||||
* TODO: Replace polling with monitors/wait/notify (remember synchronization)
|
* implementation of joint feldman protocol user.
|
||||||
|
*
|
||||||
|
* according to the protocol, each user run feldman verifiable secret sharing
|
||||||
|
* as a dealer.
|
||||||
|
*
|
||||||
|
* by the end of run(), each party in QUAL has his own share of the generated random key.
|
||||||
|
* this key can be recover by any subset of QUAL of size at least t + 1.
|
||||||
*/
|
*/
|
||||||
public class User<T> implements Runnable{
|
public class User<T> implements Runnable{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* joint feldman protocol object
|
||||||
|
*/
|
||||||
protected final Protocol<T> dkg;
|
protected final Protocol<T> dkg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a generator of cyclic group of order q.
|
||||||
|
* the generated group is a subgroup of the given group.
|
||||||
|
* it must be chosen such that computing discrete logarithms is hard in this group.
|
||||||
|
*/
|
||||||
protected final T g;
|
protected final T g;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cyclic group contains g.
|
||||||
|
*/
|
||||||
protected final Group<T> group;
|
protected final Group<T> group;
|
||||||
protected final int n;
|
|
||||||
protected final int t;
|
/**
|
||||||
|
* user id
|
||||||
|
*/
|
||||||
protected final int id;
|
protected final int id;
|
||||||
protected meerkat.crypto.concrete.distributed_key_generation.communication.MailHandler mailHandler;
|
|
||||||
|
|
||||||
protected final Channel channel;
|
/**
|
||||||
|
* threshold
|
||||||
|
*/
|
||||||
|
protected final int t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* number of shares
|
||||||
|
*/
|
||||||
|
protected final int n;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mail handler registered to channel as ReceiverCallback
|
||||||
|
*/
|
||||||
|
protected meerkat.destributed_key_generation.concrete.distributed_key_generation.communication.MailHandler mailHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* channel object
|
||||||
|
*/
|
||||||
|
protected final Channel channel; //
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All parties participating in key generation.
|
||||||
|
* parties[id-1] has my info.
|
||||||
|
*/
|
||||||
protected final Party[] parties;
|
protected final Party[] parties;
|
||||||
protected Set<Integer> QUAL; // set of all non-disqualified parties
|
|
||||||
protected Polynomial.Point share; // final share of the secrete
|
|
||||||
protected ArrayList<T> commitments; // public verification values
|
|
||||||
protected T y; // final public value
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set of all non-disqualified parties
|
||||||
|
*/
|
||||||
|
protected Set<Integer> QUAL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* my own share of the generated random key.
|
||||||
|
*/
|
||||||
|
protected Polynomial.Point share;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* public verification values
|
||||||
|
*/
|
||||||
|
protected ArrayList<T> commitments;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* public value,
|
||||||
|
* y = g ^ key
|
||||||
|
*/
|
||||||
|
protected T y;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
* @param dkg joint feldman protocol object
|
||||||
|
* @param channel channel object
|
||||||
|
*/
|
||||||
public User(Protocol<T> dkg, Channel channel) {
|
public User(Protocol<T> dkg, Channel channel) {
|
||||||
this.dkg = dkg;
|
this.dkg = dkg;
|
||||||
|
|
||||||
|
@ -74,20 +138,23 @@ public class User<T> implements Runnable{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wait for all shares and commitments will arrive from other parties
|
||||||
|
*/
|
||||||
protected void waitUntilStageOneCompleted(){
|
protected void waitUntilStageOneCompleted(){
|
||||||
// all parties send their share or aborted
|
// wait for parties' share
|
||||||
for (int i = 0 ; i < n ; i++){
|
for (int i = 0 ; i < n ; i++){
|
||||||
synchronized (parties[i]) {
|
synchronized (parties[i]) {
|
||||||
while (parties[i].share == null && !parties[i].aborted) {
|
while (parties[i].share == null && !parties[i].aborted) {
|
||||||
try {
|
try {
|
||||||
parties[i].wait();
|
parties[i].wait();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
//do nothing
|
if (stop) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// all parties broadcast their commitments or aborted
|
// wait for parties' commitments
|
||||||
for (int i = 0 ; i < n ; i++){
|
for (int i = 0 ; i < n ; i++){
|
||||||
for (int k = 0 ; k <= t ; k++) {
|
for (int k = 0 ; k <= t ; k++) {
|
||||||
synchronized (parties[i]) {
|
synchronized (parties[i]) {
|
||||||
|
@ -95,7 +162,7 @@ public class User<T> implements Runnable{
|
||||||
try {
|
try {
|
||||||
parties[i].wait();
|
parties[i].wait();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
//do nothing
|
if (stop) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,15 +184,17 @@ public class User<T> implements Runnable{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wait until all other parties done complaining by receiving done message
|
||||||
|
*/
|
||||||
protected void waitUntilStageTwoCompleted(){
|
protected void waitUntilStageTwoCompleted(){
|
||||||
// all parties done or aborted
|
|
||||||
for (int i = 0 ; i < n ; i++){
|
for (int i = 0 ; i < n ; i++){
|
||||||
synchronized (parties[i]) {
|
synchronized (parties[i]) {
|
||||||
while (!parties[i].doneFlag && !parties[i].aborted) {
|
while (!parties[i].doneFlag && !parties[i].aborted) {
|
||||||
try {
|
try {
|
||||||
parties[i].wait();
|
parties[i].wait();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
//do nothing
|
if (stop) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +219,7 @@ public class User<T> implements Runnable{
|
||||||
try {
|
try {
|
||||||
parties[i].wait();
|
parties[i].wait();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
//do nothing
|
if (stop) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,18 +242,38 @@ public class User<T> implements Runnable{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
this.runThread = Thread.currentThread();
|
||||||
stage1();
|
stage1();
|
||||||
waitUntilStageOneCompleted();
|
waitUntilStageOneCompleted();
|
||||||
|
if (stop) return;
|
||||||
stage2();
|
stage2();
|
||||||
waitUntilStageTwoCompleted();
|
waitUntilStageTwoCompleted();
|
||||||
|
if (stop) return;
|
||||||
stage3();
|
stage3();
|
||||||
|
if (stop) return;
|
||||||
stage4();
|
stage4();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* current thread in the main loop
|
||||||
|
*/
|
||||||
|
protected Thread runThread;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* flag indicates if there was request to stop the current run of the protocol
|
||||||
|
*/
|
||||||
|
protected boolean stop = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request the current run loop to exit gracefully
|
* Request the current run loop to exit gracefully
|
||||||
*/
|
*/
|
||||||
public void stop() {
|
public void stop() {
|
||||||
|
try {
|
||||||
|
stop = true;
|
||||||
|
runThread.interrupt();
|
||||||
|
}catch (Exception e){
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,12 +349,19 @@ public class User<T> implements Runnable{
|
||||||
return QUAL;
|
return QUAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getter
|
||||||
|
* @return channel
|
||||||
|
*/
|
||||||
|
public Channel getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
public class MessageHandler implements meerkat.crypto.concrete.distributed_key_generation.communication.MessageHandler{
|
/**
|
||||||
|
* an implementation of MessageHandler
|
||||||
|
*/
|
||||||
|
public class MessageHandler implements meerkat.destributed_key_generation.concrete.distributed_key_generation.communication.MessageHandler{
|
||||||
|
|
||||||
public MessageHandler(){
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* commitment message is valid if:
|
* commitment message is valid if:
|
||||||
* 1. it was received in broadcast chanel
|
* 1. it was received in broadcast chanel
|
||||||
|
@ -314,7 +410,7 @@ public class User<T> implements Runnable{
|
||||||
* saves the secret
|
* saves the secret
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void handleSecretMessage(int sender, boolean isBroadcast, Message message) {
|
public void handleShareMessage(int sender, boolean isBroadcast, Message message) {
|
||||||
DKGMessages.ShareMessage secretMessage = (DKGMessages.ShareMessage) message;
|
DKGMessages.ShareMessage secretMessage = (DKGMessages.ShareMessage) message;
|
||||||
if(isValidSecretMessage(sender,isBroadcast,secretMessage)) {
|
if(isValidSecretMessage(sender,isBroadcast,secretMessage)) {
|
||||||
int i = secretMessage.getI();
|
int i = secretMessage.getI();
|
|
@ -1,7 +1,7 @@
|
||||||
package meerkat.crypto.concrete.secret_shring.feldman_verifiable;
|
package meerkat.destributed_key_generation.concrete.secret_shring.feldman_verifiable;
|
||||||
|
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.SecretSharing;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.SecretSharing;
|
||||||
import org.factcenter.qilin.primitives.Group;
|
import org.factcenter.qilin.primitives.Group;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -17,12 +17,22 @@ import java.util.Random;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class VerifiableSecretSharing<T> extends SecretSharing {
|
public class VerifiableSecretSharing<T> extends SecretSharing {
|
||||||
|
/**
|
||||||
|
* cyclic group contains g.
|
||||||
|
*/
|
||||||
protected final Group<T> group;
|
protected final Group<T> group;
|
||||||
protected final T g; // public generator of group
|
/**
|
||||||
|
* a generator of cyclic group of order q.
|
||||||
|
* the generated group is a subgroup of the given group.
|
||||||
|
* it must be chosen such that computing discrete logarithms is hard in this group.
|
||||||
|
*/
|
||||||
|
protected final T g;
|
||||||
|
/**
|
||||||
|
* commitments to polynomial coefficients.
|
||||||
|
* commitments[k] = g ^ coefficients[k] (group operation)
|
||||||
|
*/
|
||||||
protected final ArrayList<T> commitmentsArrayList;
|
protected final ArrayList<T> commitmentsArrayList;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
* @param q a large prime.
|
* @param q a large prime.
|
|
@ -1,6 +1,6 @@
|
||||||
package meerkat.crypto.concrete.secret_shring.shamir;
|
package meerkat.destributed_key_generation.concrete.secret_shring.shamir;
|
||||||
|
|
||||||
import meerkat.crypto.utilitis.Arithmetic;
|
import meerkat.destributed_key_generation.utilitis.Arithmetic;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package meerkat.crypto.concrete.secret_shring.shamir;
|
package meerkat.destributed_key_generation.concrete.secret_shring.shamir;
|
||||||
|
|
||||||
import meerkat.crypto.utilitis.Arithmetic;
|
import meerkat.destributed_key_generation.utilitis.Arithmetic;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -100,7 +100,7 @@ public class Polynomial implements Comparable<Polynomial> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param other
|
* @param other
|
||||||
* @return new meerkat.crypto.concrete.secret_shring.shamir.Polynomial of degree max(this degree,other degree) s.t for all x
|
* @return new meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial of degree max(this degree,other degree) s.t for all x
|
||||||
* new.evaluate(x) = this.evaluate(x) + other.evaluate(x)
|
* new.evaluate(x) = this.evaluate(x) + other.evaluate(x)
|
||||||
*/
|
*/
|
||||||
public Polynomial add(Polynomial other){
|
public Polynomial add(Polynomial other){
|
|
@ -1,7 +1,7 @@
|
||||||
package meerkat.crypto.concrete.secret_shring.shamir;
|
package meerkat.destributed_key_generation.concrete.secret_shring.shamir;
|
||||||
|
|
||||||
import meerkat.crypto.utilitis.Arithmetic;
|
import meerkat.destributed_key_generation.utilitis.Arithmetic;
|
||||||
import meerkat.crypto.utilitis.concrete.Fp;
|
import meerkat.destributed_key_generation.utilitis.concrete.Fp;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -11,9 +11,21 @@ import java.util.Random;
|
||||||
* an implementation of Shamire's secret sharing scheme
|
* an implementation of Shamire's secret sharing scheme
|
||||||
*/
|
*/
|
||||||
public class SecretSharing{
|
public class SecretSharing{
|
||||||
|
/**
|
||||||
|
* threshold
|
||||||
|
*/
|
||||||
protected final int t;
|
protected final int t;
|
||||||
|
/**
|
||||||
|
* number of shares
|
||||||
|
*/
|
||||||
protected final int n;
|
protected final int n;
|
||||||
|
/**
|
||||||
|
* a large prime
|
||||||
|
*/
|
||||||
protected final BigInteger q;
|
protected final BigInteger q;
|
||||||
|
/**
|
||||||
|
* random polynomial of degree s.t polynomial.evaluate(0) = secret
|
||||||
|
*/
|
||||||
protected final Polynomial polynomial;
|
protected final Polynomial polynomial;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -0,0 +1,38 @@
|
||||||
|
package meerkat.destributed_key_generation.utilitis;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Tzlil on 3/17/2016.
|
||||||
|
* defines the properties of the traditional operations : add,sub,mul,div
|
||||||
|
* between two objects of type T
|
||||||
|
*/
|
||||||
|
public interface Arithmetic<T> {
|
||||||
|
/**
|
||||||
|
* addition
|
||||||
|
* @param a
|
||||||
|
* @param b
|
||||||
|
* @return a + b
|
||||||
|
*/
|
||||||
|
T add(T a, T b);
|
||||||
|
/**
|
||||||
|
* subtraction
|
||||||
|
* @param a
|
||||||
|
* @param b
|
||||||
|
* @return a - b
|
||||||
|
*/
|
||||||
|
T sub(T a, T b);
|
||||||
|
/**
|
||||||
|
* multiplication
|
||||||
|
* @param a
|
||||||
|
* @param b
|
||||||
|
* @return a * b
|
||||||
|
*/
|
||||||
|
T mul(T a, T b);
|
||||||
|
/**
|
||||||
|
* division
|
||||||
|
* @param a
|
||||||
|
* @param b
|
||||||
|
* @return a / b
|
||||||
|
*/
|
||||||
|
T div(T a, T b);
|
||||||
|
|
||||||
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package meerkat.crypto.utilitis;
|
package meerkat.destributed_key_generation.utilitis;
|
||||||
|
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
import meerkat.protobuf.DKGMessages;
|
import meerkat.protobuf.DKGMessages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A generic commmunication channel that supports point-to-point and broadcast operation
|
* A generic communication channel that supports point-to-point and broadcast operation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface Channel {
|
public interface Channel {
|
||||||
|
@ -12,8 +12,20 @@ public interface Channel {
|
||||||
public void receiveMail(DKGMessages.Mail mail);
|
public void receiveMail(DKGMessages.Mail mail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sends a private message
|
||||||
|
* @param destUser destination user's identifier
|
||||||
|
* @param type message type
|
||||||
|
* @param msg message
|
||||||
|
*/
|
||||||
public void sendMessage(int destUser, DKGMessages.Mail.Type type, Message msg);
|
public void sendMessage(int destUser, DKGMessages.Mail.Type type, Message msg);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* broadcasts a message to all parties (including the sender)
|
||||||
|
* @param type message type
|
||||||
|
* @param msg message
|
||||||
|
*/
|
||||||
public void broadcastMessage(DKGMessages.Mail.Type type, Message msg);
|
public void broadcastMessage(DKGMessages.Mail.Type type, Message msg);
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,17 +1,22 @@
|
||||||
package meerkat.crypto.utilitis.concrete;
|
package meerkat.destributed_key_generation.utilitis.concrete;
|
||||||
|
|
||||||
import meerkat.crypto.utilitis.Arithmetic;
|
import meerkat.destributed_key_generation.utilitis.Arithmetic;
|
||||||
import org.factcenter.qilin.primitives.concrete.Zpstar;
|
import org.factcenter.qilin.primitives.concrete.Zpstar;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Tzlil on 3/17/2016.
|
* Created by Tzlil on 3/17/2016.
|
||||||
|
* an implementation of Arithmetic<BigInteger> over prime fields: integers modulo p
|
||||||
*/
|
*/
|
||||||
public class Fp implements Arithmetic<BigInteger> {
|
public class Fp implements Arithmetic<BigInteger> {
|
||||||
public final BigInteger p;
|
public final BigInteger p;
|
||||||
private final Zpstar zp;
|
private final Zpstar zp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
* @param p prime
|
||||||
|
*/
|
||||||
public Fp(BigInteger p) {
|
public Fp(BigInteger p) {
|
||||||
this.p = p;
|
this.p = p;
|
||||||
this.zp = new Zpstar(p);
|
this.zp = new Zpstar(p);
|
|
@ -1,7 +1,6 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.gjkr_secure_protocol;
|
||||||
|
|
||||||
import meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol.*;
|
import meerkat.destributed_key_generation.utilitis.Channel;
|
||||||
import meerkat.crypto.utilitis.Channel;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
|
@ -1,15 +1,15 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.gjkr_secure_protocol;
|
||||||
|
|
||||||
import Utils.ChannelImpl;
|
import meerkat.destributed_key_generation.utilitis.ChannelImpl;
|
||||||
import meerkat.crypto.utilitis.Arithmetic;
|
import meerkat.destributed_key_generation.utilitis.Arithmetic;
|
||||||
import meerkat.crypto.utilitis.concrete.Fp;
|
import meerkat.destributed_key_generation.utilitis.concrete.Fp;
|
||||||
import meerkat.crypto.utilitis.Channel;
|
import meerkat.destributed_key_generation.utilitis.Channel;
|
||||||
import meerkat.crypto.concrete.secret_shring.feldman_verifiable.VerifiableSecretSharing;
|
import meerkat.destributed_key_generation.concrete.secret_shring.feldman_verifiable.VerifiableSecretSharing;
|
||||||
import meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.DKGMaliciousUser;
|
import meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol.DKGMaliciousUser;
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.SecretSharing;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.SecretSharing;
|
||||||
import Utils.BigIntegerByteEncoder;
|
import meerkat.destributed_key_generation.utilitis.BigIntegerByteEncoder;
|
||||||
import Utils.GenerateRandomPrime;
|
import meerkat.destributed_key_generation.utilitis.GenerateRandomPrime;
|
||||||
import org.factcenter.qilin.primitives.Group;
|
import org.factcenter.qilin.primitives.Group;
|
||||||
import org.factcenter.qilin.primitives.concrete.Zpstar;
|
import org.factcenter.qilin.primitives.concrete.Zpstar;
|
||||||
import org.factcenter.qilin.util.ByteEncoder;
|
import org.factcenter.qilin.util.ByteEncoder;
|
||||||
|
@ -27,25 +27,16 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
public class SDKGTest {
|
public class SDKGTest {
|
||||||
|
|
||||||
int tests = 1;
|
int tests = 10;
|
||||||
BigInteger p = GenerateRandomPrime.SafePrime100Bits;
|
BigInteger p = GenerateRandomPrime.SafePrime100Bits;
|
||||||
BigInteger q = p.subtract(BigInteger.ONE).divide(BigInteger.valueOf(2));
|
BigInteger q = p.subtract(BigInteger.ONE).divide(BigInteger.valueOf(2));
|
||||||
Group<BigInteger> group = new Zpstar(p);
|
Group<BigInteger> group = new Zpstar(p);
|
||||||
Arithmetic<BigInteger> arithmetic = new Fp(q);
|
Arithmetic<BigInteger> arithmetic = new Fp(q);
|
||||||
int t = 9;
|
int t = 9;
|
||||||
int n = 20;
|
int n = 20;
|
||||||
Testable[] testables;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void settings(){
|
|
||||||
testables = new Testable[tests];
|
|
||||||
for (int i = 0; i < tests; i++){
|
|
||||||
testables[i] = new Testable(new Random());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void oneTest(int test) throws Exception {
|
public void oneTest(Testable testable) throws Exception {
|
||||||
Testable testable = testables[test];
|
|
||||||
for (int i = 0; i < testable.threads.length ; i++){
|
for (int i = 0; i < testable.threads.length ; i++){
|
||||||
testable.threads[i].start();
|
testable.threads[i].start();
|
||||||
}
|
}
|
||||||
|
@ -83,13 +74,23 @@ public class SDKGTest {
|
||||||
assert (calculatedSecret.equals(testable.secret));
|
assert (calculatedSecret.equals(testable.secret));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void stopReceivers(Testable testable){
|
||||||
public void test() throws Exception {
|
ChannelImpl channel;
|
||||||
for (int i = 0; i < tests; i++){
|
for (int i = 0 ; i < testable.sdkgs.length ; i++){
|
||||||
oneTest(i);
|
channel = (ChannelImpl)testable.sdkgs[i].getChannel();
|
||||||
|
channel.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() throws Exception {
|
||||||
|
Testable testable;
|
||||||
|
for (int i = 0; i < tests; i++) {
|
||||||
|
testable = new Testable(new Random());
|
||||||
|
oneTest(testable);
|
||||||
|
stopReceivers(testable);
|
||||||
|
}
|
||||||
|
}
|
||||||
class Testable{
|
class Testable{
|
||||||
Set<Integer> valids;
|
Set<Integer> valids;
|
||||||
Set<Integer> QUAL;
|
Set<Integer> QUAL;
|
|
@ -1,6 +1,6 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.gjkr_secure_protocol;
|
||||||
|
|
||||||
import meerkat.crypto.utilitis.Channel;
|
import meerkat.destributed_key_generation.utilitis.Channel;
|
||||||
import meerkat.protobuf.DKGMessages;
|
import meerkat.protobuf.DKGMessages;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,6 +1,6 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol;
|
||||||
|
|
||||||
import meerkat.crypto.utilitis.Channel;
|
import meerkat.destributed_key_generation.utilitis.Channel;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.*;
|
import java.util.*;
|
|
@ -1,15 +1,14 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol;
|
||||||
|
|
||||||
import Utils.ChannelImpl;
|
import meerkat.destributed_key_generation.utilitis.ChannelImpl;
|
||||||
import meerkat.crypto.utilitis.Arithmetic;
|
import meerkat.destributed_key_generation.utilitis.Arithmetic;
|
||||||
import meerkat.crypto.utilitis.concrete.Fp;
|
import meerkat.destributed_key_generation.utilitis.concrete.Fp;
|
||||||
import meerkat.crypto.utilitis.Channel;
|
import meerkat.destributed_key_generation.utilitis.Channel;
|
||||||
import meerkat.crypto.concrete.secret_shring.feldman_verifiable.VerifiableSecretSharing;
|
import meerkat.destributed_key_generation.concrete.secret_shring.feldman_verifiable.VerifiableSecretSharing;
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.SecretSharing;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.SecretSharing;
|
||||||
import Utils.BigIntegerByteEncoder;
|
import meerkat.destributed_key_generation.utilitis.BigIntegerByteEncoder;
|
||||||
import Utils.GenerateRandomPrime;
|
import meerkat.destributed_key_generation.utilitis.GenerateRandomPrime;
|
||||||
import meerkat.protobuf.Crypto;
|
|
||||||
import org.factcenter.qilin.primitives.Group;
|
import org.factcenter.qilin.primitives.Group;
|
||||||
import org.factcenter.qilin.primitives.concrete.Zpstar;
|
import org.factcenter.qilin.primitives.concrete.Zpstar;
|
||||||
import org.factcenter.qilin.util.ByteEncoder;
|
import org.factcenter.qilin.util.ByteEncoder;
|
||||||
|
@ -27,7 +26,7 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
public class DKGTest {
|
public class DKGTest {
|
||||||
|
|
||||||
int tests = 1;
|
int tests = 10;
|
||||||
BigInteger p = GenerateRandomPrime.SafePrime100Bits;
|
BigInteger p = GenerateRandomPrime.SafePrime100Bits;
|
||||||
BigInteger q = p.subtract(BigInteger.ONE).divide(BigInteger.valueOf(2));
|
BigInteger q = p.subtract(BigInteger.ONE).divide(BigInteger.valueOf(2));
|
||||||
Group<BigInteger> group = new Zpstar(p);
|
Group<BigInteger> group = new Zpstar(p);
|
||||||
|
@ -35,18 +34,7 @@ public class DKGTest {
|
||||||
int t = 9;
|
int t = 9;
|
||||||
int n = 20;
|
int n = 20;
|
||||||
|
|
||||||
Testable[] testables;
|
public void oneTest(Testable testable) throws Exception {
|
||||||
|
|
||||||
@Before
|
|
||||||
public void settings(){
|
|
||||||
testables = new Testable[tests];
|
|
||||||
for (int i = 0; i < tests; i++){
|
|
||||||
testables[i] = new Testable(new Random());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void oneTest(int test) throws Exception {
|
|
||||||
Testable testable = testables[test];
|
|
||||||
for (int i = 0; i < testable.threads.length ; i++){
|
for (int i = 0; i < testable.threads.length ; i++){
|
||||||
testable.threads[i].start();
|
testable.threads[i].start();
|
||||||
}
|
}
|
||||||
|
@ -84,10 +72,21 @@ public class DKGTest {
|
||||||
assert (calculatedSecret.equals(testable.secret));
|
assert (calculatedSecret.equals(testable.secret));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void stopReceivers(Testable testable){
|
||||||
|
ChannelImpl channel;
|
||||||
|
for (int i = 0 ; i < testable.dkgs.length ; i++){
|
||||||
|
channel = (ChannelImpl)testable.dkgs[i].getChannel();
|
||||||
|
channel.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
|
Testable testable;
|
||||||
for (int i = 0; i < tests; i++){
|
for (int i = 0; i < tests; i++){
|
||||||
oneTest(i);
|
testable = new Testable(new Random());
|
||||||
|
oneTest(testable);
|
||||||
|
stopReceivers(testable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,13 +116,13 @@ public class DKGTest {
|
||||||
BigInteger s;
|
BigInteger s;
|
||||||
Protocol<BigInteger> dkg;
|
Protocol<BigInteger> dkg;
|
||||||
this.secret = BigInteger.ZERO;
|
this.secret = BigInteger.ZERO;
|
||||||
Channel channel;
|
ChannelImpl channel;
|
||||||
ByteEncoder<BigInteger> byteEncoder = new BigIntegerByteEncoder();
|
ByteEncoder<BigInteger> byteEncoder = new BigIntegerByteEncoder();
|
||||||
while (!ids.isEmpty()) {
|
while (!ids.isEmpty()) {
|
||||||
id = ids.remove(random.nextInt(ids.size()));
|
id = ids.remove(random.nextInt(ids.size()));
|
||||||
channel = new ChannelImpl(id,n);
|
channel = new ChannelImpl(id,n);
|
||||||
s = randomIntModQ(random);
|
s = randomIntModQ(random);
|
||||||
dkg = new meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.Protocol<BigInteger>(t, n, s, random, q, g, group, id,byteEncoder);
|
dkg = new meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol.Protocol<BigInteger>(t, n, s, random, q, g, group, id,byteEncoder);
|
||||||
dkgs[id - 1] = randomDKGUser(id,channel,dkg,random);
|
dkgs[id - 1] = randomDKGUser(id,channel,dkg,random);
|
||||||
threads[id - 1] = new Thread(dkgs[id - 1]);
|
threads[id - 1] = new Thread(dkgs[id - 1]);
|
||||||
if(QUAL.contains(id)){
|
if(QUAL.contains(id)){
|
|
@ -1,6 +1,6 @@
|
||||||
package meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol;
|
package meerkat.destributed_key_generation.concrete.distributed_key_generation.joint_feldman_protocol;
|
||||||
|
|
||||||
import meerkat.crypto.utilitis.Channel;
|
import meerkat.destributed_key_generation.utilitis.Channel;
|
||||||
import meerkat.protobuf.DKGMessages;
|
import meerkat.protobuf.DKGMessages;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,6 +1,6 @@
|
||||||
package meerkat.crypto.concrete.secret_shring.feldman_verifiable;
|
package meerkat.destributed_key_generation.concrete.secret_shring.feldman_verifiable;
|
||||||
|
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
import org.factcenter.qilin.primitives.Group;
|
import org.factcenter.qilin.primitives.Group;
|
||||||
import org.factcenter.qilin.primitives.concrete.Zpstar;
|
import org.factcenter.qilin.primitives.concrete.Zpstar;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
|
@ -1,7 +1,7 @@
|
||||||
package meerkat.crypto.concrete.secret_shring.shamir.PolynomialTests;
|
package meerkat.destributed_key_generation.concrete.secret_shring.shamir.PolynomialTests;
|
||||||
import Utils.GenerateRandomPolynomial;
|
import meerkat.destributed_key_generation.utilitis.GenerateRandomPolynomial;
|
||||||
import Utils.Z;
|
import meerkat.destributed_key_generation.utilitis.Z;
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package meerkat.crypto.concrete.secret_shring.shamir.PolynomialTests;
|
package meerkat.destributed_key_generation.concrete.secret_shring.shamir.PolynomialTests;
|
||||||
|
|
||||||
import meerkat.crypto.utilitis.Arithmetic;
|
import meerkat.destributed_key_generation.utilitis.Arithmetic;
|
||||||
import meerkat.crypto.utilitis.concrete.Fp;
|
import meerkat.destributed_key_generation.utilitis.concrete.Fp;
|
||||||
import Utils.GenerateRandomPolynomial;
|
import meerkat.destributed_key_generation.utilitis.GenerateRandomPolynomial;
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
import Utils.GenerateRandomPrime;
|
import meerkat.destributed_key_generation.utilitis.GenerateRandomPrime;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package meerkat.crypto.concrete.secret_shring.shamir.PolynomialTests;
|
package meerkat.destributed_key_generation.concrete.secret_shring.shamir.PolynomialTests;
|
||||||
|
|
||||||
import Utils.GenerateRandomPolynomial;
|
import meerkat.destributed_key_generation.utilitis.GenerateRandomPolynomial;
|
||||||
import Utils.Z;
|
import meerkat.destributed_key_generation.utilitis.Z;
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package meerkat.crypto.concrete.secret_shring.shamir.PolynomialTests;
|
package meerkat.destributed_key_generation.concrete.secret_shring.shamir.PolynomialTests;
|
||||||
|
|
||||||
import Utils.GenerateRandomPolynomial;
|
import meerkat.destributed_key_generation.utilitis.GenerateRandomPolynomial;
|
||||||
import Utils.Z;
|
import meerkat.destributed_key_generation.utilitis.Z;
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package meerkat.crypto.concrete.secret_shring.shamir;
|
package meerkat.destributed_key_generation.concrete.secret_shring.shamir;
|
||||||
|
|
||||||
import meerkat.crypto.utilitis.concrete.Fp;
|
import meerkat.destributed_key_generation.utilitis.concrete.Fp;
|
||||||
import Utils.GenerateRandomPrime;
|
import meerkat.destributed_key_generation.utilitis.GenerateRandomPrime;
|
||||||
import org.factcenter.qilin.primitives.CyclicGroup;
|
import org.factcenter.qilin.primitives.CyclicGroup;
|
||||||
import org.factcenter.qilin.primitives.concrete.Zn;
|
import org.factcenter.qilin.primitives.concrete.Zn;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
|
@ -1,4 +1,4 @@
|
||||||
package Utils;
|
package meerkat.destributed_key_generation.utilitis;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package Utils;
|
package meerkat.destributed_key_generation.utilitis;
|
||||||
|
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
import meerkat.crypto.utilitis.Channel;
|
|
||||||
import meerkat.protobuf.DKGMessages;
|
import meerkat.protobuf.DKGMessages;
|
||||||
|
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
@ -76,13 +75,17 @@ public class ChannelImpl implements Channel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void stop(){
|
||||||
public void registerReceiverCallback(final ReceiverCallback callback) {
|
|
||||||
try{
|
try{
|
||||||
receiverThread.interrupt();
|
receiverThread.interrupt();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerReceiverCallback(final ReceiverCallback callback) {
|
||||||
|
stop();
|
||||||
receiverThread = new Thread(new Runnable() {
|
receiverThread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
|
@ -1,8 +1,7 @@
|
||||||
package Utils;
|
package meerkat.destributed_key_generation.utilitis;
|
||||||
|
|
||||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
import meerkat.destributed_key_generation.concrete.secret_shring.shamir.Polynomial;
|
||||||
import meerkat.crypto.utilitis.Arithmetic;
|
import meerkat.destributed_key_generation.utilitis.concrete.Fp;
|
||||||
import meerkat.crypto.utilitis.concrete.Fp;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
|
@ -1,6 +1,4 @@
|
||||||
package Utils;
|
package meerkat.destributed_key_generation.utilitis;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
|
@ -1,6 +1,4 @@
|
||||||
package Utils;
|
package meerkat.destributed_key_generation.utilitis;
|
||||||
|
|
||||||
import meerkat.crypto.utilitis.Arithmetic;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package meerkat.crypto;
|
package meerkat.destributed_key_generation;
|
||||||
|
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package meerkat.crypto;
|
package meerkat.destributed_key_generation;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
|
@ -1,4 +1,4 @@
|
||||||
package meerkat.crypto;
|
package meerkat.destributed_key_generation;
|
||||||
|
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
|
@ -1,4 +1,4 @@
|
||||||
package meerkat.crypto.concrete;
|
package meerkat.destributed_key_generation.concrete;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
|
@ -1,4 +1,4 @@
|
||||||
package meerkat.crypto.concrete;
|
package meerkat.destributed_key_generation.concrete;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -16,7 +16,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
|
|
||||||
import meerkat.crypto.DigitalSignature;
|
import meerkat.destributed_key_generation.DigitalSignature;
|
||||||
import meerkat.protobuf.Crypto.Signature;
|
import meerkat.protobuf.Crypto.Signature;
|
||||||
|
|
||||||
import javax.security.auth.callback.Callback;
|
import javax.security.auth.callback.Callback;
|
|
@ -1,9 +1,9 @@
|
||||||
package meerkat.crypto.concrete;
|
package meerkat.destributed_key_generation.concrete;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
import meerkat.crypto.Encryption;
|
import meerkat.destributed_key_generation.Encryption;
|
||||||
import meerkat.protobuf.ConcreteCrypto;
|
import meerkat.protobuf.ConcreteCrypto;
|
||||||
import meerkat.protobuf.Crypto;
|
import meerkat.protobuf.Crypto;
|
||||||
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
|
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
|
|
@ -1,4 +1,4 @@
|
||||||
package meerkat.crypto.concrete;
|
package meerkat.destributed_key_generation.concrete;
|
||||||
|
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -8,7 +8,7 @@ import java.security.Provider;
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that performs required crypto setup
|
* A class that performs required destributed_key_generation setup
|
||||||
*/
|
*/
|
||||||
public class GlobalCryptoSetup {
|
public class GlobalCryptoSetup {
|
||||||
final static Logger logger = LoggerFactory.getLogger(GlobalCryptoSetup.class);
|
final static Logger logger = LoggerFactory.getLogger(GlobalCryptoSetup.class);
|
|
@ -1,8 +1,8 @@
|
||||||
package meerkat.crypto.concrete;
|
package meerkat.destributed_key_generation.concrete;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
import meerkat.crypto.Digest;
|
import meerkat.destributed_key_generation.Digest;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package meerkat.crypto.mixnet;
|
package meerkat.destributed_key_generation.mixnet;
|
||||||
|
|
||||||
import meerkat.protobuf.Crypto;
|
import meerkat.protobuf.Crypto;
|
||||||
import meerkat.protobuf.Mixing;
|
import meerkat.protobuf.Mixing;
|
|
@ -1,4 +1,4 @@
|
||||||
package meerkat.crypto.mixnet;
|
package meerkat.destributed_key_generation.mixnet;
|
||||||
|
|
||||||
import meerkat.protobuf.Crypto;
|
import meerkat.protobuf.Crypto;
|
||||||
import meerkat.protobuf.Mixing;
|
import meerkat.protobuf.Mixing;
|
|
@ -1,4 +1,4 @@
|
||||||
package meerkat.crypto.mixnet;
|
package meerkat.destributed_key_generation.mixnet;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import static meerkat.protobuf.Voting.*;
|
import static meerkat.protobuf.Voting.*;
|
|
@ -1,4 +1,4 @@
|
||||||
package meerkat.crypto.mixnet;
|
package meerkat.destributed_key_generation.mixnet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by talm on 25/10/15.
|
* Created by talm on 25/10/15.
|
|
@ -1,4 +1,4 @@
|
||||||
package meerkat.crypto.mixnet;
|
package meerkat.destributed_key_generation.mixnet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by talm on 25/10/15.
|
* Created by talm on 25/10/15.
|
|
@ -1,9 +1,8 @@
|
||||||
package meerkat.crypto.concrete;
|
package meerkat.destributed_key_generation.concrete;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
|
|
||||||
import meerkat.crypto.concrete.ECDSASignature;
|
|
||||||
import meerkat.protobuf.Crypto;
|
import meerkat.protobuf.Crypto;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package meerkat.crypto.concrete;
|
package meerkat.destributed_key_generation.concrete;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
import meerkat.protobuf.Crypto;
|
import meerkat.protobuf.Crypto;
|
||||||
import meerkat.crypto.concrete.ECDSASignature;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package meerkat.crypto.concrete;
|
package meerkat.destributed_key_generation.concrete;
|
||||||
|
|
||||||
import meerkat.protobuf.ConcreteCrypto;
|
import meerkat.protobuf.ConcreteCrypto;
|
||||||
import meerkat.protobuf.Crypto;
|
import meerkat.protobuf.Crypto;
|
|
@ -1,4 +1,4 @@
|
||||||
package meerkat.crypto.concrete;
|
package meerkat.destributed_key_generation.concrete;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.GeneratedMessage;
|
import com.google.protobuf.GeneratedMessage;
|
Loading…
Reference in New Issue