From dfe96f572122660b9931da83ee9cba4f444d8e34 Mon Sep 17 00:00:00 2001 From: jamesm Date: Tue, 29 Oct 2024 17:13:48 -0400 Subject: [PATCH] Move Ed25519 to the encoding package - it's only used by the SolanaProgramDerivedAddress so just put it next to it in the package --- .../solana4j/{ => encoding}/EddsaPointOnCurveBenchmark.java | 3 +-- .../java/com/lmax/solana4j/{util => encoding}/Ed25519.java | 6 +++--- .../lmax/solana4j/encoding/SolanaProgramDerivedAddress.java | 1 - .../com/lmax/solana4j/{util => encoding}/Ed25519Test.java | 3 ++- 4 files changed, 6 insertions(+), 7 deletions(-) rename message-encoding/src/jmh-test/java/com/lmax/solana4j/{ => encoding}/EddsaPointOnCurveBenchmark.java (97%) rename message-encoding/src/main/java/com/lmax/solana4j/{util => encoding}/Ed25519.java (96%) rename message-encoding/src/test/java/com/lmax/solana4j/{util => encoding}/Ed25519Test.java (97%) diff --git a/message-encoding/src/jmh-test/java/com/lmax/solana4j/EddsaPointOnCurveBenchmark.java b/message-encoding/src/jmh-test/java/com/lmax/solana4j/encoding/EddsaPointOnCurveBenchmark.java similarity index 97% rename from message-encoding/src/jmh-test/java/com/lmax/solana4j/EddsaPointOnCurveBenchmark.java rename to message-encoding/src/jmh-test/java/com/lmax/solana4j/encoding/EddsaPointOnCurveBenchmark.java index b60e0f7e..7e98c10e 100644 --- a/message-encoding/src/jmh-test/java/com/lmax/solana4j/EddsaPointOnCurveBenchmark.java +++ b/message-encoding/src/jmh-test/java/com/lmax/solana4j/encoding/EddsaPointOnCurveBenchmark.java @@ -1,6 +1,5 @@ -package com.lmax.solana4j; +package com.lmax.solana4j.encoding; -import com.lmax.solana4j.util.Ed25519; import com.lmax.solana4j.util.TestKeyPairGenerator; import net.i2p.crypto.eddsa.math.GroupElement; import org.openjdk.jmh.annotations.Benchmark; diff --git a/message-encoding/src/main/java/com/lmax/solana4j/util/Ed25519.java b/message-encoding/src/main/java/com/lmax/solana4j/encoding/Ed25519.java similarity index 96% rename from message-encoding/src/main/java/com/lmax/solana4j/util/Ed25519.java rename to message-encoding/src/main/java/com/lmax/solana4j/encoding/Ed25519.java index 5f92a2a0..ca939ecc 100644 --- a/message-encoding/src/main/java/com/lmax/solana4j/util/Ed25519.java +++ b/message-encoding/src/main/java/com/lmax/solana4j/encoding/Ed25519.java @@ -1,4 +1,4 @@ -package com.lmax.solana4j.util; +package com.lmax.solana4j.encoding; import java.math.BigInteger; @@ -14,7 +14,7 @@ * The Ed25519 curve equation is: * dx^2y^2 + x^2 = y^2 - 1 (mod P), where d is a curve constant. */ -public final class Ed25519 +final class Ed25519 { private static final BigInteger P = new BigInteger("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed", 16); private static final BigInteger D = new BigInteger("52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3", 16); @@ -31,7 +31,7 @@ private Ed25519() * @return true if the point is on the curve, false otherwise. * @throws IllegalArgumentException if the public key byte array is not 32 bytes long. */ - public static boolean isOnCurve(final byte[] publicKeyBytes) + static boolean isOnCurve(final byte[] publicKeyBytes) { if (publicKeyBytes.length != 32) { diff --git a/message-encoding/src/main/java/com/lmax/solana4j/encoding/SolanaProgramDerivedAddress.java b/message-encoding/src/main/java/com/lmax/solana4j/encoding/SolanaProgramDerivedAddress.java index 0b427012..eb2148dc 100644 --- a/message-encoding/src/main/java/com/lmax/solana4j/encoding/SolanaProgramDerivedAddress.java +++ b/message-encoding/src/main/java/com/lmax/solana4j/encoding/SolanaProgramDerivedAddress.java @@ -2,7 +2,6 @@ import com.lmax.solana4j.api.ProgramDerivedAddress; import com.lmax.solana4j.api.PublicKey; -import com.lmax.solana4j.util.Ed25519; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; diff --git a/message-encoding/src/test/java/com/lmax/solana4j/util/Ed25519Test.java b/message-encoding/src/test/java/com/lmax/solana4j/encoding/Ed25519Test.java similarity index 97% rename from message-encoding/src/test/java/com/lmax/solana4j/util/Ed25519Test.java rename to message-encoding/src/test/java/com/lmax/solana4j/encoding/Ed25519Test.java index 8d6d7ca0..a00f5b68 100644 --- a/message-encoding/src/test/java/com/lmax/solana4j/util/Ed25519Test.java +++ b/message-encoding/src/test/java/com/lmax/solana4j/encoding/Ed25519Test.java @@ -1,5 +1,6 @@ -package com.lmax.solana4j.util; +package com.lmax.solana4j.encoding; +import com.lmax.solana4j.util.TestKeyPairGenerator; import net.i2p.crypto.eddsa.math.GroupElement; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test;