switch secret with share
parent
5d564c834c
commit
3e1f59ec2b
|
@ -1,108 +0,0 @@
|
|||
package meerkat.crypto.concrete.distributed_key_generation.Communication;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import meerkat.crypto.utilitis.Channel;
|
||||
import meerkat.protobuf.DKGMessages;
|
||||
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
|
||||
/**
|
||||
* Created by Tzlil on 2/14/2016.
|
||||
*/
|
||||
// TODO: Change nane to network
|
||||
|
||||
public class ChannelImpl implements Channel {
|
||||
|
||||
public static int BROADCAST = 0;
|
||||
private static ChannelImpl[] channels = null;
|
||||
|
||||
protected final Queue<DKGMessages.Mail> mailbox;
|
||||
protected final int id;
|
||||
protected final int n;
|
||||
protected Thread receiverThread;
|
||||
|
||||
|
||||
public ChannelImpl(int id, int n) {
|
||||
if (channels == null){
|
||||
channels = new ChannelImpl[n];
|
||||
}
|
||||
this.mailbox = new ArrayBlockingQueue<DKGMessages.Mail>( n * n * n);
|
||||
this.id = id;
|
||||
this.n = n;
|
||||
channels[id - 1] = this;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(int destUser, DKGMessages.Mail.Type type, Message msg) {
|
||||
if(destUser < 1 || destUser > n)
|
||||
return;
|
||||
ChannelImpl channel = channels[destUser - 1];
|
||||
if (channel == null)
|
||||
return;
|
||||
DKGMessages.Mail mail = DKGMessages.Mail.newBuilder()
|
||||
.setSender(id)
|
||||
.setDestination(destUser)
|
||||
.setIsPrivate(true)
|
||||
.setType(type)
|
||||
.setMessage(msg.toByteString())
|
||||
.build();
|
||||
synchronized (channel.mailbox) {
|
||||
channel.mailbox.add(mail);
|
||||
channel.mailbox.notify();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastMessage(DKGMessages.Mail.Type type,Message msg) {
|
||||
ChannelImpl channel;
|
||||
DKGMessages.Mail mail = DKGMessages.Mail.newBuilder()
|
||||
.setSender(id)
|
||||
.setDestination(BROADCAST)
|
||||
.setIsPrivate(false)
|
||||
.setType(type)
|
||||
.setMessage(msg.toByteString())
|
||||
.build();
|
||||
for (int i = 0 ; i < n ; i++){
|
||||
channel = channels[i];
|
||||
synchronized (channel.mailbox) {
|
||||
channel.mailbox.add(mail);
|
||||
channel.mailbox.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerReceiverCallback(final ReceiverCallback callback) {
|
||||
try{
|
||||
receiverThread.interrupt();
|
||||
}catch (Exception e){
|
||||
//do nothing
|
||||
}
|
||||
receiverThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true){
|
||||
try {
|
||||
synchronized (mailbox) {
|
||||
while (!mailbox.isEmpty()) {
|
||||
callback.receiveMail(mailbox.remove());
|
||||
}
|
||||
mailbox.wait();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
receiverThread.start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package meerkat.crypto.concrete.distributed_key_generation.Communication;
|
||||
package meerkat.crypto.concrete.distributed_key_generation.communication;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import meerkat.crypto.utilitis.Channel;
|
||||
|
@ -9,13 +9,19 @@ import meerkat.protobuf.DKGMessages;
|
|||
*/
|
||||
public abstract class MailHandler implements Channel.ReceiverCallback{
|
||||
|
||||
public static final int BROADCAST = 0;
|
||||
private MessageHandler messageHandler;
|
||||
|
||||
public MailHandler(MessageHandler messageHandler){
|
||||
this.messageHandler = messageHandler;
|
||||
}
|
||||
|
||||
public abstract Message extractMessage(DKGMessages.Mail mail);
|
||||
|
||||
public boolean isBroadcast(DKGMessages.Mail mail){
|
||||
return mail.getDestination() == BROADCAST;
|
||||
}
|
||||
|
||||
public void receiveMail(DKGMessages.Mail mail){
|
||||
|
||||
Message message = extractMessage(mail);
|
||||
|
@ -24,28 +30,22 @@ public abstract class MailHandler implements Channel.ReceiverCallback{
|
|||
|
||||
switch (mail.getType()) {
|
||||
case SHARE:
|
||||
messageHandler.handleSecretMessage(mail.getSender(), mail.getDestination() == ChannelImpl.BROADCAST
|
||||
, message);
|
||||
messageHandler.handleSecretMessage(mail.getSender(), isBroadcast(mail),message);
|
||||
break;
|
||||
case COMMITMENT:
|
||||
messageHandler.handleCommitmentMessage(mail.getSender(), mail.getDestination() == ChannelImpl.BROADCAST
|
||||
, message);
|
||||
messageHandler.handleCommitmentMessage(mail.getSender(), isBroadcast(mail),message);
|
||||
break;
|
||||
case DONE:
|
||||
messageHandler.handleDoneMessage(mail.getSender(), mail.getDestination() == ChannelImpl.BROADCAST
|
||||
, message);
|
||||
messageHandler.handleDoneMessage(mail.getSender(), isBroadcast(mail),message);
|
||||
break;
|
||||
case COMPLAINT:
|
||||
messageHandler.handleComplaintMessage(mail.getSender(), mail.getDestination() == ChannelImpl.BROADCAST
|
||||
, message);
|
||||
messageHandler.handleComplaintMessage(mail.getSender(), isBroadcast(mail),message);
|
||||
break;
|
||||
case ANSWER:
|
||||
messageHandler.handleAnswerMessage(mail.getSender(), mail.getDestination() == ChannelImpl.BROADCAST
|
||||
, message);
|
||||
messageHandler.handleAnswerMessage(mail.getSender(), isBroadcast(mail),message);
|
||||
break;
|
||||
case ABORT:
|
||||
messageHandler.handleAbortMessage(mail.getSender(), mail.getDestination() == ChannelImpl.BROADCAST
|
||||
, message);
|
||||
messageHandler.handleAbortMessage(mail.getSender(), isBroadcast(mail),message);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package meerkat.crypto.concrete.distributed_key_generation.Communication;
|
||||
package meerkat.crypto.concrete.distributed_key_generation.communication;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol;
|
||||
|
||||
import Communication.MailHandler;
|
||||
import Communication.MessageHandler;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.google.protobuf.Message;
|
||||
import meerkat.crypto.concrete.distributed_key_generation.communication.MessageHandler;
|
||||
import meerkat.protobuf.DKGMessages;
|
||||
|
||||
/**
|
||||
* Created by Tzlil on 2/29/2016.
|
||||
*/
|
||||
public class MailHandler extends Communication.MailHandler {
|
||||
public class MailHandler extends meerkat.crypto.concrete.distributed_key_generation.communication.MailHandler {
|
||||
|
||||
private boolean isStage4;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol;
|
||||
|
||||
import meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.DistributedKeyGenerationParty;
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -14,7 +13,7 @@ import java.util.Set;
|
|||
* contains all relevant information on specific party during
|
||||
* the run of the safe protocol
|
||||
*/
|
||||
public class Party<T> extends DistributedKeyGenerationParty<T> {
|
||||
public class Party<T> extends meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.Party<T> {
|
||||
public Polynomial.Point shareT;
|
||||
public boolean ysDoneFlag;
|
||||
public ArrayList<T> verifiableValues;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol;
|
||||
|
||||
import meerkat.crypto.concrete.secret_shring.feldman_verifiable.VerifiableSecretSharing;
|
||||
import meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.Protocol;
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
||||
import com.google.protobuf.ByteString;
|
||||
import meerkat.protobuf.DKGMessages;
|
||||
|
@ -137,8 +136,8 @@ public class Protocol<T> extends meerkat.crypto.concrete.distributed_key_generat
|
|||
DKGMessages.DoubleShareMessage doubleShareMessage = DKGMessages.DoubleShareMessage.newBuilder()
|
||||
.setI(i)
|
||||
.setJ(j)
|
||||
.setSecret(ByteString.copyFrom(share.y.toByteArray()))
|
||||
.setSecretT(ByteString.copyFrom(shareT.y.toByteArray()))
|
||||
.setShare(ByteString.copyFrom(share.y.toByteArray()))
|
||||
.setShareT(ByteString.copyFrom(shareT.y.toByteArray()))
|
||||
.build();
|
||||
return doubleShareMessage;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol;
|
|||
import meerkat.crypto.utilitis.Arithmetic;
|
||||
import meerkat.crypto.utilitis.concrete.Fp;
|
||||
import meerkat.crypto.utilitis.Channel;
|
||||
import meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.User;
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.SecretSharing;
|
||||
import com.google.protobuf.Message;
|
||||
|
@ -22,7 +21,7 @@ public class User<T> extends meerkat.crypto.concrete.distributed_key_generation.
|
|||
private Arithmetic<BigInteger> arithmetic;
|
||||
private boolean isStage4;
|
||||
|
||||
public User(Protocol sdkg, Channel channel) {
|
||||
public User(Protocol<T> sdkg, Channel channel) {
|
||||
super(sdkg, channel);
|
||||
this.sdkg = sdkg;
|
||||
this.parties = sdkg.getParties();
|
||||
|
@ -176,7 +175,7 @@ public class User<T> extends meerkat.crypto.concrete.distributed_key_generation.
|
|||
DKGMessages.ShareMessage secretMessage = DKGMessages.ShareMessage.newBuilder()
|
||||
.setI(doubleSecretMessage.getI())
|
||||
.setJ(doubleSecretMessage.getJ())
|
||||
.setSecret(doubleSecretMessage.getSecret())
|
||||
.setShare(doubleSecretMessage.getShare())
|
||||
.build();
|
||||
return super.isValidSecretMessage(sender,isBroadcast,secretMessage);
|
||||
}
|
||||
|
@ -190,8 +189,8 @@ public class User<T> extends meerkat.crypto.concrete.distributed_key_generation.
|
|||
if (isValidSecretMessage(sender,isBroadcast,doubleSecretMessage)) {
|
||||
int i = doubleSecretMessage.getI();
|
||||
synchronized (parties[i - 1]) {
|
||||
parties[i - 1].share = extractShare(id, doubleSecretMessage.getSecret());
|
||||
parties[i - 1].shareT = extractShare(id, doubleSecretMessage.getSecretT());
|
||||
parties[i - 1].share = extractShare(id, doubleSecretMessage.getShare());
|
||||
parties[i - 1].shareT = extractShare(id, doubleSecretMessage.getShareT());
|
||||
parties[i - 1].notify();
|
||||
}
|
||||
}
|
||||
|
@ -209,7 +208,7 @@ public class User<T> extends meerkat.crypto.concrete.distributed_key_generation.
|
|||
DKGMessages.ShareMessage secretMessage = DKGMessages.ShareMessage.newBuilder()
|
||||
.setI(doubleSecretMessage.getI())
|
||||
.setJ(doubleSecretMessage.getJ())
|
||||
.setSecret(doubleSecretMessage.getSecret())
|
||||
.setShare(doubleSecretMessage.getShare())
|
||||
.build();
|
||||
return super.isValidAnswerMessage(sender, isBroadcast, secretMessage);
|
||||
}else{
|
||||
|
@ -230,8 +229,8 @@ public class User<T> extends meerkat.crypto.concrete.distributed_key_generation.
|
|||
if(isValidAnswerMessage(sender,isBroadcast,doubleSecretMessage)) {
|
||||
int i = doubleSecretMessage.getI();
|
||||
int j = doubleSecretMessage.getJ();
|
||||
Polynomial.Point secret = extractShare(j, doubleSecretMessage.getSecret());
|
||||
Polynomial.Point secretT = extractShare(j, doubleSecretMessage.getSecretT());
|
||||
Polynomial.Point secret = extractShare(j, doubleSecretMessage.getShare());
|
||||
Polynomial.Point secretT = extractShare(j, doubleSecretMessage.getShareT());
|
||||
synchronized (parties[i - 1]) {
|
||||
if (!isStage4) {
|
||||
if (sdkg.isValidShare(secret, secretT, parties[j - 1].verifiableValues, i)) {
|
||||
|
@ -310,8 +309,8 @@ public class User<T> extends meerkat.crypto.concrete.distributed_key_generation.
|
|||
if (isValidComplaintMessage(sender,isBroadcast,ysComplaintMessage)) {
|
||||
int i = ysComplaintMessage.getI();
|
||||
int j = ysComplaintMessage.getJ();
|
||||
Polynomial.Point secret = extractShare(i,ysComplaintMessage.getSecret());
|
||||
Polynomial.Point secretT = extractShare(i,ysComplaintMessage.getSecretT());
|
||||
Polynomial.Point secret = extractShare(i,ysComplaintMessage.getShare());
|
||||
Polynomial.Point secretT = extractShare(i,ysComplaintMessage.getShareT());
|
||||
if (sdkg.isValidShare(secret, secretT, parties[i - 1].verifiableValues, j)
|
||||
&& !dkg.isValidShare(secret,parties[i - 1].commitments, j)) {
|
||||
synchronized (parties[i - 1]) {
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol;
|
||||
|
||||
import Communication.MailHandler;
|
||||
import Communication.MessageHandler;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.google.protobuf.Message;
|
||||
import meerkat.crypto.concrete.distributed_key_generation.communication.MessageHandler;
|
||||
import meerkat.protobuf.DKGMessages;
|
||||
|
||||
/**
|
||||
* Created by Tzlil on 2/29/2016.
|
||||
*/
|
||||
public class MailHandler extends Communication.MailHandler {
|
||||
public class MailHandler extends meerkat.crypto.concrete.distributed_key_generation.communication.MailHandler {
|
||||
|
||||
public MailHandler(MessageHandler messageHandler) {
|
||||
super(messageHandler);
|
||||
|
|
|
@ -11,21 +11,20 @@ import java.util.Arrays;
|
|||
* contains all relevant information on specific party during
|
||||
* the run of Joint Feldamn protocol
|
||||
*/
|
||||
// TODO: comments for every field.
|
||||
public class Party<T> {
|
||||
public final int id;
|
||||
public Polynomial.Point share;
|
||||
public ArrayList<T> commitments;
|
||||
public boolean doneFlag;
|
||||
public DistributedKeyGeneration.ComplaintState[] complaints;
|
||||
public Protocol.ComplaintState[] complaints;
|
||||
public boolean aborted;
|
||||
|
||||
public Party(int id, int n, int t) {
|
||||
this.id = id;
|
||||
this.share = null;
|
||||
this.doneFlag = false;
|
||||
this.complaints = new DistributedKeyGeneration.ComplaintState[n];
|
||||
Arrays.fill(this.complaints, DistributedKeyGeneration.ComplaintState.OK);
|
||||
this.complaints = new Protocol.ComplaintState[n];
|
||||
Arrays.fill(this.complaints, Protocol.ComplaintState.OK);
|
||||
this.commitments = new ArrayList<T>(t + 1);
|
||||
for (int i = 0; i <= t ; i++){
|
||||
commitments.add(null);
|
||||
|
|
|
@ -146,7 +146,7 @@ public class Protocol<T> extends VerifiableSecretSharing<T> {
|
|||
DKGMessages.ShareMessage.newBuilder()
|
||||
.setI(id)
|
||||
.setJ(j)
|
||||
.setSecret(secret)
|
||||
.setShare(secret)
|
||||
.build());
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ public class Protocol<T> extends VerifiableSecretSharing<T> {
|
|||
channel.broadcastMessage(DKGMessages.Mail.Type.ANSWER, DKGMessages.ShareMessage.newBuilder()
|
||||
.setI(id)
|
||||
.setJ(j)
|
||||
.setSecret(ByteString.copyFrom(getShare(j).y.toByteArray()))
|
||||
.setShare(ByteString.copyFrom(getShare(j).y.toByteArray()))
|
||||
.build());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol;
|
||||
|
||||
import meerkat.crypto.utilitis.Channel;
|
||||
import Communication.MailHandler;
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.Message;
|
||||
|
@ -11,7 +10,6 @@ import org.factcenter.qilin.primitives.Group;
|
|||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.DistributedKeyGeneration.ComplaintState;
|
||||
|
||||
/**
|
||||
* Created by Tzlil on 3/14/2016.
|
||||
|
@ -20,14 +18,14 @@ import meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol
|
|||
*/
|
||||
public class User<T> implements Runnable{
|
||||
|
||||
protected final DistributedKeyGeneration<T> dkg;
|
||||
protected final Protocol<T> dkg;
|
||||
|
||||
protected final T g;
|
||||
protected final Group<T> group;
|
||||
protected final int n;
|
||||
protected final int t;
|
||||
protected final int id;
|
||||
protected MailHandler mailHandler;
|
||||
protected meerkat.crypto.concrete.distributed_key_generation.communication.MailHandler mailHandler;
|
||||
|
||||
protected final Channel channel;
|
||||
protected final Party[] parties;
|
||||
|
@ -36,7 +34,7 @@ public class User<T> implements Runnable{
|
|||
protected ArrayList<T> commitments; // public verification values
|
||||
protected T y; // final public value
|
||||
|
||||
public User(DistributedKeyGeneration<T> dkg, Channel channel) {
|
||||
public User(Protocol<T> dkg, Channel channel) {
|
||||
this.dkg = dkg;
|
||||
|
||||
this.g = dkg.getGenerator();
|
||||
|
@ -61,7 +59,7 @@ public class User<T> implements Runnable{
|
|||
* create MailHandler and register it as ReceiverCallback
|
||||
*/
|
||||
protected void registerReceiverCallback(){
|
||||
this.mailHandler = new DistributedKeyGenerationMailHandler(new MessageHandler());
|
||||
this.mailHandler = new MailHandler(new MessageHandler());
|
||||
channel.registerReceiverCallback(mailHandler);
|
||||
}
|
||||
|
||||
|
@ -148,7 +146,7 @@ public class User<T> implements Runnable{
|
|||
for (int i = 0; i < n; i++){
|
||||
for (int j = 0; j < n; j++){
|
||||
synchronized (parties[i]) {
|
||||
while (parties[i].complaints[j].equals(ComplaintState.Waiting) && !parties[i].aborted) {
|
||||
while (parties[i].complaints[j].equals(Protocol.ComplaintState.Waiting) && !parties[i].aborted) {
|
||||
try {
|
||||
parties[i].wait();
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -263,7 +261,7 @@ public class User<T> implements Runnable{
|
|||
}
|
||||
|
||||
|
||||
public class MessageHandler implements Communication.MessageHandler{
|
||||
public class MessageHandler implements meerkat.crypto.concrete.distributed_key_generation.communication.MessageHandler{
|
||||
|
||||
public MessageHandler(){
|
||||
|
||||
|
@ -320,7 +318,7 @@ public class User<T> implements Runnable{
|
|||
DKGMessages.ShareMessage secretMessage = (DKGMessages.ShareMessage) message;
|
||||
if(isValidSecretMessage(sender,isBroadcast,secretMessage)) {
|
||||
int i = secretMessage.getI();
|
||||
Polynomial.Point secret = extractShare(id,secretMessage.getSecret());
|
||||
Polynomial.Point secret = extractShare(id,secretMessage.getShare());
|
||||
synchronized (parties[i -1]) {
|
||||
parties[i - 1].share = secret;
|
||||
parties[i - 1].notify();
|
||||
|
@ -358,7 +356,7 @@ public class User<T> implements Runnable{
|
|||
protected boolean isValidComplaintMessage(int sender, boolean isBroadcast, DKGMessages.IDMessage complaintMessage){
|
||||
int i = sender;
|
||||
int j = complaintMessage.getId();
|
||||
return isBroadcast && parties[i - 1].complaints[j - 1].equals( ComplaintState.OK);
|
||||
return isBroadcast && parties[i - 1].complaints[j - 1].equals( Protocol.ComplaintState.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -371,7 +369,7 @@ public class User<T> implements Runnable{
|
|||
int i = sender;
|
||||
int j = complaintMessage.getId();
|
||||
synchronized (parties[j - 1]) {
|
||||
parties[j - 1].complaints[i - 1] = ComplaintState.Waiting;
|
||||
parties[j - 1].complaints[i - 1] = Protocol.ComplaintState.Waiting;
|
||||
parties[j - 1].notify();
|
||||
}
|
||||
}
|
||||
|
@ -390,7 +388,7 @@ public class User<T> implements Runnable{
|
|||
if(sender != i || !isBroadcast)
|
||||
return false;
|
||||
else
|
||||
return j >= 1 && j <= n && parties[i - 1].complaints[j - 1].equals(ComplaintState.Waiting);
|
||||
return j >= 1 && j <= n && parties[i - 1].complaints[j - 1].equals(Protocol.ComplaintState.Waiting);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -404,12 +402,12 @@ public class User<T> implements Runnable{
|
|||
if(isValidAnswerMessage(sender,isBroadcast,secretMessage)) {
|
||||
int i = secretMessage.getI();
|
||||
int j = secretMessage.getJ();
|
||||
Polynomial.Point secret = extractShare(j,secretMessage.getSecret());
|
||||
Polynomial.Point secret = extractShare(j,secretMessage.getShare());
|
||||
synchronized (parties[i - 1]) {
|
||||
if (dkg.isValidShare(secret, parties[i - 1].commitments, j)) {
|
||||
parties[i - 1].complaints[j - 1] = ComplaintState.NonDisqualified;
|
||||
parties[i - 1].complaints[j - 1] = Protocol.ComplaintState.NonDisqualified;
|
||||
} else {
|
||||
parties[i - 1].complaints[j - 1] = ComplaintState.Disqualified;
|
||||
parties[i - 1].complaints[j - 1] = Protocol.ComplaintState.Disqualified;
|
||||
}
|
||||
if (j == id) {
|
||||
parties[i - 1].share = secret;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package meerkat.crypto.concrete.secret_shring.feldman_verifiable;
|
||||
|
||||
import meerkat.crypto.concrete.secret_shring.ShamirSecretSharing.Polynomial;
|
||||
import meerkat.crypto.concrete.secret_shring.ShamirSecretSharing.SecretSharing;
|
||||
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.SecretSharing;
|
||||
import org.factcenter.qilin.primitives.Group;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package Utils;
|
||||
|
||||
import Arithmetics.Arithmetic;
|
||||
import Arithmetics.Fp;
|
||||
import ShamirSecretSharing.Polynomial;
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
||||
import meerkat.crypto.utilitis.Arithmetic;
|
||||
import meerkat.crypto.utilitis.concrete.Fp;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Random;
|
||||
|
@ -12,7 +12,7 @@ import java.util.Random;
|
|||
*/
|
||||
public class GenerateRandomPolynomial {
|
||||
|
||||
public static Polynomial generateRandomPolynomial(int degree, int bits, Random random,Arithmetic<BigInteger> arithmetic) {
|
||||
public static Polynomial generateRandomPolynomial(int degree, int bits, Random random, Arithmetic<BigInteger> arithmetic) {
|
||||
BigInteger[] coefficients = new BigInteger[degree + 1];
|
||||
|
||||
for (int i = 0 ; i <= degree; i++ ){
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol;
|
||||
|
||||
import meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol.*;
|
||||
import meerkat.crypto.utilitis.Channel;
|
||||
import meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.DistributedKeyGeneration;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Random;
|
||||
|
@ -10,11 +10,11 @@ import java.util.Set;
|
|||
/**
|
||||
* Created by Tzlil on 3/29/2016.
|
||||
*/
|
||||
public class SDKGMaliciousUserImpl extends SecureDistributedKeyGenerationUser {
|
||||
public class SDKGMaliciousUserImpl<T> extends User<T> {
|
||||
|
||||
private final DistributedKeyGeneration maliciousSDKG;
|
||||
private final Protocol<T> maliciousSDKG;
|
||||
private final Set<Integer> falls;
|
||||
public SDKGMaliciousUserImpl(SecureDistributedKeyGeneration sdkg, SecureDistributedKeyGeneration maliciousSDKG
|
||||
public SDKGMaliciousUserImpl(Protocol<T> sdkg, Protocol<T> maliciousSDKG
|
||||
, Channel channel, Set<Integer> falls) {
|
||||
super(sdkg, channel);
|
||||
this.falls = falls;
|
||||
|
@ -22,10 +22,10 @@ public class SDKGMaliciousUserImpl extends SecureDistributedKeyGenerationUser {
|
|||
maliciousSDKG.setParties(parties);
|
||||
}
|
||||
|
||||
public static SecureDistributedKeyGeneration generateMaliciousSDKG(SecureDistributedKeyGeneration sdkg,Channel channel,Random random){
|
||||
public static<T> Protocol<T> generateMaliciousSDKG(Protocol<T> sdkg,Channel channel,Random random){
|
||||
BigInteger q = sdkg.getQ();
|
||||
BigInteger zi = new BigInteger(q.bitLength(), random).mod(q);
|
||||
SecureDistributedKeyGeneration malicious = new SecureDistributedKeyGeneration(sdkg.getT(),sdkg.getN(),zi,random,sdkg.getQ()
|
||||
Protocol<T> malicious = new Protocol<T>(sdkg.getT(),sdkg.getN(),zi,random,sdkg.getQ()
|
||||
,sdkg.getGenerator(),sdkg.getH(),sdkg.getGroup(),sdkg.getId(),sdkg.getEncoder());
|
||||
malicious.setChannel(channel);
|
||||
return malicious;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package meerkat.crypto.concrete.distributed_key_generation.gjkr_secure_protocol;
|
||||
|
||||
import Utils.ChannelImpl;
|
||||
import meerkat.crypto.utilitis.Arithmetic;
|
||||
import meerkat.crypto.utilitis.concrete.Fp;
|
||||
import meerkat.crypto.utilitis.Channel;
|
||||
import Communication.ChannelImpl;
|
||||
import meerkat.crypto.concrete.secret_shring.feldman_verifiable.VerifiableSecretSharing;
|
||||
import meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol.DKGMaliciousUser;
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
||||
|
@ -95,14 +95,14 @@ public class SDKGTest {
|
|||
Set<Integer> QUAL;
|
||||
Set<Integer> aborted;
|
||||
Set<Integer> malicious;
|
||||
SecureDistributedKeyGenerationUser[] sdkgs;
|
||||
User<BigInteger>[] sdkgs;
|
||||
Thread[] threads;
|
||||
BigInteger g;
|
||||
BigInteger h;
|
||||
BigInteger secret;
|
||||
|
||||
public Testable(Random random) {
|
||||
this.sdkgs = new SecureDistributedKeyGenerationUser[n];
|
||||
this.sdkgs = new User[n];
|
||||
this.valids = new HashSet<Integer>();
|
||||
this.QUAL = new HashSet<Integer>();
|
||||
this.aborted = new HashSet<Integer>();
|
||||
|
@ -117,14 +117,14 @@ public class SDKGTest {
|
|||
int id;
|
||||
BigInteger s;
|
||||
Channel channel;
|
||||
SecureDistributedKeyGeneration sdkg;
|
||||
Protocol<BigInteger> sdkg;
|
||||
this.secret = BigInteger.ZERO;
|
||||
ByteEncoder<BigInteger> encoder = new BigIntegerByteEncoder();
|
||||
while (!ids.isEmpty()) {
|
||||
id = ids.remove(random.nextInt(ids.size()));
|
||||
s = randomIntModQ(random);
|
||||
channel = new ChannelImpl(id,n);
|
||||
sdkg = new SecureDistributedKeyGeneration(t, n, s, random, q, g , h, group, id,encoder);
|
||||
sdkg = new Protocol<BigInteger>(t, n, s, random, q, g , h, group, id,encoder);
|
||||
sdkgs[id - 1] = randomSDKGUser(id,channel,sdkg,random);
|
||||
threads[id - 1] = new Thread(sdkgs[id - 1]);
|
||||
if(QUAL.contains(id)){
|
||||
|
@ -134,18 +134,18 @@ public class SDKGTest {
|
|||
|
||||
}
|
||||
|
||||
public SecureDistributedKeyGenerationUser randomSDKGUser(int id, Channel channel, SecureDistributedKeyGeneration sdkg, Random random){
|
||||
public User<BigInteger> randomSDKGUser(int id, Channel channel, Protocol<BigInteger> sdkg, Random random){
|
||||
if (QUAL.size() <= t) {
|
||||
valids.add(id);
|
||||
QUAL.add(id);
|
||||
return new SecureDistributedKeyGenerationUser(sdkg,channel);
|
||||
return new User<BigInteger>(sdkg,channel);
|
||||
}else{
|
||||
int type = random.nextInt(3);
|
||||
switch (type){
|
||||
case 0:// regular
|
||||
valids.add(id);
|
||||
QUAL.add(id);
|
||||
return new SecureDistributedKeyGenerationUser(sdkg,channel);
|
||||
return new User<BigInteger>(sdkg,channel);
|
||||
case 1:// abort
|
||||
int abortStage = random.nextInt(3) + 1; // 1 or 2 or 3
|
||||
aborted.add(id);
|
||||
|
@ -156,7 +156,7 @@ public class SDKGTest {
|
|||
case 2:// malicious
|
||||
malicious.add(id);
|
||||
Set<Integer> falls = DKGMaliciousUser.selectFallsRandomly(valids,random);
|
||||
SecureDistributedKeyGeneration maliciousSDKG = SDKGMaliciousUserImpl.generateMaliciousSDKG(sdkg,channel,random);
|
||||
Protocol<BigInteger> maliciousSDKG = SDKGMaliciousUserImpl.generateMaliciousSDKG(sdkg,channel,random);
|
||||
return new SDKGMaliciousUserImpl(sdkg,maliciousSDKG,channel,falls);
|
||||
default:
|
||||
return null;
|
||||
|
|
|
@ -6,11 +6,11 @@ import meerkat.protobuf.DKGMessages;
|
|||
/**
|
||||
* Created by Tzlil on 3/14/2016.
|
||||
*/
|
||||
public class SDKGUserImplAbort extends SecureDistributedKeyGenerationUser {
|
||||
public class SDKGUserImplAbort<T> extends User<T> {
|
||||
|
||||
final int abortStage;
|
||||
int stage;
|
||||
public SDKGUserImplAbort(SecureDistributedKeyGeneration sdkg, Channel channel, int abortStage) {
|
||||
public SDKGUserImplAbort(Protocol<T> sdkg, Channel channel, int abortStage) {
|
||||
super(sdkg, channel);
|
||||
this.abortStage = abortStage;// 1 - 4
|
||||
this.stage = 1;
|
||||
|
|
|
@ -8,11 +8,11 @@ import java.util.*;
|
|||
/**
|
||||
* Created by Tzlil on 3/21/2016.
|
||||
*/
|
||||
public class DKGMaliciousUser extends DistributedKeyGenerationUser {
|
||||
public class DKGMaliciousUser<T> extends User<T> {
|
||||
|
||||
private final DistributedKeyGeneration maliciousDkg;
|
||||
private final Protocol<T> maliciousDkg;
|
||||
private final Set<Integer> falls;
|
||||
public DKGMaliciousUser(DistributedKeyGeneration dkg, DistributedKeyGeneration maliciousDKG, Channel channel, Set<Integer> falls) {
|
||||
public DKGMaliciousUser(Protocol<T> dkg, Protocol<T> maliciousDKG, Channel channel, Set<Integer> falls) {
|
||||
super(dkg, channel);
|
||||
this.falls = falls;
|
||||
this.maliciousDkg = maliciousDKG;
|
||||
|
@ -32,10 +32,10 @@ public class DKGMaliciousUser extends DistributedKeyGenerationUser {
|
|||
return falls;
|
||||
}
|
||||
|
||||
public static DistributedKeyGeneration generateMaliciousDKG(DistributedKeyGeneration dkg,Channel channel,Random random){
|
||||
public static <T> Protocol<T> generateMaliciousDKG(Protocol<T> dkg,Channel channel,Random random){
|
||||
BigInteger q = dkg.getQ();
|
||||
BigInteger zi = new BigInteger(q.bitLength(), random).mod(q);
|
||||
DistributedKeyGeneration malicious = new DistributedKeyGeneration(dkg.getT(),dkg.getN(),zi,random,dkg.getQ()
|
||||
Protocol<T> malicious = new Protocol<T>(dkg.getT(),dkg.getN(),zi,random,dkg.getQ()
|
||||
,dkg.getGenerator(),dkg.getGroup(),dkg.getId(),dkg.getEncoder());
|
||||
malicious.setChannel(channel);
|
||||
return malicious;
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package meerkat.crypto.concrete.distributed_key_generation.joint_feldman_protocol;
|
||||
|
||||
import Utils.ChannelImpl;
|
||||
import meerkat.crypto.utilitis.Arithmetic;
|
||||
import meerkat.crypto.utilitis.concrete.Fp;
|
||||
import meerkat.crypto.utilitis.Channel;
|
||||
import Communication.ChannelImpl;
|
||||
import meerkat.crypto.concrete.secret_shring.feldman_verifiable.VerifiableSecretSharing;
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.SecretSharing;
|
||||
import Utils.BigIntegerByteEncoder;
|
||||
import Utils.GenerateRandomPrime;
|
||||
import meerkat.protobuf.Crypto;
|
||||
import org.factcenter.qilin.primitives.Group;
|
||||
import org.factcenter.qilin.primitives.concrete.Zpstar;
|
||||
import org.factcenter.qilin.util.ByteEncoder;
|
||||
|
@ -95,13 +96,13 @@ public class DKGTest {
|
|||
Set<Integer> QUAL;
|
||||
Set<Integer> aborted;
|
||||
Set<Integer> malicious;
|
||||
DistributedKeyGenerationUser[] dkgs;
|
||||
User<BigInteger>[] dkgs;
|
||||
Thread[] threads;
|
||||
BigInteger g;
|
||||
BigInteger secret;
|
||||
|
||||
public Testable(Random random) {
|
||||
this.dkgs = new DistributedKeyGenerationUser[n];
|
||||
this.dkgs = new User[n];
|
||||
this.valids = new HashSet<Integer>();
|
||||
this.QUAL = new HashSet<Integer>();
|
||||
this.aborted = new HashSet<Integer>();
|
||||
|
@ -114,7 +115,7 @@ public class DKGTest {
|
|||
}
|
||||
int id;
|
||||
BigInteger s;
|
||||
DistributedKeyGeneration dkg;
|
||||
Protocol<BigInteger> dkg;
|
||||
this.secret = BigInteger.ZERO;
|
||||
Channel channel;
|
||||
ByteEncoder<BigInteger> byteEncoder = new BigIntegerByteEncoder();
|
||||
|
@ -122,7 +123,7 @@ public class DKGTest {
|
|||
id = ids.remove(random.nextInt(ids.size()));
|
||||
channel = new ChannelImpl(id,n);
|
||||
s = randomIntModQ(random);
|
||||
dkg = new DistributedKeyGeneration(t, n, s, random, q, g, group, id,byteEncoder);
|
||||
dkg = new meerkat.crypto.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);
|
||||
threads[id - 1] = new Thread(dkgs[id - 1]);
|
||||
if(QUAL.contains(id)){
|
||||
|
@ -132,18 +133,18 @@ public class DKGTest {
|
|||
|
||||
}
|
||||
|
||||
public DistributedKeyGenerationUser randomDKGUser(int id, Channel channel, DistributedKeyGeneration dkg, Random random){
|
||||
public User<BigInteger> randomDKGUser(int id, Channel channel, Protocol<BigInteger> dkg, Random random){
|
||||
if (QUAL.size() <= t) {
|
||||
valids.add(id);
|
||||
QUAL.add(id);
|
||||
return new DistributedKeyGenerationUser(dkg,channel);
|
||||
return new User<BigInteger>(dkg,channel);
|
||||
}else{
|
||||
int type = random.nextInt(3);
|
||||
switch (type){
|
||||
case 0:// regular
|
||||
valids.add(id);
|
||||
QUAL.add(id);
|
||||
return new DistributedKeyGenerationUser(dkg,channel);
|
||||
return new User<BigInteger>(dkg,channel);
|
||||
case 1:// abort
|
||||
int abortStage = random.nextInt(2) + 1; // 1 or 2
|
||||
aborted.add(id);
|
||||
|
@ -154,7 +155,7 @@ public class DKGTest {
|
|||
case 2:// malicious
|
||||
malicious.add(id);
|
||||
Set<Integer> falls = DKGMaliciousUser.selectFallsRandomly(valids,random);
|
||||
DistributedKeyGeneration maliciousDKG = DKGMaliciousUser.generateMaliciousDKG(dkg,channel,random);
|
||||
Protocol<BigInteger> maliciousDKG = DKGMaliciousUser.generateMaliciousDKG(dkg,channel,random);
|
||||
return new DKGMaliciousUser(dkg,maliciousDKG,channel,falls);
|
||||
default:
|
||||
return null;
|
||||
|
|
|
@ -6,11 +6,11 @@ import meerkat.protobuf.DKGMessages;
|
|||
/**
|
||||
* Created by Tzlil on 3/14/2016.
|
||||
*/
|
||||
public class DKGUserImplAbort extends DistributedKeyGenerationUser {
|
||||
public class DKGUserImplAbort<T> extends User<T> {
|
||||
|
||||
final int abortStage;
|
||||
int stage;
|
||||
public DKGUserImplAbort(DistributedKeyGeneration dkg, Channel channel, int abortStage) {
|
||||
public DKGUserImplAbort(Protocol<T> dkg, Channel channel, int abortStage) {
|
||||
super(dkg, channel);
|
||||
this.abortStage = abortStage;// 1 - 2
|
||||
this.stage = 1;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package meerkat.crypto.concrete.secret_shring.feldman_verifiable;
|
||||
|
||||
import meerkat.crypto.concrete.secret_shring.ShamirSecretSharing.Polynomial;
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
||||
import org.factcenter.qilin.primitives.Group;
|
||||
import org.factcenter.qilin.primitives.concrete.Zpstar;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package meerkat.crypto.concrete.secret_shring.shamir.PolynomialTests;
|
||||
import Arithmetics.Z;
|
||||
import Utils.GenerateRandomPolynomial;
|
||||
import Utils.Z;
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package meerkat.crypto.concrete.secret_shring.shamir.PolynomialTests;
|
||||
|
||||
import Arithmetics.Z;
|
||||
import Utils.GenerateRandomPolynomial;
|
||||
import Utils.Z;
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package meerkat.crypto.concrete.secret_shring.shamir.PolynomialTests;
|
||||
|
||||
import Arithmetics.Z;
|
||||
import Utils.GenerateRandomPolynomial;
|
||||
import Utils.Z;
|
||||
import meerkat.crypto.concrete.secret_shring.shamir.Polynomial;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -6,7 +6,7 @@ option java_package = "meerkat.protobuf";
|
|||
|
||||
message Mail{
|
||||
enum Type {
|
||||
SECRET = 0;
|
||||
SHARE = 0;
|
||||
COMMITMENT = 1;
|
||||
COMPLAINT = 2;
|
||||
DONE = 3;
|
||||
|
@ -23,17 +23,17 @@ message Mail{
|
|||
bytes message = 5;
|
||||
}
|
||||
|
||||
message SecretMessage {
|
||||
message ShareMessage {
|
||||
int32 i = 1;
|
||||
int32 j = 2;
|
||||
bytes secret = 3;
|
||||
bytes share = 3;
|
||||
}
|
||||
|
||||
message DoubleSecretMessage{
|
||||
message DoubleShareMessage{
|
||||
int32 i = 1;
|
||||
int32 j = 2;
|
||||
bytes secret = 3;
|
||||
bytes secretT = 4;
|
||||
bytes share = 3;
|
||||
bytes shareT = 4;
|
||||
}
|
||||
|
||||
message CommitmentMessage{
|
||||
|
|
Loading…
Reference in New Issue