Commit 80bbda24 authored by Gijs Van Laer's avatar Gijs Van Laer
Browse files

add W to key for completeness

parent fe7f24c7
......@@ -5,6 +5,19 @@ Implementation of the CL signature scheme
This is an experimental library and is only at its first version. The API could still be updated in the near future.
I cannot guarantee the security of this library, and one should not use this in production.
### Setup ###
* Install PBC on your machine (Hopefully we can solve this in time)
https://crypto.stanford.edu/pbc/
* Setup a shared library
http://gas.dia.unisa.it/projects/jpbc/docs/pbcwrapper.html
### Run tests ###
* mvn clean test
### Usage ###
Note: random messages are generated in this example
......
......@@ -47,10 +47,14 @@ public class CLSign {
private static PublicKey createPublicKey(final Pairing pairing, final SecretKey sk) {
final Element generator = pairing.getG1().newRandomElement().getImmutable();
final Element generatorT = pairing.getGT().newRandomElement().getImmutable();
final Element X = generator.powZn(sk.getX());
final Element Y = generator.powZn(sk.getY());
final List<Element> Z = sk.getZ().stream()
.map(generator::powZn).collect(Collectors.toList());
final List<Element> W = sk.getZ().stream()
.map(Y::powZn).collect(Collectors.toList());
return new PublicKey(pairing, generator, generatorT,
generator.powZn(sk.getX()), generator.powZn(sk.getY()), Z);
X, Y, Z, W);
}
private static SecretKey createSecretKey(final Pairing pairing, final int messageSize) {
......
......@@ -34,14 +34,16 @@ public class PublicKey {
private Element X;
private Element Y;
private List<Element> Z = new ArrayList<>();
private List<Element> W = new ArrayList<>();
public PublicKey(final Pairing pairing, final Element generator, final Element generatorT, final Element x, final Element y, final List<Element> z) {
public PublicKey(final Pairing pairing, final Element generator, final Element generatorT, final Element x, final Element y, final List<Element> z, final List<Element> w) {
this.pairing = pairing;
this.generator = generator;
this.generatorT = generatorT;
X = x;
Y = y;
Z = z;
W = w;
}
public Pairing getPairing() {
......@@ -67,4 +69,12 @@ public class PublicKey {
public List<Element> getZ() {
return Z;
}
public Element getW(final int index) {
return W.get(index);
}
public List<Element> getW() {
return W;
}
}
......@@ -26,10 +26,12 @@ public class CLSignTest {
assertNotNull(sk);
assertEquals(messageSize, sk.getZ().size());
assertEquals(messageSize, pk.getZ().size());
assertEquals(messageSize, pk.getW().size());
assertEquals(pk.getGenerator().powZn(sk.getX()), pk.getX());
assertEquals(pk.getGenerator().powZn(sk.getY()), pk.getY());
for (int i = 0; i < messageSize; i++) {
assertEquals(pk.getGenerator().powZn(sk.getZ(i)), pk.getZ(i));
assertEquals(pk.getY().powZn(sk.getZ(i)), pk.getW(i));
}
assertEquals(pk.getPairing().getG1(), pk.getPairing().getG2());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment