diff --git a/packages/beacon-node/src/util/kzg.ts b/packages/beacon-node/src/util/kzg.ts index b5f32d89db76..a6ea6ebafcd6 100644 --- a/packages/beacon-node/src/util/kzg.ts +++ b/packages/beacon-node/src/util/kzg.ts @@ -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[], @@ -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.