Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor KZG API indicating deprecated functions and add recoverCellsAndKzgProofs #7031

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/beacon-node/src/util/kzg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ export let ckzg: {
computeBlobKzgProof(blob: Uint8Array, commitment: Uint8Array): Uint8Array;
verifyBlobKzgProof(blob: Uint8Array, commitment: Uint8Array, proof: Uint8Array): boolean;
verifyBlobKzgProofBatch(blobs: Uint8Array[], expectedKzgCommitments: Uint8Array[], kzgProofs: Uint8Array[]): boolean;
/** @deprecated Use `computeCellsAndKzgProofs` */
computeCells(blob: Uint8Array): Uint8Array[];
computeCellsAndKzgProofs(blob: Uint8Array): [Uint8Array[], Uint8Array[]];
/** @deprecated Now being done internally in `recoverCellsAndKzgProofs` */
cellsToBlob(cells: Uint8Array[]): Uint8Array;
/** @deprecated Use recoverCellsAndKzgProofs */
recoverAllCells(cellIds: number[], cells: Uint8Array[]): Uint8Array[];
recoverCellsAndKzgProofs(cellIndices: number[], cells: Uint8Array[]): [Uint8Array[], Uint8Array[]];
/** @deprecated This method is not used and has been removed from specs */
verifyCellKzgProof(commitmentBytes: Uint8Array, cellId: number, cell: Uint8Array, proofBytes: Uint8Array): boolean;
/** @deprecated This API will no longer take rowIndices in the future, in particular the rowIndices is no longer used. */
verifyCellKzgProofBatch(
commitmentsBytes: Uint8Array[],
rowIndices: number[],
Expand All @@ -44,6 +50,14 @@ export let ckzg: {
recoverAllCells: ckzgNotLoaded,
verifyCellKzgProof: ckzgNotLoaded,
verifyCellKzgProofBatch: ckzgNotLoaded,
recoverCellsAndKzgProofs(cellIndices: number[], cells: Uint8Array[]): [Uint8Array[], Uint8Array[]] {
// First recover all of the cells
const recoveredCells = this.recoverAllCells(cellIndices, cells);
// Convert the cells to a Blob
const blob = this.cellsToBlob(recoveredCells);
// Compute Cells and Proofs
return this.computeCellsAndKzgProofs(blob);
},
};

// Global variable __dirname no longer available in ES6 modules.
Expand Down
Loading