Update java bindings to support YAML ref tests (#166)
* Update java bindings to support YAML ref tests * Clean things up a little * Fix some more nits * Swap comparision to be expected/actual * Add missing input length checks * Move test formats to new directory
This commit is contained in:
parent
54ab82c93b
commit
410eed4db6
|
@ -23,7 +23,7 @@ dependencies {
|
||||||
|
|
||||||
testFixturesImplementation("org.apache.tuweni:tuweni-units:2.3.1")
|
testFixturesImplementation("org.apache.tuweni:tuweni-units:2.3.1")
|
||||||
testFixturesImplementation("com.fasterxml.jackson.core:jackson-databind:2.14.2")
|
testFixturesImplementation("com.fasterxml.jackson.core:jackson-databind:2.14.2")
|
||||||
|
testFixturesImplementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.14.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
spotless {
|
spotless {
|
||||||
|
|
|
@ -193,6 +193,20 @@ JNIEXPORT jbyteArray JNICALL Java_ethereum_ckzg4844_CKZG4844JNI_computeKzgProof(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t blob_size = (size_t)(*env)->GetArrayLength(env, blob);
|
||||||
|
if (blob_size != BYTES_PER_BLOB)
|
||||||
|
{
|
||||||
|
throw_invalid_size_exception(env, "Invalid blob size.", blob_size, BYTES_PER_BLOB);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t z_bytes_size = (size_t)(*env)->GetArrayLength(env, z_bytes);
|
||||||
|
if (z_bytes_size != BYTES_PER_FIELD_ELEMENT)
|
||||||
|
{
|
||||||
|
throw_invalid_size_exception(env, "Invalid z size.", z_bytes_size, BYTES_PER_FIELD_ELEMENT);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Blob *blob_native = (Blob *)(*env)->GetByteArrayElements(env, blob, NULL);
|
Blob *blob_native = (Blob *)(*env)->GetByteArrayElements(env, blob, NULL);
|
||||||
Bytes32 *z_native = (Bytes32 *)(*env)->GetByteArrayElements(env, z_bytes, NULL);
|
Bytes32 *z_native = (Bytes32 *)(*env)->GetByteArrayElements(env, z_bytes, NULL);
|
||||||
|
|
||||||
|
@ -255,6 +269,34 @@ JNIEXPORT jboolean JNICALL Java_ethereum_ckzg4844_CKZG4844JNI_verifyKzgProof(JNI
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t commitment_bytes_size = (size_t)(*env)->GetArrayLength(env, commitment_bytes);
|
||||||
|
if (commitment_bytes_size != BYTES_PER_COMMITMENT)
|
||||||
|
{
|
||||||
|
throw_invalid_size_exception(env, "Invalid commitment size.", commitment_bytes_size, BYTES_PER_COMMITMENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t z_bytes_size = (size_t)(*env)->GetArrayLength(env, z_bytes);
|
||||||
|
if (z_bytes_size != BYTES_PER_FIELD_ELEMENT)
|
||||||
|
{
|
||||||
|
throw_invalid_size_exception(env, "Invalid z size.", z_bytes_size, BYTES_PER_FIELD_ELEMENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t y_bytes_size = (size_t)(*env)->GetArrayLength(env, y_bytes);
|
||||||
|
if (y_bytes_size != BYTES_PER_FIELD_ELEMENT)
|
||||||
|
{
|
||||||
|
throw_invalid_size_exception(env, "Invalid y size.", y_bytes_size, BYTES_PER_FIELD_ELEMENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t proof_bytes_size = (size_t)(*env)->GetArrayLength(env, proof_bytes);
|
||||||
|
if (proof_bytes_size != BYTES_PER_PROOF)
|
||||||
|
{
|
||||||
|
throw_invalid_size_exception(env, "Invalid proof size.", proof_bytes_size, BYTES_PER_PROOF);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Bytes48 *commitment_native = (Bytes48 *)(*env)->GetByteArrayElements(env, commitment_bytes, NULL);
|
Bytes48 *commitment_native = (Bytes48 *)(*env)->GetByteArrayElements(env, commitment_bytes, NULL);
|
||||||
Bytes48 *proof_native = (Bytes48 *)(*env)->GetByteArrayElements(env, proof_bytes, NULL);
|
Bytes48 *proof_native = (Bytes48 *)(*env)->GetByteArrayElements(env, proof_bytes, NULL);
|
||||||
Bytes32 *z_native = (Bytes32 *)(*env)->GetByteArrayElements(env, z_bytes, NULL);
|
Bytes32 *z_native = (Bytes32 *)(*env)->GetByteArrayElements(env, z_bytes, NULL);
|
||||||
|
@ -300,7 +342,7 @@ JNIEXPORT jboolean JNICALL Java_ethereum_ckzg4844_CKZG4844JNI_verifyBlobKzgProof
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t proof_bytes_size = (size_t)(*env)->GetArrayLength(env, proof_bytes);
|
size_t proof_bytes_size = (size_t)(*env)->GetArrayLength(env, proof_bytes);
|
||||||
if (proof_bytes_size != BYTES_PER_COMMITMENT)
|
if (proof_bytes_size != BYTES_PER_PROOF)
|
||||||
{
|
{
|
||||||
throw_invalid_size_exception(env, "Invalid proof size.", proof_bytes_size, BYTES_PER_PROOF);
|
throw_invalid_size_exception(env, "Invalid proof size.", proof_bytes_size, BYTES_PER_PROOF);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -60,6 +60,22 @@ public class CKZG4844JNIBenchmark {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@State(Scope.Benchmark)
|
||||||
|
public static class VerifyKzgProofState {
|
||||||
|
private byte[] commitment;
|
||||||
|
private byte[] z;
|
||||||
|
private byte[] y;
|
||||||
|
private byte[] proof;
|
||||||
|
|
||||||
|
@Setup(Level.Iteration)
|
||||||
|
public void setUp() {
|
||||||
|
commitment = TestUtils.createRandomCommitments(1);
|
||||||
|
z = TestUtils.randomBLSFieldElementBytes();
|
||||||
|
y = TestUtils.randomBLSFieldElementBytes();
|
||||||
|
proof = TestUtils.createRandomProofs(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@State(Scope.Benchmark)
|
@State(Scope.Benchmark)
|
||||||
public static class VerifyBlobKzgProofState {
|
public static class VerifyBlobKzgProofState {
|
||||||
private byte[] blob;
|
private byte[] blob;
|
||||||
|
@ -91,23 +107,6 @@ public class CKZG4844JNIBenchmark {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@State(Scope.Benchmark)
|
|
||||||
public static class VerifyKzgProofState {
|
|
||||||
private byte[] commitment;
|
|
||||||
private byte[] z;
|
|
||||||
private byte[] y;
|
|
||||||
private byte[] proof;
|
|
||||||
|
|
||||||
@Setup
|
|
||||||
public void setUp() {
|
|
||||||
final VerifyKzgProofParameters parameters = TestUtils.getVerifyKzgProofTestVectors().get(2);
|
|
||||||
commitment = parameters.getCommitment();
|
|
||||||
z = parameters.getZ();
|
|
||||||
y = parameters.getY();
|
|
||||||
proof = parameters.getProof();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Setup
|
@Setup
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
CKZG4844JNI.loadTrustedSetup("../../src/trusted_setup.txt");
|
CKZG4844JNI.loadTrustedSetup("../../src/trusted_setup.txt");
|
||||||
|
|
|
@ -4,12 +4,12 @@ import static ethereum.ckzg4844.CKZGException.CKZGError.C_KZG_BADARGS;
|
||||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import ethereum.ckzg4844.CKZG4844JNI.Preset;
|
import ethereum.ckzg4844.CKZG4844JNI.Preset;
|
||||||
import java.nio.file.Files;
|
import ethereum.ckzg4844.test_formats.*;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
@ -38,17 +38,9 @@ public class CKZG4844JNITest {
|
||||||
private static final Map<Preset, String> TRUSTED_SETUP_RESOURCE_BY_PRESET =
|
private static final Map<Preset, String> TRUSTED_SETUP_RESOURCE_BY_PRESET =
|
||||||
Map.of(
|
Map.of(
|
||||||
Preset.MAINNET,
|
Preset.MAINNET,
|
||||||
"/test-vectors/trusted_setup.txt",
|
"/trusted-setups/trusted_setup.txt",
|
||||||
Preset.MINIMAL,
|
Preset.MINIMAL,
|
||||||
"/test-vectors/trusted_setup_4.txt");
|
"/trusted-setups/trusted_setup_4.txt");
|
||||||
|
|
||||||
private static final String BLOB_TO_KZG_COMMITMENT_TESTS = "../../tests/blob_to_kzg_commitment/";
|
|
||||||
private static final String COMPUTE_KZG_PROOF_TESTS = "../../tests/compute_kzg_proof/";
|
|
||||||
private static final String COMPUTE_BLOB_KZG_PROOF_TESTS = "../../tests/compute_blob_kzg_proof/";
|
|
||||||
private static final String VERIFY_KZG_PROOF_TESTS = "../../tests/verify_kzg_proof/";
|
|
||||||
private static final String VERIFY_BLOB_KZG_PROOF_TESTS = "../../tests/verify_blob_kzg_proof/";
|
|
||||||
private static final String VERIFY_BLOB_KZG_PROOF_BATCH_TESTS =
|
|
||||||
"../../tests/verify_blob_kzg_proof_batch/";
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
PRESET =
|
PRESET =
|
||||||
|
@ -59,144 +51,97 @@ public class CKZG4844JNITest {
|
||||||
CKZG4844JNI.loadNativeLibrary(PRESET);
|
CKZG4844JNI.loadNativeLibrary(PRESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void blobToKzgCommitmentTests() {
|
@MethodSource("getBlobToKzgCommitmentTests")
|
||||||
|
public void blobToKzgCommitmentTests(final BlobToKzgCommitmentTest test) {
|
||||||
if (PRESET != Preset.MAINNET) return;
|
if (PRESET != Preset.MAINNET) return;
|
||||||
loadTrustedSetup();
|
|
||||||
|
|
||||||
for (String test : TestUtils.getFiles(BLOB_TO_KZG_COMMITMENT_TESTS)) {
|
try {
|
||||||
byte[] blob = TestUtils.getBytes(Paths.get(test, "blob.txt"));
|
byte[] commitment = CKZG4844JNI.blobToKzgCommitment(test.getInput().getBlob());
|
||||||
try {
|
assertArrayEquals(test.getOutput(), commitment);
|
||||||
byte[] commitment = CKZG4844JNI.blobToKzgCommitment(blob);
|
} catch (CKZGException ex) {
|
||||||
byte[] expectedCommitment = TestUtils.getBytes(Paths.get(test, "commitment.txt"));
|
assertNull(test.getOutput());
|
||||||
assertArrayEquals(commitment, expectedCommitment);
|
|
||||||
} catch (CKZGException ex) {
|
|
||||||
assertFalse(Files.exists(Paths.get(test, "commitment.txt")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CKZG4844JNI.freeTrustedSetup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void computeKzgProofTests() {
|
@MethodSource("getComputeKzgProofTests")
|
||||||
|
public void computeKzgProofTests(final ComputeKzgProofTest test) {
|
||||||
if (PRESET != Preset.MAINNET) return;
|
if (PRESET != Preset.MAINNET) return;
|
||||||
loadTrustedSetup();
|
|
||||||
|
|
||||||
for (String test : TestUtils.getFiles(COMPUTE_KZG_PROOF_TESTS)) {
|
try {
|
||||||
byte[] blob = TestUtils.getBytes(Paths.get(test, "blob.txt"));
|
byte[] proof = CKZG4844JNI.computeKzgProof(test.getInput().getBlob(), test.getInput().getZ());
|
||||||
byte[] inputPoint = TestUtils.getBytes(Paths.get(test, "input_point.txt"));
|
assertArrayEquals(test.getOutput(), proof);
|
||||||
try {
|
} catch (CKZGException ex) {
|
||||||
byte[] proof = CKZG4844JNI.computeKzgProof(blob, inputPoint);
|
assertNull(test.getOutput());
|
||||||
byte[] expectedProof = TestUtils.getBytes(Paths.get(test, "proof.txt"));
|
|
||||||
assertArrayEquals(proof, expectedProof);
|
|
||||||
} catch (CKZGException ex) {
|
|
||||||
assertFalse(Files.exists(Paths.get(test, "proof.txt")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CKZG4844JNI.freeTrustedSetup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void computeBlobKzgProofTests() {
|
@MethodSource("getComputeBlobKzgProofTests")
|
||||||
|
public void computeBlobKzgProofTests(final ComputeBlobKzgProofTest test) {
|
||||||
if (PRESET != Preset.MAINNET) return;
|
if (PRESET != Preset.MAINNET) return;
|
||||||
loadTrustedSetup();
|
|
||||||
|
|
||||||
for (String test : TestUtils.getFiles(COMPUTE_BLOB_KZG_PROOF_TESTS)) {
|
try {
|
||||||
byte[] blob = TestUtils.getBytes(Paths.get(test, "blob.txt"));
|
byte[] proof = CKZG4844JNI.computeBlobKzgProof(test.getInput().getBlob());
|
||||||
try {
|
assertArrayEquals(test.getOutput(), proof);
|
||||||
byte[] proof = CKZG4844JNI.computeBlobKzgProof(blob);
|
} catch (CKZGException ex) {
|
||||||
byte[] expectedProof = TestUtils.getBytes(Paths.get(test, "proof.txt"));
|
assertNull(test.getOutput());
|
||||||
assertArrayEquals(proof, expectedProof);
|
|
||||||
} catch (CKZGException ex) {
|
|
||||||
assertFalse(Files.exists(Paths.get(test, "proof.txt")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CKZG4844JNI.freeTrustedSetup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void verifyKzgProofTests() {
|
@MethodSource("getVerifyKzgProofTests")
|
||||||
|
public void verifyKzgProofTests(final VerifyKzgProofTest test) {
|
||||||
if (PRESET != Preset.MAINNET) return;
|
if (PRESET != Preset.MAINNET) return;
|
||||||
loadTrustedSetup();
|
|
||||||
|
|
||||||
for (String test : TestUtils.getFiles(VERIFY_KZG_PROOF_TESTS)) {
|
try {
|
||||||
byte[] commitment = TestUtils.getBytes(Paths.get(test, "commitment.txt"));
|
boolean valid =
|
||||||
byte[] inputPoint = TestUtils.getBytes(Paths.get(test, "input_point.txt"));
|
CKZG4844JNI.verifyKzgProof(
|
||||||
byte[] claimedValue = TestUtils.getBytes(Paths.get(test, "claimed_value.txt"));
|
test.getInput().getCommitment(),
|
||||||
byte[] proof = TestUtils.getBytes(Paths.get(test, "proof.txt"));
|
test.getInput().getZ(),
|
||||||
try {
|
test.getInput().getY(),
|
||||||
boolean ok = CKZG4844JNI.verifyKzgProof(commitment, inputPoint, claimedValue, proof);
|
test.getInput().getProof());
|
||||||
boolean expectedOk = TestUtils.getBoolean(Paths.get(test, "ok.txt"));
|
assertEquals(test.getOutput(), valid);
|
||||||
assertEquals(ok, expectedOk);
|
} catch (CKZGException ex) {
|
||||||
} catch (CKZGException ex) {
|
assertNull(test.getOutput());
|
||||||
assertFalse(Files.exists(Paths.get(test, "ok.txt")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CKZG4844JNI.freeTrustedSetup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void verifyBlobKzgProofTests() {
|
@MethodSource("getVerifyBlobKzgProofTests")
|
||||||
|
public void verifyBlobKzgProofTests(final VerifyBlobKzgProofTest test) {
|
||||||
if (PRESET != Preset.MAINNET) return;
|
if (PRESET != Preset.MAINNET) return;
|
||||||
loadTrustedSetup();
|
|
||||||
|
|
||||||
for (String test : TestUtils.getFiles(VERIFY_BLOB_KZG_PROOF_TESTS)) {
|
try {
|
||||||
byte[] blob = TestUtils.getBytes(Paths.get(test, "blob.txt"));
|
boolean valid =
|
||||||
byte[] commitment = TestUtils.getBytes(Paths.get(test, "commitment.txt"));
|
CKZG4844JNI.verifyBlobKzgProof(
|
||||||
byte[] proof = TestUtils.getBytes(Paths.get(test, "proof.txt"));
|
test.getInput().getBlob(),
|
||||||
try {
|
test.getInput().getCommitment(),
|
||||||
boolean ok = CKZG4844JNI.verifyBlobKzgProof(blob, commitment, proof);
|
test.getInput().getProof());
|
||||||
boolean expectedOk = TestUtils.getBoolean(Paths.get(test, "ok.txt"));
|
assertEquals(test.getOutput(), valid);
|
||||||
assertEquals(ok, expectedOk);
|
} catch (CKZGException ex) {
|
||||||
} catch (CKZGException ex) {
|
assertNull(test.getOutput());
|
||||||
assertFalse(Files.exists(Paths.get(test, "ok.txt")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CKZG4844JNI.freeTrustedSetup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void verifyBlobKzgProofBatchTests() {
|
@MethodSource("getVerifyBlobKzgProofBatchTests")
|
||||||
|
public void verifyBlobKzgProofBatchTests(final VerifyBlobKzgProofBatchTest test) {
|
||||||
if (PRESET != Preset.MAINNET) return;
|
if (PRESET != Preset.MAINNET) return;
|
||||||
loadTrustedSetup();
|
|
||||||
|
|
||||||
for (String test : TestUtils.getFiles(VERIFY_BLOB_KZG_PROOF_BATCH_TESTS)) {
|
try {
|
||||||
byte[] blobs =
|
int count = test.getInput().getBlobs().length / CKZG4844JNI.getBytesPerBlob();
|
||||||
TestUtils.flatten(
|
boolean valid =
|
||||||
TestUtils.getFiles(Paths.get(test, "blobs").toString()).stream()
|
CKZG4844JNI.verifyBlobKzgProofBatch(
|
||||||
.map(Paths::get)
|
test.getInput().getBlobs(),
|
||||||
.map(TestUtils::getBytes)
|
test.getInput().getCommitments(),
|
||||||
.toArray(byte[][]::new));
|
test.getInput().getProofs(),
|
||||||
byte[] commitments =
|
count);
|
||||||
TestUtils.flatten(
|
assertEquals(test.getOutput(), valid);
|
||||||
TestUtils.getFiles(Paths.get(test, "commitments").toString()).stream()
|
} catch (CKZGException ex) {
|
||||||
.map(Paths::get)
|
assertNull(test.getOutput());
|
||||||
.map(TestUtils::getBytes)
|
|
||||||
.toArray(byte[][]::new));
|
|
||||||
byte[] proofs =
|
|
||||||
TestUtils.flatten(
|
|
||||||
TestUtils.getFiles(Paths.get(test, "proofs").toString()).stream()
|
|
||||||
.map(Paths::get)
|
|
||||||
.map(TestUtils::getBytes)
|
|
||||||
.toArray(byte[][]::new));
|
|
||||||
|
|
||||||
try {
|
|
||||||
boolean ok =
|
|
||||||
CKZG4844JNI.verifyBlobKzgProofBatch(
|
|
||||||
blobs, commitments, proofs, blobs.length / CKZG4844JNI.getBytesPerBlob());
|
|
||||||
boolean expectedOk = TestUtils.getBoolean(Paths.get(test, "ok.txt"));
|
|
||||||
assertEquals(ok, expectedOk);
|
|
||||||
} catch (CKZGException ex) {
|
|
||||||
assertFalse(Files.exists(Paths.get(test, "ok.txt")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CKZG4844JNI.freeTrustedSetup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -207,17 +152,6 @@ public class CKZG4844JNITest {
|
||||||
CKZG4844JNI.getBytesPerBlob());
|
CKZG4844JNI.getBytesPerBlob());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest(name = "{index}")
|
|
||||||
@MethodSource("getVerifyKzgProofTestVectors")
|
|
||||||
public void testVerifyKzgProof(final VerifyKzgProofParameters parameters) {
|
|
||||||
assertTrue(
|
|
||||||
CKZG4844JNI.verifyKzgProof(
|
|
||||||
parameters.getCommitment(),
|
|
||||||
parameters.getZ(),
|
|
||||||
parameters.getY(),
|
|
||||||
parameters.getProof()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@EnumSource(TrustedSetupSource.class)
|
@EnumSource(TrustedSetupSource.class)
|
||||||
public void testVerifyBlobKzgProofBatch(final TrustedSetupSource trustedSetupSource) {
|
public void testVerifyBlobKzgProofBatch(final TrustedSetupSource trustedSetupSource) {
|
||||||
|
@ -458,8 +392,34 @@ public class CKZG4844JNITest {
|
||||||
TRUSTED_SETUP_RESOURCE_BY_PRESET.get(PRESET), CKZG4844JNITest.class);
|
TRUSTED_SETUP_RESOURCE_BY_PRESET.get(PRESET), CKZG4844JNITest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Stream<VerifyKzgProofParameters> getVerifyKzgProofTestVectors() {
|
private static Stream<BlobToKzgCommitmentTest> getBlobToKzgCommitmentTests() {
|
||||||
loadTrustedSetup();
|
loadTrustedSetup();
|
||||||
return TestUtils.getVerifyKzgProofTestVectors().stream().onClose(CKZG4844JNI::freeTrustedSetup);
|
return TestUtils.getBlobToKzgCommitmentTests().stream().onClose(CKZG4844JNI::freeTrustedSetup);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Stream<ComputeKzgProofTest> getComputeKzgProofTests() {
|
||||||
|
loadTrustedSetup();
|
||||||
|
return TestUtils.getComputeKzgProofTests().stream().onClose(CKZG4844JNI::freeTrustedSetup);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Stream<ComputeBlobKzgProofTest> getComputeBlobKzgProofTests() {
|
||||||
|
loadTrustedSetup();
|
||||||
|
return TestUtils.getComputeBlobKzgProofTests().stream().onClose(CKZG4844JNI::freeTrustedSetup);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Stream<VerifyKzgProofTest> getVerifyKzgProofTests() {
|
||||||
|
loadTrustedSetup();
|
||||||
|
return TestUtils.getVerifyKzgProofTests().stream().onClose(CKZG4844JNI::freeTrustedSetup);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Stream<VerifyBlobKzgProofTest> getVerifyBlobKzgProofTests() {
|
||||||
|
loadTrustedSetup();
|
||||||
|
return TestUtils.getVerifyBlobKzgProofTests().stream().onClose(CKZG4844JNI::freeTrustedSetup);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Stream<VerifyBlobKzgProofBatchTest> getVerifyBlobKzgProofBatchTests() {
|
||||||
|
loadTrustedSetup();
|
||||||
|
return TestUtils.getVerifyBlobKzgProofBatchTests().stream()
|
||||||
|
.onClose(CKZG4844JNI::freeTrustedSetup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package ethereum.ckzg4844;
|
package ethereum.ckzg4844;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
||||||
|
import ethereum.ckzg4844.test_formats.*;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -14,6 +14,7 @@ import java.nio.ByteOrder;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -21,15 +22,22 @@ import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import org.apache.tuweni.bytes.Bytes;
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
import org.apache.tuweni.bytes.Bytes32;
|
|
||||||
import org.apache.tuweni.units.bigints.UInt256;
|
import org.apache.tuweni.units.bigints.UInt256;
|
||||||
|
|
||||||
public class TestUtils {
|
public class TestUtils {
|
||||||
|
|
||||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(new YAMLFactory());
|
||||||
|
|
||||||
private static final Random RANDOM = new Random();
|
private static final Random RANDOM = new Random();
|
||||||
|
|
||||||
|
private static final String BLOB_TO_KZG_COMMITMENT_TESTS = "../../tests/blob_to_kzg_commitment/";
|
||||||
|
private static final String COMPUTE_KZG_PROOF_TESTS = "../../tests/compute_kzg_proof/";
|
||||||
|
private static final String COMPUTE_BLOB_KZG_PROOF_TESTS = "../../tests/compute_blob_kzg_proof/";
|
||||||
|
private static final String VERIFY_KZG_PROOF_TESTS = "../../tests/verify_kzg_proof/";
|
||||||
|
private static final String VERIFY_BLOB_KZG_PROOF_TESTS = "../../tests/verify_blob_kzg_proof/";
|
||||||
|
private static final String VERIFY_BLOB_KZG_PROOF_BATCH_TESTS =
|
||||||
|
"../../tests/verify_blob_kzg_proof_batch/";
|
||||||
|
|
||||||
public static byte[] flatten(final byte[]... bytes) {
|
public static byte[] flatten(final byte[]... bytes) {
|
||||||
final int capacity = Arrays.stream(bytes).mapToInt(b -> b.length).sum();
|
final int capacity = Arrays.stream(bytes).mapToInt(b -> b.length).sum();
|
||||||
final ByteBuffer buffer = ByteBuffer.allocate(capacity);
|
final ByteBuffer buffer = ByteBuffer.allocate(capacity);
|
||||||
|
@ -81,37 +89,103 @@ public class TestUtils {
|
||||||
return flatten(blob);
|
return flatten(blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static List<BlobToKzgCommitmentTest> getBlobToKzgCommitmentTests() {
|
||||||
* Generated using <a
|
final Stream.Builder<BlobToKzgCommitmentTest> tests = Stream.builder();
|
||||||
* href="https://github.com/crate-crypto/proto-danksharding-fuzzy-test/">proto-danksharding-fuzzy-test</a>
|
|
||||||
*/
|
try {
|
||||||
public static List<VerifyKzgProofParameters> getVerifyKzgProofTestVectors() {
|
for (String testFile : getTestFiles(BLOB_TO_KZG_COMMITMENT_TESTS)) {
|
||||||
final JsonNode jsonNode;
|
String data = Files.readString(Path.of(testFile));
|
||||||
try (final InputStream testVectors =
|
BlobToKzgCommitmentTest test = OBJECT_MAPPER.readValue(data, BlobToKzgCommitmentTest.class);
|
||||||
readResource("test-vectors/public_verify_kzg_proof.json")) {
|
tests.add(test);
|
||||||
jsonNode = OBJECT_MAPPER.readTree(testVectors);
|
}
|
||||||
} catch (final IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new UncheckedIOException(ex);
|
throw new UncheckedIOException(ex);
|
||||||
}
|
}
|
||||||
final ArrayNode testCases = (ArrayNode) jsonNode.get("TestCases");
|
|
||||||
final Stream.Builder<VerifyKzgProofParameters> testVectors = Stream.builder();
|
return tests.build().collect(Collectors.toList());
|
||||||
testVectors.add(VerifyKzgProofParameters.ZERO);
|
}
|
||||||
IntStream.range(0, jsonNode.get("NumTestCases").asInt())
|
|
||||||
.mapToObj(
|
public static List<ComputeKzgProofTest> getComputeKzgProofTests() {
|
||||||
i -> {
|
final Stream.Builder<ComputeKzgProofTest> tests = Stream.builder();
|
||||||
final JsonNode testCase = testCases.get(i);
|
|
||||||
final Bytes32 z = Bytes32.fromHexString(testCase.get("InputPoint").asText());
|
try {
|
||||||
final Bytes32 y = Bytes32.fromHexString(testCase.get("ClaimedValue").asText());
|
for (String testFile : getTestFiles(COMPUTE_KZG_PROOF_TESTS)) {
|
||||||
final Bytes commitment =
|
String jsonData = Files.readString(Path.of(testFile));
|
||||||
Bytes.fromHexString(
|
ComputeKzgProofTest test = OBJECT_MAPPER.readValue(jsonData, ComputeKzgProofTest.class);
|
||||||
testCase.get("Commitment").asText(), CKZG4844JNI.BYTES_PER_COMMITMENT);
|
tests.add(test);
|
||||||
final Bytes proof =
|
}
|
||||||
Bytes.fromHexString(testCase.get("Proof").asText(), CKZG4844JNI.BYTES_PER_PROOF);
|
} catch (IOException ex) {
|
||||||
return new VerifyKzgProofParameters(
|
throw new UncheckedIOException(ex);
|
||||||
commitment.toArray(), z.toArray(), y.toArray(), proof.toArray());
|
}
|
||||||
})
|
|
||||||
.forEach(testVectors::add);
|
return tests.build().collect(Collectors.toList());
|
||||||
return testVectors.build().collect(Collectors.toList());
|
}
|
||||||
|
|
||||||
|
public static List<ComputeBlobKzgProofTest> getComputeBlobKzgProofTests() {
|
||||||
|
final Stream.Builder<ComputeBlobKzgProofTest> tests = Stream.builder();
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (String testFile : getTestFiles(COMPUTE_BLOB_KZG_PROOF_TESTS)) {
|
||||||
|
String jsonData = Files.readString(Path.of(testFile));
|
||||||
|
ComputeBlobKzgProofTest test =
|
||||||
|
OBJECT_MAPPER.readValue(jsonData, ComputeBlobKzgProofTest.class);
|
||||||
|
tests.add(test);
|
||||||
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new UncheckedIOException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tests.build().collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<VerifyKzgProofTest> getVerifyKzgProofTests() {
|
||||||
|
final Stream.Builder<VerifyKzgProofTest> tests = Stream.builder();
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (String testFile : getTestFiles(VERIFY_KZG_PROOF_TESTS)) {
|
||||||
|
String jsonData = Files.readString(Path.of(testFile));
|
||||||
|
VerifyKzgProofTest test = OBJECT_MAPPER.readValue(jsonData, VerifyKzgProofTest.class);
|
||||||
|
tests.add(test);
|
||||||
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new UncheckedIOException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tests.build().collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<VerifyBlobKzgProofTest> getVerifyBlobKzgProofTests() {
|
||||||
|
final Stream.Builder<VerifyBlobKzgProofTest> tests = Stream.builder();
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (String testFile : getTestFiles(VERIFY_BLOB_KZG_PROOF_TESTS)) {
|
||||||
|
String jsonData = Files.readString(Path.of(testFile));
|
||||||
|
VerifyBlobKzgProofTest test =
|
||||||
|
OBJECT_MAPPER.readValue(jsonData, VerifyBlobKzgProofTest.class);
|
||||||
|
tests.add(test);
|
||||||
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new UncheckedIOException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tests.build().collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<VerifyBlobKzgProofBatchTest> getVerifyBlobKzgProofBatchTests() {
|
||||||
|
final Stream.Builder<VerifyBlobKzgProofBatchTest> tests = Stream.builder();
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (String testFile : getTestFiles(VERIFY_BLOB_KZG_PROOF_BATCH_TESTS)) {
|
||||||
|
String jsonData = Files.readString(Path.of(testFile));
|
||||||
|
VerifyBlobKzgProofBatchTest test =
|
||||||
|
OBJECT_MAPPER.readValue(jsonData, VerifyBlobKzgProofBatchTest.class);
|
||||||
|
tests.add(test);
|
||||||
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new UncheckedIOException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tests.build().collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LoadTrustedSetupParameters createLoadTrustedSetupParameters(
|
public static LoadTrustedSetupParameters createLoadTrustedSetupParameters(
|
||||||
|
@ -152,22 +226,6 @@ public class TestUtils {
|
||||||
return Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
|
return Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] getBytes(Path path) {
|
|
||||||
try {
|
|
||||||
return Bytes.fromHexString(Files.readString(path)).toArray();
|
|
||||||
} catch (final IOException ex) {
|
|
||||||
throw new UncheckedIOException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getBoolean(Path path) {
|
|
||||||
try {
|
|
||||||
return Files.readString(path).contains("true");
|
|
||||||
} catch (final IOException ex) {
|
|
||||||
throw new UncheckedIOException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getFiles(String path) {
|
public static List<String> getFiles(String path) {
|
||||||
try {
|
try {
|
||||||
try (Stream<Path> stream = Files.list(Paths.get(path))) {
|
try (Stream<Path> stream = Files.list(Paths.get(path))) {
|
||||||
|
@ -177,4 +235,14 @@ public class TestUtils {
|
||||||
throw new UncheckedIOException(ex);
|
throw new UncheckedIOException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> getTestFiles(String path) {
|
||||||
|
List<String> testFiles = new ArrayList<>();
|
||||||
|
for (final String suite : getFiles(path)) {
|
||||||
|
for (final String test : getFiles(suite)) {
|
||||||
|
testFiles.addAll(getFiles(test));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return testFiles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
package ethereum.ckzg4844;
|
|
||||||
|
|
||||||
public class VerifyKzgProofParameters {
|
|
||||||
|
|
||||||
public static final VerifyKzgProofParameters ZERO;
|
|
||||||
|
|
||||||
static {
|
|
||||||
final byte[] commitment = new byte[CKZG4844JNI.BYTES_PER_COMMITMENT];
|
|
||||||
commitment[0] = (byte) 0xc0;
|
|
||||||
final byte[] z = new byte[32];
|
|
||||||
final byte[] y = new byte[32];
|
|
||||||
final byte[] proof = new byte[CKZG4844JNI.BYTES_PER_PROOF];
|
|
||||||
proof[0] = (byte) 0xc0;
|
|
||||||
ZERO = new VerifyKzgProofParameters(commitment, z, y, proof);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final byte[] commitment;
|
|
||||||
private final byte[] z;
|
|
||||||
private final byte[] y;
|
|
||||||
private final byte[] proof;
|
|
||||||
|
|
||||||
public VerifyKzgProofParameters(
|
|
||||||
final byte[] commitment, final byte[] z, final byte[] y, final byte[] proof) {
|
|
||||||
this.commitment = commitment;
|
|
||||||
this.z = z;
|
|
||||||
this.y = y;
|
|
||||||
this.proof = proof;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getCommitment() {
|
|
||||||
return commitment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getZ() {
|
|
||||||
return z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getProof() {
|
|
||||||
return proof;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package ethereum.ckzg4844.test_formats;
|
||||||
|
|
||||||
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
|
|
||||||
|
public class BlobToKzgCommitmentTest {
|
||||||
|
public static class Input {
|
||||||
|
private String blob;
|
||||||
|
|
||||||
|
public byte[] getBlob() {
|
||||||
|
return Bytes.fromHexString(blob).toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Input input;
|
||||||
|
private String output;
|
||||||
|
|
||||||
|
public Input getInput() {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getOutput() {
|
||||||
|
if (output == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Bytes.fromHexString(output).toArray();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package ethereum.ckzg4844.test_formats;
|
||||||
|
|
||||||
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
|
|
||||||
|
public class ComputeBlobKzgProofTest {
|
||||||
|
public static class Input {
|
||||||
|
private String blob;
|
||||||
|
|
||||||
|
public byte[] getBlob() {
|
||||||
|
return Bytes.fromHexString(blob).toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Input input;
|
||||||
|
private String output;
|
||||||
|
|
||||||
|
public Input getInput() {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getOutput() {
|
||||||
|
if (output == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Bytes.fromHexString(output).toArray();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package ethereum.ckzg4844.test_formats;
|
||||||
|
|
||||||
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
|
|
||||||
|
public class ComputeKzgProofTest {
|
||||||
|
public static class Input {
|
||||||
|
private String blob;
|
||||||
|
private String z;
|
||||||
|
|
||||||
|
public byte[] getBlob() {
|
||||||
|
return Bytes.fromHexString(blob).toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getZ() {
|
||||||
|
return Bytes.fromHexString(z).toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Input input;
|
||||||
|
private String output;
|
||||||
|
|
||||||
|
public Input getInput() {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getOutput() {
|
||||||
|
if (output == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Bytes.fromHexString(output).toArray();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package ethereum.ckzg4844.test_formats;
|
||||||
|
|
||||||
|
import ethereum.ckzg4844.TestUtils;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
|
|
||||||
|
public class VerifyBlobKzgProofBatchTest {
|
||||||
|
public static class Input {
|
||||||
|
private List<String> blobs;
|
||||||
|
private List<String> commitments;
|
||||||
|
private List<String> proofs;
|
||||||
|
|
||||||
|
public byte[] getBlobs() {
|
||||||
|
return TestUtils.flatten(
|
||||||
|
blobs.stream()
|
||||||
|
.map(Bytes::fromHexString)
|
||||||
|
.map(Bytes::toArray)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
.toArray(byte[][]::new));
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getCommitments() {
|
||||||
|
return TestUtils.flatten(
|
||||||
|
commitments.stream()
|
||||||
|
.map(Bytes::fromHexString)
|
||||||
|
.map(Bytes::toArray)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
.toArray(byte[][]::new));
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getProofs() {
|
||||||
|
return TestUtils.flatten(
|
||||||
|
proofs.stream()
|
||||||
|
.map(Bytes::fromHexString)
|
||||||
|
.map(Bytes::toArray)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
.toArray(byte[][]::new));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Input input;
|
||||||
|
private Boolean output;
|
||||||
|
|
||||||
|
public Input getInput() {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getOutput() {
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package ethereum.ckzg4844.test_formats;
|
||||||
|
|
||||||
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
|
|
||||||
|
public class VerifyBlobKzgProofTest {
|
||||||
|
public static class Input {
|
||||||
|
private String blob;
|
||||||
|
private String commitment;
|
||||||
|
private String proof;
|
||||||
|
|
||||||
|
public byte[] getBlob() {
|
||||||
|
return Bytes.fromHexString(blob).toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getCommitment() {
|
||||||
|
return Bytes.fromHexString(commitment).toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getProof() {
|
||||||
|
return Bytes.fromHexString(proof).toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Input input;
|
||||||
|
private Boolean output;
|
||||||
|
|
||||||
|
public Input getInput() {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getOutput() {
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package ethereum.ckzg4844.test_formats;
|
||||||
|
|
||||||
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
|
|
||||||
|
public class VerifyKzgProofTest {
|
||||||
|
public static class Input {
|
||||||
|
private String commitment;
|
||||||
|
private String z;
|
||||||
|
private String y;
|
||||||
|
private String proof;
|
||||||
|
|
||||||
|
public byte[] getCommitment() {
|
||||||
|
return Bytes.fromHexString(commitment).toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getZ() {
|
||||||
|
return Bytes.fromHexString(z).toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getY() {
|
||||||
|
return Bytes.fromHexString(y).toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getProof() {
|
||||||
|
return Bytes.fromHexString(proof).toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Input input;
|
||||||
|
private Boolean output;
|
||||||
|
|
||||||
|
public Input getInput() {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getOutput() {
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue