From b614a3303fd2c81d575243a7fbc43b3fc5f97250 Mon Sep 17 00:00:00 2001 From: rk Date: Tue, 14 Feb 2023 14:37:37 +0100 Subject: [PATCH 1/5] fix: BBS+ verifier --- pom.xml | 82 +++++++++++++++++-- .../Bls12381G2_BBSPlus_PublicKeyVerifier.java | 2 +- ...ls12381G2_BBSPlus_PublicKeyVerifierTest.kt | 25 ++++++ 3 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt diff --git a/pom.xml b/pom.xml index 7370594..5548a15 100644 --- a/pom.xml +++ b/pom.xml @@ -45,19 +45,11 @@ UTF-8 github 2.5.3 + 1.8.20-Beta - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - 1.8 - 1.8 - - org.apache.maven.plugins maven-source-plugin @@ -103,6 +95,67 @@ @{project.version} + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + src/main/java + target/generated-sources/annotations + + + + + test-compile + test-compile + + test-compile + + + + src/test/java + target/generated-test-sources/test-annotations + + + + + + 1.8 + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + compile + compile + + compile + + + + testCompile + test-compile + + testCompile + + + + + 1.8 + 1.8 + + @@ -201,6 +254,17 @@ + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + diff --git a/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G2_BBSPlus_PublicKeyVerifier.java b/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G2_BBSPlus_PublicKeyVerifier.java index 702f09d..5a3e40a 100644 --- a/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G2_BBSPlus_PublicKeyVerifier.java +++ b/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G2_BBSPlus_PublicKeyVerifier.java @@ -19,7 +19,7 @@ public boolean verify(byte[] content, byte[] signature) throws GeneralSecurityEx try { - return Bbs.blsVerify(this.getPublicKey().publicKey, signature, new byte[][]{signature}); + return Bbs.blsVerify(this.getPublicKey().publicKey, signature, new byte[][]{content}); } catch (GeneralSecurityException ex) { throw ex; diff --git a/src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt b/src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt new file mode 100644 index 0000000..5d7e0b1 --- /dev/null +++ b/src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt @@ -0,0 +1,25 @@ +package com.danubetech.keyformats.crypto + +import bbs.signatures.Bbs +import com.danubetech.keyformats.crypto.impl.Bls12381G2_BBSPlus_PrivateKeySigner +import com.danubetech.keyformats.crypto.impl.Bls12381G2_BBSPlus_PublicKeyVerifier +import org.junit.jupiter.api.Test +import kotlin.random.Random +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class Bls12381G2_BBSPlusTest { + @Test + fun signAndVerifyContent() { + val content = Random.nextBytes(32) + val keyPair = Bbs.generateBls12381G2Key(Random.nextBytes(32)) + val signature = Bls12381G2_BBSPlus_PrivateKeySigner(keyPair).run { + sign(content) + } + assertEquals(signature.size, 112) + val verifyResult = Bls12381G2_BBSPlus_PublicKeyVerifier(keyPair).run { + verify(content, signature) + } + assertTrue(verifyResult) + } +} \ No newline at end of file From 35a05ce2d2ba83b5edbebdaa7a79f103db4d734a Mon Sep 17 00:00:00 2001 From: rk Date: Thu, 16 Feb 2023 11:23:11 +0100 Subject: [PATCH 2/5] add: signing and verifying of list of messages (Bls12381 only) --- pom.xml | 4 +- .../crypto/PublicKeyVerifierFactory.java | 4 +- .../crypto/impl/BBSPlus_PrivateKeySigner.java | 38 +++++++++++++++++++ .../impl/BBSPlus_PublicKeyVerifier.java | 32 ++++++++++++++++ .../Bls12381G1_BBSPlus_PrivateKeySigner.java | 22 ++--------- .../Bls12381G1_BBSPlus_PublicKeyVerifier.java | 29 +++----------- .../Bls12381G2_BBSPlus_PrivateKeySigner.java | 22 ++--------- .../Bls12381G2_BBSPlus_PublicKeyVerifier.java | 25 +++--------- ...ls12381G2_BBSPlus_PublicKeyVerifierTest.kt | 19 +++++++++- 9 files changed, 109 insertions(+), 86 deletions(-) create mode 100644 src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PrivateKeySigner.java create mode 100644 src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PublicKeyVerifier.java diff --git a/pom.xml b/pom.xml index 5548a15..f790871 100644 --- a/pom.xml +++ b/pom.xml @@ -152,8 +152,8 @@ - 1.8 - 1.8 + 9 + 9 diff --git a/src/main/java/com/danubetech/keyformats/crypto/PublicKeyVerifierFactory.java b/src/main/java/com/danubetech/keyformats/crypto/PublicKeyVerifierFactory.java index 4385460..4765d7c 100644 --- a/src/main/java/com/danubetech/keyformats/crypto/PublicKeyVerifierFactory.java +++ b/src/main/java/com/danubetech/keyformats/crypto/PublicKeyVerifierFactory.java @@ -37,10 +37,10 @@ public static PublicKeyVerifier publicKeyVerifierForKey(KeyTypeName keyTypeNa if (JWSAlgorithm.ES256KCC.equals(algorithm)) return new secp256k1_ES256KCC_PublicKeyVerifier((ECKey) publicKey); } else if (KeyTypeName.Bls12381G1.equals(keyTypeName)) { - if (JWSAlgorithm.BBSPlus.equals(algorithm)) return new Bls12381G1_BBSPlus_PublicKeyVerifier((bbs.signatures.KeyPair) publicKey); + if (JWSAlgorithm.BBSPlus.equals(algorithm)) return new Bls12381G1_BBSPlus_PublicKeyVerifier((byte[]) publicKey); } else if (KeyTypeName.Bls12381G2.equals(keyTypeName)) { - if (JWSAlgorithm.BBSPlus.equals(algorithm)) return new Bls12381G2_BBSPlus_PublicKeyVerifier((bbs.signatures.KeyPair) publicKey); + if (JWSAlgorithm.BBSPlus.equals(algorithm)) return new Bls12381G2_BBSPlus_PublicKeyVerifier((byte[]) publicKey); } else if (KeyTypeName.Bls48581G1.equals(keyTypeName)) { if (JWSAlgorithm.BBSPlus.equals(algorithm)) return new Bls48581G1_BBSPlus_PublicKeyVerifier((bbs.signatures.KeyPair) publicKey); diff --git a/src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PrivateKeySigner.java b/src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PrivateKeySigner.java new file mode 100644 index 0000000..69fff2d --- /dev/null +++ b/src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PrivateKeySigner.java @@ -0,0 +1,38 @@ +package com.danubetech.keyformats.crypto.impl; + +import bbs.signatures.Bbs; +import bbs.signatures.KeyPair; +import com.danubetech.keyformats.crypto.PrivateKeySigner; +import com.danubetech.keyformats.jose.JWSAlgorithm; + +import java.security.GeneralSecurityException; +import java.util.List; + +public class BBSPlus_PrivateKeySigner extends PrivateKeySigner { + + private final byte[] publicKey; + + public BBSPlus_PrivateKeySigner(KeyPair keyPair) { + super( keyPair.secretKey, JWSAlgorithm.BBSPlus); + int keySize = Bbs.getSecretKeySize(); + if (keyPair.secretKey.length != keySize) { + throw new IllegalArgumentException("wrong key size: expected: " + keySize + "but was " + keyPair.secretKey.length); + } + publicKey = keyPair.publicKey; + } + + @Override + public byte[] sign(byte[] content) throws GeneralSecurityException { + return sign(List.of(content)); + } + + public byte[] sign(List content) throws GeneralSecurityException { + try { + return Bbs.blsSign(getPrivateKey(), publicKey, content.toArray(new byte[content.size()][])); + } catch (GeneralSecurityException ex) { + throw ex; + } catch (Exception ex) { + throw new GeneralSecurityException(ex.getMessage(), ex); + } + } +} diff --git a/src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PublicKeyVerifier.java b/src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PublicKeyVerifier.java new file mode 100644 index 0000000..d5ec249 --- /dev/null +++ b/src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PublicKeyVerifier.java @@ -0,0 +1,32 @@ +package com.danubetech.keyformats.crypto.impl; + +import bbs.signatures.Bbs; +import bbs.signatures.KeyPair; +import com.danubetech.keyformats.crypto.PublicKeyVerifier; +import com.danubetech.keyformats.jose.JWSAlgorithm; + +import java.security.GeneralSecurityException; +import java.util.List; + +public class BBSPlus_PublicKeyVerifier extends PublicKeyVerifier { + + public BBSPlus_PublicKeyVerifier(byte[] publicKey) { + super(publicKey, JWSAlgorithm.BBSPlus); + } + + @Override + public boolean verify(byte[] content, byte[] signature) throws GeneralSecurityException { + return verify(List.of(content), signature); + } + + public boolean verify(List content, byte[] signature) throws GeneralSecurityException { + try { + return Bbs.blsVerify(getPublicKey(), signature, content.toArray(new byte[content.size()][])); + } catch (GeneralSecurityException ex) { + throw ex; + } catch (Exception ex) { + throw new GeneralSecurityException(ex.getMessage(), ex); + } + } + +} diff --git a/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G1_BBSPlus_PrivateKeySigner.java b/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G1_BBSPlus_PrivateKeySigner.java index 29eb346..53d07a4 100644 --- a/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G1_BBSPlus_PrivateKeySigner.java +++ b/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G1_BBSPlus_PrivateKeySigner.java @@ -7,25 +7,9 @@ import java.security.GeneralSecurityException; -public class Bls12381G1_BBSPlus_PrivateKeySigner extends PrivateKeySigner { +public class Bls12381G1_BBSPlus_PrivateKeySigner extends BBSPlus_PrivateKeySigner { - public Bls12381G1_BBSPlus_PrivateKeySigner(KeyPair privateKey) { - - super(privateKey, JWSAlgorithm.BBSPlus); - } - - @Override - public byte[] sign(byte[] content) throws GeneralSecurityException { - - try { - - return Bbs.blsSign(this.getPrivateKey().secretKey, this.getPrivateKey().publicKey, new byte[][]{content}); - } catch (GeneralSecurityException ex) { - - throw ex; - } catch (Exception ex) { - - throw new GeneralSecurityException(ex.getMessage(), ex); - } + public Bls12381G1_BBSPlus_PrivateKeySigner(KeyPair keyPair) { + super(keyPair); } } diff --git a/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G1_BBSPlus_PublicKeyVerifier.java b/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G1_BBSPlus_PublicKeyVerifier.java index 0831332..418e7c9 100644 --- a/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G1_BBSPlus_PublicKeyVerifier.java +++ b/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G1_BBSPlus_PublicKeyVerifier.java @@ -1,31 +1,14 @@ package com.danubetech.keyformats.crypto.impl; import bbs.signatures.Bbs; -import bbs.signatures.KeyPair; -import com.danubetech.keyformats.crypto.PublicKeyVerifier; -import com.danubetech.keyformats.jose.JWSAlgorithm; -import java.security.GeneralSecurityException; +public class Bls12381G1_BBSPlus_PublicKeyVerifier extends BBSPlus_PublicKeyVerifier { -public class Bls12381G1_BBSPlus_PublicKeyVerifier extends PublicKeyVerifier { - - public Bls12381G1_BBSPlus_PublicKeyVerifier(KeyPair publicKey) { - - super(publicKey, JWSAlgorithm.BBSPlus); - } - - @Override - public boolean verify(byte[] content, byte[] signature) throws GeneralSecurityException { - - try { - - return Bbs.blsVerify(this.getPublicKey().publicKey, signature, new byte[][]{signature}); - } catch (GeneralSecurityException ex) { - - throw ex; - } catch (Exception ex) { - - throw new GeneralSecurityException(ex.getMessage(), ex); + public Bls12381G1_BBSPlus_PublicKeyVerifier(byte[] publicKey) { + super(publicKey); + int keySize = Bbs.getBls12381G1PublicKeySize(); + if (publicKey.length != keySize) { + throw new IllegalArgumentException("wrong key size: expected: " + keySize + "but was " + publicKey.length); } } } diff --git a/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G2_BBSPlus_PrivateKeySigner.java b/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G2_BBSPlus_PrivateKeySigner.java index 969a6bf..a730eee 100644 --- a/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G2_BBSPlus_PrivateKeySigner.java +++ b/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G2_BBSPlus_PrivateKeySigner.java @@ -7,25 +7,9 @@ import java.security.GeneralSecurityException; -public class Bls12381G2_BBSPlus_PrivateKeySigner extends PrivateKeySigner { +public class Bls12381G2_BBSPlus_PrivateKeySigner extends BBSPlus_PrivateKeySigner { - public Bls12381G2_BBSPlus_PrivateKeySigner(KeyPair privateKey) { - - super(privateKey, JWSAlgorithm.BBSPlus); - } - - @Override - public byte[] sign(byte[] content) throws GeneralSecurityException { - - try { - - return Bbs.blsSign(this.getPrivateKey().secretKey, this.getPrivateKey().publicKey, new byte[][]{content}); - } catch (GeneralSecurityException ex) { - - throw ex; - } catch (Exception ex) { - - throw new GeneralSecurityException(ex.getMessage(), ex); - } + public Bls12381G2_BBSPlus_PrivateKeySigner(KeyPair keyPair) { + super(keyPair); } } diff --git a/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G2_BBSPlus_PublicKeyVerifier.java b/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G2_BBSPlus_PublicKeyVerifier.java index 5a3e40a..3978e18 100644 --- a/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G2_BBSPlus_PublicKeyVerifier.java +++ b/src/main/java/com/danubetech/keyformats/crypto/impl/Bls12381G2_BBSPlus_PublicKeyVerifier.java @@ -7,25 +7,12 @@ import java.security.GeneralSecurityException; -public class Bls12381G2_BBSPlus_PublicKeyVerifier extends PublicKeyVerifier { - - public Bls12381G2_BBSPlus_PublicKeyVerifier(KeyPair publicKey) { - - super(publicKey, JWSAlgorithm.BBSPlus); - } - - @Override - public boolean verify(byte[] content, byte[] signature) throws GeneralSecurityException { - - try { - - return Bbs.blsVerify(this.getPublicKey().publicKey, signature, new byte[][]{content}); - } catch (GeneralSecurityException ex) { - - throw ex; - } catch (Exception ex) { - - throw new GeneralSecurityException(ex.getMessage(), ex); +public class Bls12381G2_BBSPlus_PublicKeyVerifier extends BBSPlus_PublicKeyVerifier { + public Bls12381G2_BBSPlus_PublicKeyVerifier(byte[] publicKey) { + super(publicKey); + int keySize = Bbs.getBls12381G2PublicKeySize(); + if (publicKey.length != keySize) { + throw new IllegalArgumentException("wrong key size: expected: " + keySize + "but was " + publicKey.length); } } } diff --git a/src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt b/src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt index 5d7e0b1..f305014 100644 --- a/src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt +++ b/src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt @@ -10,16 +10,31 @@ import kotlin.test.assertTrue class Bls12381G2_BBSPlusTest { @Test - fun signAndVerifyContent() { + fun signAndVerifySingleMessage() { val content = Random.nextBytes(32) val keyPair = Bbs.generateBls12381G2Key(Random.nextBytes(32)) val signature = Bls12381G2_BBSPlus_PrivateKeySigner(keyPair).run { sign(content) } assertEquals(signature.size, 112) - val verifyResult = Bls12381G2_BBSPlus_PublicKeyVerifier(keyPair).run { + val verifyResult = Bls12381G2_BBSPlus_PublicKeyVerifier(keyPair.publicKey).run { verify(content, signature) } assertTrue(verifyResult) } + + @Test + fun signAndVerifyListOfMessages() { + val content = listOf(Random.nextBytes(32), Random.nextBytes(32), Random.nextBytes(32)) + val keyPair = Bbs.generateBls12381G2Key(Random.nextBytes(32)) + val signature = Bls12381G2_BBSPlus_PrivateKeySigner(keyPair).run { + sign(content) + } + assertEquals(signature.size, 112) + val verifyResult = Bls12381G2_BBSPlus_PublicKeyVerifier(keyPair.publicKey).run { + verify(content, signature) + } + assertTrue(verifyResult) + } + } \ No newline at end of file From c6b045596bbce5941579f1fae1225b50a29bde8a Mon Sep 17 00:00:00 2001 From: rk Date: Thu, 23 Feb 2023 16:13:07 +0100 Subject: [PATCH 3/5] add: failing test case signAndVerifyLongListOfMessages() --- pom.xml | 2 +- .../crypto/impl/BBSPlus_PrivateKeySigner.java | 7 +++++++ .../crypto/impl/BBSPlus_PublicKeyVerifier.java | 8 +++++++- .../Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt | 16 +++++++++++++++- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index f790871..ef35d3c 100644 --- a/pom.xml +++ b/pom.xml @@ -240,7 +240,7 @@ com.github.mattrglobal bbs.signatures - 1.5-21-07-2021 + 1.6-SNAPSHOT true diff --git a/src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PrivateKeySigner.java b/src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PrivateKeySigner.java index 69fff2d..d5e514e 100644 --- a/src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PrivateKeySigner.java +++ b/src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PrivateKeySigner.java @@ -26,6 +26,13 @@ public byte[] sign(byte[] content) throws GeneralSecurityException { return sign(List.of(content)); } + public final byte[] sign(List content, String algorithm) throws GeneralSecurityException { + + if (! algorithm.equals(getAlgorithm())) throw new GeneralSecurityException("Unexpected algorithm " + algorithm + " is different from " + getAlgorithm()); + + return this.sign(content); + } + public byte[] sign(List content) throws GeneralSecurityException { try { return Bbs.blsSign(getPrivateKey(), publicKey, content.toArray(new byte[content.size()][])); diff --git a/src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PublicKeyVerifier.java b/src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PublicKeyVerifier.java index d5ec249..3ed655b 100644 --- a/src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PublicKeyVerifier.java +++ b/src/main/java/com/danubetech/keyformats/crypto/impl/BBSPlus_PublicKeyVerifier.java @@ -1,7 +1,6 @@ package com.danubetech.keyformats.crypto.impl; import bbs.signatures.Bbs; -import bbs.signatures.KeyPair; import com.danubetech.keyformats.crypto.PublicKeyVerifier; import com.danubetech.keyformats.jose.JWSAlgorithm; @@ -19,6 +18,13 @@ public boolean verify(byte[] content, byte[] signature) throws GeneralSecurityEx return verify(List.of(content), signature); } + public final boolean verify(List content, byte[] signature, String algorithm) throws GeneralSecurityException { + if (!algorithm.equals(getAlgorithm())) { + throw new GeneralSecurityException("Unexpected algorithm " + algorithm + " is different from " + getAlgorithm()); + } + return this.verify(content, signature); + } + public boolean verify(List content, byte[] signature) throws GeneralSecurityException { try { return Bbs.blsVerify(getPublicKey(), signature, content.toArray(new byte[content.size()][])); diff --git a/src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt b/src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt index f305014..95dc75b 100644 --- a/src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt +++ b/src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt @@ -25,7 +25,21 @@ class Bls12381G2_BBSPlusTest { @Test fun signAndVerifyListOfMessages() { - val content = listOf(Random.nextBytes(32), Random.nextBytes(32), Random.nextBytes(32)) + val content = List(3) { Random.nextBytes(32) } + val keyPair = Bbs.generateBls12381G2Key(Random.nextBytes(32)) + val signature = Bls12381G2_BBSPlus_PrivateKeySigner(keyPair).run { + sign(content) + } + assertEquals(signature.size, 112) + val verifyResult = Bls12381G2_BBSPlus_PublicKeyVerifier(keyPair.publicKey).run { + verify(content, signature) + } + assertTrue(verifyResult) + } + + @Test + fun signAndVerifyLongListOfMessages() { + val content = List(20) { Random.nextBytes(32) } val keyPair = Bbs.generateBls12381G2Key(Random.nextBytes(32)) val signature = Bls12381G2_BBSPlus_PrivateKeySigner(keyPair).run { sign(content) From 2d792e10a18ea33f4a2e8e93cc013c6083922abc Mon Sep 17 00:00:00 2001 From: rk Date: Mon, 27 Feb 2023 10:32:48 +0100 Subject: [PATCH 4/5] mod: kotlin (pom) and kotlin unit tests removed --- ...ls12381G2_BBSPlus_PublicKeyVerifierTest.kt | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt diff --git a/src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt b/src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt deleted file mode 100644 index 95dc75b..0000000 --- a/src/test/java/com/danubetech/keyformats/crypto/Bls12381G2_BBSPlus_PublicKeyVerifierTest.kt +++ /dev/null @@ -1,54 +0,0 @@ -package com.danubetech.keyformats.crypto - -import bbs.signatures.Bbs -import com.danubetech.keyformats.crypto.impl.Bls12381G2_BBSPlus_PrivateKeySigner -import com.danubetech.keyformats.crypto.impl.Bls12381G2_BBSPlus_PublicKeyVerifier -import org.junit.jupiter.api.Test -import kotlin.random.Random -import kotlin.test.assertEquals -import kotlin.test.assertTrue - -class Bls12381G2_BBSPlusTest { - @Test - fun signAndVerifySingleMessage() { - val content = Random.nextBytes(32) - val keyPair = Bbs.generateBls12381G2Key(Random.nextBytes(32)) - val signature = Bls12381G2_BBSPlus_PrivateKeySigner(keyPair).run { - sign(content) - } - assertEquals(signature.size, 112) - val verifyResult = Bls12381G2_BBSPlus_PublicKeyVerifier(keyPair.publicKey).run { - verify(content, signature) - } - assertTrue(verifyResult) - } - - @Test - fun signAndVerifyListOfMessages() { - val content = List(3) { Random.nextBytes(32) } - val keyPair = Bbs.generateBls12381G2Key(Random.nextBytes(32)) - val signature = Bls12381G2_BBSPlus_PrivateKeySigner(keyPair).run { - sign(content) - } - assertEquals(signature.size, 112) - val verifyResult = Bls12381G2_BBSPlus_PublicKeyVerifier(keyPair.publicKey).run { - verify(content, signature) - } - assertTrue(verifyResult) - } - - @Test - fun signAndVerifyLongListOfMessages() { - val content = List(20) { Random.nextBytes(32) } - val keyPair = Bbs.generateBls12381G2Key(Random.nextBytes(32)) - val signature = Bls12381G2_BBSPlus_PrivateKeySigner(keyPair).run { - sign(content) - } - assertEquals(signature.size, 112) - val verifyResult = Bls12381G2_BBSPlus_PublicKeyVerifier(keyPair.publicKey).run { - verify(content, signature) - } - assertTrue(verifyResult) - } - -} \ No newline at end of file From 29a309580632c21a7e028097bc71dfcb1d6d6053 Mon Sep 17 00:00:00 2001 From: rk Date: Mon, 27 Feb 2023 10:37:50 +0100 Subject: [PATCH 5/5] mod: remove kotlin (pom) --- pom.xml | 84 +++++++-------------------------------------------------- 1 file changed, 10 insertions(+), 74 deletions(-) diff --git a/pom.xml b/pom.xml index ef35d3c..7370594 100644 --- a/pom.xml +++ b/pom.xml @@ -45,11 +45,19 @@ UTF-8 github 2.5.3 - 1.8.20-Beta + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + org.apache.maven.plugins maven-source-plugin @@ -95,67 +103,6 @@ @{project.version} - - org.jetbrains.kotlin - kotlin-maven-plugin - ${kotlin.version} - - - compile - compile - - compile - - - - src/main/java - target/generated-sources/annotations - - - - - test-compile - test-compile - - test-compile - - - - src/test/java - target/generated-test-sources/test-annotations - - - - - - 1.8 - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - - compile - compile - - compile - - - - testCompile - test-compile - - testCompile - - - - - 9 - 9 - - @@ -240,7 +187,7 @@ com.github.mattrglobal bbs.signatures - 1.6-SNAPSHOT + 1.5-21-07-2021 true @@ -254,17 +201,6 @@ - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - ${kotlin.version} - - - org.jetbrains.kotlin - kotlin-test - ${kotlin.version} - test -