Skip to content

Java Implementation of Threshold Signatures using Ed25519

License

Notifications You must be signed in to change notification settings

omarelnaggar/threshold-sig

 
 

Repository files navigation

Threshold Signature using Ed25519

A pure Java implementation of Threshold Signature.

Threshold signature schemes are a way of generating a single digital signature from multiple signers that can be then validated by another party that has a public key of the participants.

T out of N participants need to sign in order for the threshold signature to be valid.

Part of Weavechain: The Layer-0 For Data

Usage

Gradle Groovy DSL

implementation 'com.weavechain:threshold-sig:1.2'

Gradle Kotlin DSL

implementation("com.weavechain:threshold-sig:1.2")
Apache Maven
<dependency>
  <groupId>com.weavechain</groupId>
  <artifactId>threshold-sig</artifactId>
  <version>1.2</version>
</dependency>

Sample

int T = 2;
int N = 3;

Set<Integer> nodes = new HashSet<>();
nodes.add(0);
nodes.add(1);

String toSign = "test";
ThresholdSigEd25519 tsig = new ThresholdSigEd25519(T, N);

//done by coordinator
ThresholdSigEd25519Params params = tsig.generate();

//Round 1: gather from each node
List<EdwardsPoint> Ri = tsig.gatherRi(params, toSign, nodes);

//done by coordinator
EdwardsPoint R = tsig.computeR(Ri);
Scalar k = tsig.computeK(params.getPublicKey(), R, toSign);

//Round 2: gather from each node
List<Scalar> res = tsig.gatherSignatures(params, k, nodes);

//done by coordinator
byte[] signature = tsig.computeSignature(R, res);

//done by validator
boolean check = ThresholdSigEd25519.verify(params.getPublicKey(), signature, toSign.getBytes(StandardCharsets.UTF_8));
System.out.println(check ? "Success" : "Fail");

Weavechain

Read more about Weavechain at https://docs.weavechain.com

About

Java Implementation of Threshold Signatures using Ed25519

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 77.5%
  • Kotlin 22.5%