Skip to content

Commit f270315

Browse files
committed
Merge remote-tracking branch 'origin/master' into kw/switch-node-to-using-release-file
2 parents e1d115a + 5023fc2 commit f270315

File tree

58 files changed

+1121
-355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1121
-355
lines changed

.cargo/config.node.cross.toml

-5
This file was deleted.

bindings/c/src/lib.rs

+10-15
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,11 @@ fn verification_result_to_bool_cresult(
212212
/// will be created.
213213
///
214214
/// - The caller must ensure that the pointers are valid.
215-
/// - The caller must ensure that `row_commitments` points to a region of memory that is at least `row_commitments_length` commitments
215+
/// - The caller must ensure that `commitments` points to a region of memory that is at least `commitments_length` commitments
216216
/// and that each commitment is at least `BYTES_PER_COMMITMENT` bytes.
217217
/// - The caller must ensure that `row_indices` points to a region of memory that is at least `num_cells` elements
218218
/// and that each element is 8 bytes.
219-
/// - The caller must ensure that `column_indices` points to a region of memory that is at least `num_cells` elements
219+
/// - The caller must ensure that `cell_indices` points to a region of memory that is at least `num_cells` elements
220220
/// and that each element is 8 bytes.
221221
/// - The caller must ensure that `cells` points to a region of memory that is at least `cells_length` proof and
222222
/// that each cell is at least `BYTES_PER_CELL` bytes
@@ -233,14 +233,11 @@ fn verification_result_to_bool_cresult(
233233
pub extern "C" fn verify_cell_kzg_proof_batch(
234234
ctx: *const DASContext,
235235

236-
row_commitments_length: u64,
237-
row_commitments: *const *const u8,
236+
commitments_length: u64,
237+
commitments: *const *const u8,
238238

239-
row_indices_length: u64,
240-
row_indices: *const u64,
241-
242-
column_indices_length: u64,
243-
column_indices: *const u64,
239+
cell_indices_length: u64,
240+
cell_indices: *const u64,
244241

245242
cells_length: u64,
246243
cells: *const *const u8,
@@ -252,12 +249,10 @@ pub extern "C" fn verify_cell_kzg_proof_batch(
252249
) -> CResult {
253250
match _verify_cell_kzg_proof_batch(
254251
ctx,
255-
row_commitments_length,
256-
row_commitments,
257-
row_indices_length,
258-
row_indices,
259-
column_indices_length,
260-
column_indices,
252+
commitments_length,
253+
commitments,
254+
cell_indices_length,
255+
cell_indices,
261256
cells_length,
262257
cells,
263258
proofs_length,

bindings/c/src/verify_cells_and_kzg_proofs_batch.rs

+10-20
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@ use rust_eth_kzg::constants::{BYTES_PER_CELL, BYTES_PER_COMMITMENT};
66
pub(crate) fn _verify_cell_kzg_proof_batch(
77
ctx: *const DASContext,
88

9-
row_commitments_length: u64,
10-
row_commitments: *const *const u8,
9+
commitments_length: u64,
10+
commitments: *const *const u8,
1111

12-
row_indices_length: u64,
13-
row_indices: *const u64,
14-
15-
column_indices_length: u64,
16-
column_indices: *const u64,
12+
cell_indices_length: u64,
13+
cell_indices: *const u64,
1714

1815
cells_length: u64,
1916
cells: *const *const u8,
@@ -44,26 +41,19 @@ pub(crate) fn _verify_cell_kzg_proof_batch(
4441
// Dereference the input pointers
4542
//
4643
let ctx = deref_const(ctx).inner();
47-
let row_commitments = ptr_ptr_to_vec_slice_const::<BYTES_PER_COMMITMENT>(
48-
row_commitments,
49-
row_commitments_length as usize,
44+
let commitments = ptr_ptr_to_vec_slice_const::<BYTES_PER_COMMITMENT>(
45+
commitments,
46+
commitments_length as usize,
5047
);
51-
let row_indices = create_slice_view(row_indices, row_indices_length as usize);
52-
let column_indices = create_slice_view(column_indices, column_indices_length as usize);
48+
let cell_indices = create_slice_view(cell_indices, cell_indices_length as usize);
5349
let cells = ptr_ptr_to_vec_slice_const::<BYTES_PER_CELL>(cells, cells_length as usize);
5450
let proofs = ptr_ptr_to_vec_slice_const::<BYTES_PER_COMMITMENT>(proofs, proofs_length as usize);
5551
let verified = deref_mut(verified);
5652

5753
// Computation
5854
//
59-
let verification_result = ctx.verify_cell_kzg_proof_batch(
60-
row_commitments,
61-
// TODO: conversion to a vector should not be needed
62-
row_indices.to_vec(),
63-
column_indices.to_vec(),
64-
cells,
65-
proofs,
66-
);
55+
let verification_result =
56+
ctx.verify_cell_kzg_proof_batch(commitments, cell_indices.to_vec(), cells, proofs);
6757

6858
// Write to output
6959
let proof_is_valid = verification_result_to_bool_cresult(verification_result)?;

bindings/csharp/csharp_code/EthKZG.bindings/ethkzg.cs

+9-10
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public unsafe (byte[][], byte[][]) ComputeCellsAndKZGProofs(byte[] blob)
111111
return (outCells, outProofs);
112112
}
113113

114-
public bool VerifyCellKZGProofBatch(byte[][] rowCommitments, ulong[] rowIndices, ulong[] columnIndices, byte[][] cells, byte[][] proofs)
114+
public bool VerifyCellKZGProofBatch(byte[][] commitments, ulong[] cellIndices, byte[][] cells, byte[][] proofs)
115115
{
116116

117117
// Length checks
@@ -131,19 +131,19 @@ public bool VerifyCellKZGProofBatch(byte[][] rowCommitments, ulong[] rowIndices,
131131
}
132132
}
133133

134-
for (int i = 0; i < rowCommitments.Length; i++)
134+
for (int i = 0; i < commitments.Length; i++)
135135
{
136-
if (rowCommitments[i].Length != BytesPerCommitment)
136+
if (commitments[i].Length != BytesPerCommitment)
137137
{
138138
throw new ArgumentException($"commitments at index {i} has an invalid length");
139139
}
140140
}
141141

142142
int numCells = cells.Length;
143143
int numProofs = proofs.Length;
144-
int numRowCommitments = rowCommitments.Length;
144+
int numCommitments = commitments.Length;
145145

146-
byte*[] commPtrs = new byte*[numRowCommitments];
146+
byte*[] commPtrs = new byte*[numCommitments];
147147
byte*[] cellsPtrs = new byte*[numCells];
148148
byte*[] proofsPtrs = new byte*[numProofs];
149149

@@ -153,8 +153,7 @@ public bool VerifyCellKZGProofBatch(byte[][] rowCommitments, ulong[] rowIndices,
153153
fixed (byte** commitmentPtrPtr = commPtrs)
154154
fixed (byte** cellsPtrPtr = cellsPtrs)
155155
fixed (byte** proofsPtrPtr = proofsPtrs)
156-
fixed (ulong* rowIndicesPtr = rowIndices)
157-
fixed (ulong* columnIndicesPtr = columnIndices)
156+
fixed (ulong* cellIndicesPtr = cellIndices)
158157
{
159158
// Get the pointer for each cell
160159
for (int i = 0; i < numCells; i++)
@@ -166,9 +165,9 @@ public bool VerifyCellKZGProofBatch(byte[][] rowCommitments, ulong[] rowIndices,
166165
}
167166

168167
// Get the pointer for each commitment
169-
for (int i = 0; i < numRowCommitments; i++)
168+
for (int i = 0; i < numCommitments; i++)
170169
{
171-
fixed (byte* commPtr = rowCommitments[i])
170+
fixed (byte* commPtr = commitments[i])
172171
{
173172
commitmentPtrPtr[i] = commPtr;
174173
}
@@ -183,7 +182,7 @@ public bool VerifyCellKZGProofBatch(byte[][] rowCommitments, ulong[] rowIndices,
183182
}
184183
}
185184

186-
CResult result = verify_cell_kzg_proof_batch(_context, Convert.ToUInt64(rowCommitments.Length), commitmentPtrPtr, Convert.ToUInt64(rowIndices.Length), rowIndicesPtr, Convert.ToUInt64(columnIndices.Length), columnIndicesPtr, Convert.ToUInt64(cells.Length), cellsPtrPtr, Convert.ToUInt64(proofs.Length), proofsPtrPtr, verifiedPtr);
185+
CResult result = verify_cell_kzg_proof_batch(_context, Convert.ToUInt64(commitments.Length), commitmentPtrPtr, Convert.ToUInt64(cellIndices.Length), cellIndicesPtr, Convert.ToUInt64(cells.Length), cellsPtrPtr, Convert.ToUInt64(proofs.Length), proofsPtrPtr, verifiedPtr);
187186
ThrowOnError(result);
188187
}
189188
return verified;

bindings/csharp/csharp_code/EthKZG.bindings/native_methods.g.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ internal static unsafe partial class NativeMethods
104104
/// will be created.
105105
///
106106
/// - The caller must ensure that the pointers are valid.
107-
/// - The caller must ensure that `row_commitments` points to a region of memory that is at least `row_commitments_length` commitments
107+
/// - The caller must ensure that `commitments` points to a region of memory that is at least `commitments_length` commitments
108108
/// and that each commitment is at least `BYTES_PER_COMMITMENT` bytes.
109109
/// - The caller must ensure that `row_indices` points to a region of memory that is at least `num_cells` elements
110110
/// and that each element is 8 bytes.
111-
/// - The caller must ensure that `column_indices` points to a region of memory that is at least `num_cells` elements
111+
/// - The caller must ensure that `cell_indices` points to a region of memory that is at least `num_cells` elements
112112
/// and that each element is 8 bytes.
113113
/// - The caller must ensure that `cells` points to a region of memory that is at least `cells_length` proof and
114114
/// that each cell is at least `BYTES_PER_CELL` bytes
@@ -122,7 +122,7 @@ internal static unsafe partial class NativeMethods
122122
/// If the other arguments are null, this method will dereference a null pointer and result in undefined behavior.
123123
/// </summary>
124124
[DllImport(__DllName, EntryPoint = "verify_cell_kzg_proof_batch", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
125-
internal static extern CResult verify_cell_kzg_proof_batch(DASContext* ctx, ulong row_commitments_length, byte** row_commitments, ulong row_indices_length, ulong* row_indices, ulong column_indices_length, ulong* column_indices, ulong cells_length, byte** cells, ulong proofs_length, byte** proofs, bool* verified);
125+
internal static extern CResult verify_cell_kzg_proof_batch(DASContext* ctx, ulong commitments_length, byte** commitments, ulong cell_indices_length, ulong* cell_indices, ulong cells_length, byte** cells, ulong proofs_length, byte** proofs, bool* verified);
126126

127127
/// <summary>
128128
/// Recovers all cells and their KZG proofs from the given cell indices and cells

bindings/csharp/csharp_code/EthKZG.test/RefTests.cs

+5-7
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,8 @@ public void TestComputeCellsAndKzgProofs()
153153

154154
private class VerifyCellKzgProofBatchInput
155155
{
156-
public List<string> RowCommitments { get; set; } = null!;
157-
public List<ulong> RowIndices { get; set; } = null!;
158-
public List<ulong> ColumnIndices { get; set; } = null!;
156+
public List<string> Commitments { get; set; } = null!;
157+
public List<ulong> CellIndices { get; set; } = null!;
159158
public List<string> Cells { get; set; } = null!;
160159
public List<string> Proofs { get; set; } = null!;
161160
}
@@ -181,15 +180,14 @@ public void TestVerifyCellKzgProofBatch()
181180
VerifyCellKzgProofBatchTest test = _deserializerUnderscoreNaming.Deserialize<VerifyCellKzgProofBatchTest>(yaml);
182181
Assert.That(test, Is.Not.EqualTo(null));
183182

184-
byte[][] rowCommitments = GetByteArrays(test.Input.RowCommitments);
185-
ulong[] rowIndices = test.Input.RowIndices.ToArray();
186-
ulong[] columnIndices = test.Input.ColumnIndices.ToArray();
183+
byte[][] commitments = GetByteArrays(test.Input.Commitments);
184+
ulong[] cellIndices = test.Input.CellIndices.ToArray();
187185
byte[][] cells = GetByteArrays(test.Input.Cells);
188186
byte[][] proofs = GetByteArrays(test.Input.Proofs);
189187

190188
try
191189
{
192-
bool isCorrect = _context.VerifyCellKZGProofBatch(rowCommitments, rowIndices, columnIndices, cells, proofs);
190+
bool isCorrect = _context.VerifyCellKZGProofBatch(commitments, cellIndices, cells, proofs);
193191
Assert.That(isCorrect, Is.EqualTo(test.Output));
194192
}
195193
catch

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ public CellsAndProofs computeCellsAndKZGProofs(byte[] blob) {
7878
return cellsAndProofs;
7979
}
8080

81-
public boolean verifyCellKZGProofBatch(byte[][] commitmentsArr, long[] rowIndices, long[] columnIndices, byte[][] cellsArr,
81+
public boolean verifyCellKZGProofBatch(byte[][] commitmentsArr, long[] cellIndices, byte[][] cellsArr,
8282
byte[][] proofsArr) {
8383
checkContextHasNotBeenFreed();
84-
return verifyCellKZGProofBatch(contextPtr, commitmentsArr, rowIndices, columnIndices, cellsArr, proofsArr);
84+
return verifyCellKZGProofBatch(contextPtr, commitmentsArr, cellIndices, cellsArr, proofsArr);
8585
}
8686

8787
public CellsAndProofs recoverCellsAndProofs(long[] cellIDs, byte[][] cellsArr) {
@@ -103,7 +103,7 @@ public CellsAndProofs recoverCellsAndProofs(long[] cellIDs, byte[][] cellsArr) {
103103
private static native byte[] blobToKZGCommitment(long context_ptr, byte[] blob);
104104

105105
private static native boolean verifyCellKZGProofBatch(
106-
long context_ptr, byte[][] commitments, long[] rowIndices, long[] columnIndices, byte[][] cells, byte[][] proofs);
106+
long context_ptr, byte[][] commitments, long[] cellIndices, byte[][] cells, byte[][] proofs);
107107

108108
private static native CellsAndProofs recoverCellsAndProof(long context_ptr, long[] cellIDs, byte[][] cells);
109109

bindings/java/java_code/src/test/java/ethereum/cryptography/LibEthKZGTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ public void recoverCellsAndKzgProofsTests(final RecoverCellsAndKzgProofsTest tes
9696
public void verifyCellKzgProofBatchTests(final VerifyCellKzgProofBatchTest test) {
9797
try {
9898
boolean valid = context.verifyCellKZGProofBatch(
99-
test.getInput().getRowCommitments(),
100-
test.getInput().getRowIndices(),
101-
test.getInput().getColumnIndices(),
99+
test.getInput().getCommitments(),
100+
test.getInput().getCellIndices(),
102101
test.getInput().getCells(),
103102
test.getInput().getProofs());
104103
assertEquals(test.getOutput(), valid);

bindings/java/java_code/src/testFixtures/java/ethereum/cryptography/test_formats/VerifyCellKzgProofBatchTest.java

+8-14
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,26 @@
88

99
public class VerifyCellKzgProofBatchTest {
1010
public static class Input {
11-
@JsonProperty("row_commitments")
12-
private List<String> rowCommitments;
11+
@JsonProperty("commitments")
12+
private List<String> commitments;
1313

14-
@JsonProperty("row_indices")
15-
private List<Long> rowIndices;
16-
17-
@JsonProperty("column_indices")
18-
private List<Long> columnIndices;
14+
@JsonProperty("cell_indices")
15+
private List<Long> cellIndices;
1916

2017
private List<String> cells;
2118
private List<String> proofs;
2219

23-
public byte[][] getRowCommitments() {
24-
return rowCommitments.stream()
20+
public byte[][] getCommitments() {
21+
return commitments.stream()
2522
.map(Bytes::fromHexString)
2623
.map(Bytes::toArray)
2724
.collect(Collectors.toList())
2825
.toArray(byte[][]::new);
2926
}
3027

31-
public long[] getRowIndices() {
32-
return rowIndices.stream().mapToLong(Long::longValue).toArray();
33-
}
3428

35-
public long[] getColumnIndices() {
36-
return columnIndices.stream().mapToLong(Long::longValue).toArray();
29+
public long[] getCellIndices() {
30+
return cellIndices.stream().mapToLong(Long::longValue).toArray();
3731
}
3832

3933
public byte[][] getCells() {

bindings/java/rust_code/ethereum_cryptography_LibEthKZG.h

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/java/rust_code/src/errors.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rust_eth_kzg::Error as DASError;
1+
use rust_eth_kzg::Error as KZGError;
22

33
#[derive(Debug)]
44
pub enum Error {
@@ -8,7 +8,7 @@ pub enum Error {
88
got: usize,
99
name: &'static str,
1010
},
11-
DASError(DASError),
11+
Cryptography(KZGError),
1212
}
1313

1414
impl From<jni::errors::Error> for Error {
@@ -17,8 +17,8 @@ impl From<jni::errors::Error> for Error {
1717
}
1818
}
1919

20-
impl From<DASError> for Error {
21-
fn from(err: DASError) -> Self {
22-
Error::DASError(err)
20+
impl From<KZGError> for Error {
21+
fn from(err: KZGError) -> Self {
22+
Error::Cryptography(err)
2323
}
2424
}

0 commit comments

Comments
 (0)