Skip to content

Commit 7837a60

Browse files
committed
chore: remove length checks since underlying rust API no longer uses the c-api
1 parent ec8acd1 commit 7837a60

File tree

1 file changed

+0
-50
lines changed

1 file changed

+0
-50
lines changed

bindings/java/java_code/src/main/java/ethereum/cryptography/LibPeerDASKZG.java

-50
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
import java.nio.file.Path;
88
import java.nio.file.StandardCopyOption;
99

10-
// TODO(Note): If the underlying java bindings call into the rust code directly,
11-
// We can remove the length checks in the java code.
12-
1310
public class LibPeerDASKZG implements AutoCloseable{
1411
// These constants were taken from c-kzg
1512
//
@@ -53,65 +50,25 @@ public void destroy() {
5350
}
5451

5552
public byte[] blobToKZGCommitment(byte[] blob) {
56-
// Length checks
57-
if (blob.length != BYTES_PER_BLOB) {
58-
throw new IllegalArgumentException("Invalid blob length");
59-
}
6053
return blobToKZGCommitment(contextPtr, blob);
6154
}
6255

6356
public CellsAndProofs computeCellsAndKZGProofs(byte[] blob) {
64-
// Length checks
65-
if (blob.length != BYTES_PER_BLOB) {
66-
throw new IllegalArgumentException("Invalid blob length");
67-
}
6857
CellsAndProofs cellsAndProofs = computeCellsAndKZGProofs(contextPtr, blob);
6958
return cellsAndProofs;
7059
}
7160

7261
public byte[][] computeCells(byte[] blob) {
73-
// Length checks
74-
if (blob.length != BYTES_PER_BLOB) {
75-
throw new IllegalArgumentException("Invalid blob length");
76-
}
7762
CellsAndProofs cellsAndProofs = computeCellsAndKZGProofs(blob);
7863
return cellsAndProofs.cells;
7964
}
8065

8166
public boolean verifyCellKZGProof(byte[] commitment, long cellID, byte[] cell, byte[] proof) {
82-
// Length checks
83-
if (commitment.length != BYTES_PER_COMMITMENT) {
84-
throw new IllegalArgumentException("Invalid commitment length");
85-
}
86-
if (cell.length != BYTES_PER_CELL) {
87-
throw new IllegalArgumentException("Invalid cell length");
88-
}
89-
if (proof.length != BYTES_PER_PROOF) {
90-
throw new IllegalArgumentException("Invalid proof length");
91-
}
9267
return verifyCellKZGProof(contextPtr, commitment, cellID, cell, proof);
9368
}
9469

9570
public boolean verifyCellKZGProofBatch(byte[][] commitmentsArr, long[] rowIndices, long[] columnIndices, byte[][] cellsArr,
9671
byte[][] proofsArr) {
97-
98-
// Length checks
99-
for (int i = 0; i < commitmentsArr.length; i++) {
100-
if (commitmentsArr[i].length != BYTES_PER_COMMITMENT) {
101-
throw new IllegalArgumentException("Invalid commitment length");
102-
}
103-
}
104-
for (int i = 0; i < proofsArr.length; i++) {
105-
if (proofsArr[i].length != BYTES_PER_PROOF) {
106-
throw new IllegalArgumentException("Invalid proof length");
107-
}
108-
}
109-
for (int i = 0; i < cellsArr.length; i++) {
110-
if (cellsArr[i].length != BYTES_PER_CELL) {
111-
throw new IllegalArgumentException("Invalid cell length");
112-
}
113-
}
114-
11572
return verifyCellKZGProofBatch(contextPtr, commitmentsArr, rowIndices, columnIndices, cellsArr, proofsArr);
11673
}
11774

@@ -120,13 +77,6 @@ public byte[][] recoverAllCells(long[] cellIDs, byte[][] cellsArr) {
12077
}
12178

12279
public CellsAndProofs recoverCellsAndProofs(long[] cellIDs, byte[][] cellsArr) {
123-
// Length checks
124-
for (int i = 0; i < cellsArr.length; i++) {
125-
if (cellsArr[i].length != BYTES_PER_CELL) {
126-
throw new IllegalArgumentException("Invalid cell length");
127-
}
128-
}
129-
13080
return recoverCellsAndProof(contextPtr, cellIDs, cellsArr);
13181
}
13282

0 commit comments

Comments
 (0)