add fake proof test

This commit is contained in:
Stefan Bratanov 2022-11-24 21:34:52 +00:00
parent c944251ca6
commit f386e524c5
1 changed files with 9 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ -35,6 +36,9 @@ public class CKZg4844JNITest {
assertTrue(CKzg4844JNI.verifyAggregateKzgProof(blobs, commitments, 2, proof));
final byte[] fakeProof = createRandomProof();
assertFalse(CKzg4844JNI.verifyAggregateKzgProof(blobs, commitments, 2, fakeProof));
CKzg4844JNI.freeTrustedSetup();
}
@ -100,6 +104,11 @@ public class CKZg4844JNITest {
return blob;
}
private byte[] createRandomProof() {
final byte[] blob = createRandomBlob();
return CKzg4844JNI.computeAggregateKzgProof(blob, 1);
}
private byte[] flatten(byte[]... bytes) {
final int capacity = Arrays.stream(bytes).mapToInt(b -> b.length).sum();
final ByteBuffer buffer = ByteBuffer.allocate(capacity);