Skip to content

Commit

Permalink
Merge branch 'feat/add-schnorr-signature' of github.com:ArkEcosystem/…
Browse files Browse the repository at this point in the history
…java-crypto into feat/add-schnorr-signature
  • Loading branch information
alfonsobries committed Aug 5, 2024
2 parents 772dc85 + 7b6ec80 commit a7354b4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/test/java/org/arkecosystem/crypto/SchnorrTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class SchnorrTest {
@Test
public void convertHexStringToByteArray() {
assertEquals(
Hex.encode(Schnorr.hexStringToByteArray("b693449AdDa7EFc015D87944EAE8b7C37EB1690A")),
"b693449adda7efc015d87944eae8b7c37eb1690a"
);
Hex.encode(
Schnorr.hexStringToByteArray("b693449AdDa7EFc015D87944EAE8b7C37EB1690A")),
"b693449adda7efc015d87944eae8b7c37eb1690a");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;


public class FixtureSignVerificationTest {

private final String passphrase = "my super secret passphrase";
private final String secondPassphrase = "this is a top secret second passphrase";
private final String musigPassphrase1 = "album pony urban cheap small blade cannon silent run reveal luxury glad predict excess fire beauty hollow reward solar egg exclude leaf sight degree";
private final String musigPassphrase2 = "hen slogan retire boss upset blame rocket slender area arch broom bring elder few milk bounce execute page evoke once inmate pear marine deliver";
private final String musigPassphrase3 = "top visa use bacon sun infant shrimp eye bridge fantasy chair sadness stable simple salad canoe raw hill target connect avoid promote spider category";
private final String musigPassphrase1 =
"album pony urban cheap small blade cannon silent run reveal luxury glad predict excess fire beauty hollow reward solar egg exclude leaf sight degree";
private final String musigPassphrase2 =
"hen slogan retire boss upset blame rocket slender area arch broom bring elder few milk bounce execute page evoke once inmate pear marine deliver";
private final String musigPassphrase3 =
"top visa use bacon sun infant shrimp eye bridge fantasy chair sadness stable simple salad canoe raw hill target connect avoid promote spider category";

@ParameterizedTest
@ValueSource(
strings = {
"transactions/transfer/transfer-sign",
"transactions/transfer/transfer-with-vendor-field-sign",
// "transactions/transfer/transfer-multi-sign",

"transactions/vote/vote-sign",
"transactions/vote/unvote-sign",
// "transactions/vote/vote-multi-sign",
Expand All @@ -59,7 +61,6 @@ void checkSchnorrSignature(String file) {
LinkedTreeMap<String, Object> fixture = FixtureLoader.load(file);

Transaction actual = new Deserializer(fixture.get("serialized").toString()).deserialize();


if (actual.signature != null) assertTrue(actual.verify());

Expand All @@ -78,7 +79,7 @@ void checkSchnorrSignature(String file) {
"transactions/transfer/transfer-sign",
"transactions/transfer/transfer-with-vendor-field-sign",
// "transactions/transfer/transfer-multi-sign",

"transactions/vote/vote-sign",
"transactions/vote/unvote-sign",
// "transactions/vote/vote-multi-sign",
Expand Down Expand Up @@ -125,7 +126,7 @@ void checkSigningAgainProducesSameSignature(String file) {
if (withoutSignatures.secondSignature != null) {
checkSecondSignature(withoutSignatures);
}

int signatureLength = 128;

if (withoutSignatures.signatures != null) {
Expand All @@ -137,11 +138,11 @@ void checkSigningAgainProducesSameSignature(String file) {
String serializedWithoutSignatures = Hex.encode(Serializer.serialize(withoutSignatures));
String serializedFixture = fixture.get("serialized").toString();

// Exclude the last 128 characters (signature) for final comparison
// Exclude the last 128 characters (signature) for final comparison
assertThat(
serializedWithoutSignatures.substring(0, serializedWithoutSignatures.length() - signatureLength),
is(serializedFixture.substring(0, serializedFixture.length() - signatureLength)));

serializedWithoutSignatures.substring(
0, serializedWithoutSignatures.length() - signatureLength),
is(serializedFixture.substring(0, serializedFixture.length() - signatureLength)));
}

private void reSignUnsigned(Transaction actual, Transaction withoutSignatures) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.arkecosystem.crypto.signature;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.arkecosystem.crypto.Schnorr;
import org.arkecosystem.crypto.encoding.Hex;
Expand Down

0 comments on commit a7354b4

Please sign in to comment.