mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-04-05 01:25:55 +00:00
crypto/kzg4844: change cell proof API to take non-pointer slice
This commit is contained in:
parent
b069645565
commit
27177d251c
6 changed files with 11 additions and 14 deletions
|
|
@ -206,11 +206,7 @@ func validateBlobSidecarOsaka(sidecar *types.BlobTxSidecar, hashes []common.Hash
|
|||
if err := sidecar.ValidateBlobCommitmentHashes(hashes); err != nil {
|
||||
return err
|
||||
}
|
||||
var blobs []*kzg4844.Blob
|
||||
for _, blob := range sidecar.Blobs {
|
||||
blobs = append(blobs, &blob)
|
||||
}
|
||||
if err := kzg4844.VerifyCellProofs(blobs, sidecar.Commitments, sidecar.Proofs); err != nil {
|
||||
if err := kzg4844.VerifyCellProofs(sidecar.Blobs, sidecar.Commitments, sidecar.Proofs); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ func VerifyBlobProof(blob *Blob, commitment Commitment, proof Proof) error {
|
|||
// VerifyCellProofs verifies a batch of proofs corresponding to the blobs and commitments.
|
||||
// Expects length of blobs and commitments to be equal.
|
||||
// Expects length of proofs be 128 * length of blobs.
|
||||
func VerifyCellProofs(blobs []*Blob, commitments []Commitment, proofs []Proof) error {
|
||||
func VerifyCellProofs(blobs []Blob, commitments []Commitment, proofs []Proof) error {
|
||||
if useCKZG.Load() {
|
||||
return ckzgVerifyCellProofBatch(blobs, commitments, proofs)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ func ckzgComputeCellProofs(blob *Blob) ([]Proof, error) {
|
|||
}
|
||||
|
||||
// ckzgVerifyCellProofs verifies that the blob data corresponds to the provided commitment.
|
||||
func ckzgVerifyCellProofBatch(blobs []*Blob, commitments []Commitment, cellProofs []Proof) error {
|
||||
func ckzgVerifyCellProofBatch(blobs []Blob, commitments []Commitment, cellProofs []Proof) error {
|
||||
ckzgIniter.Do(ckzgInit)
|
||||
var (
|
||||
proofs = make([]ckzg4844.Bytes48, len(cellProofs))
|
||||
|
|
@ -170,8 +170,8 @@ func ckzgVerifyCellProofBatch(blobs []*Blob, commitments []Commitment, cellProof
|
|||
}
|
||||
}
|
||||
// Compute the cells and cell indices
|
||||
for _, blob := range blobs {
|
||||
cellsI, err := ckzg4844.ComputeCells((*ckzg4844.Blob)(blob))
|
||||
for i := range blobs {
|
||||
cellsI, err := ckzg4844.ComputeCells((*ckzg4844.Blob)(&blobs[i]))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func ckzgVerifyBlobProof(blob *Blob, commitment Commitment, proof Proof) error {
|
|||
}
|
||||
|
||||
// ckzgVerifyCellProofBatch verifies that the blob data corresponds to the provided commitment.
|
||||
func ckzgVerifyCellProofBatch(blobs []*Blob, commitments []Commitment, proof []Proof) error {
|
||||
func ckzgVerifyCellProofBatch(blobs []Blob, commitments []Commitment, proof []Proof) error {
|
||||
panic("unsupported platform")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ func gokzgComputeCellProofs(blob *Blob) ([]Proof, error) {
|
|||
}
|
||||
|
||||
// gokzgVerifyCellProofs verifies that the blob data corresponds to the provided commitment.
|
||||
func gokzgVerifyCellProofBatch(blobs []*Blob, commitments []Commitment, cellProofs []Proof) error {
|
||||
func gokzgVerifyCellProofBatch(blobs []Blob, commitments []Commitment, cellProofs []Proof) error {
|
||||
gokzgIniter.Do(gokzgInit)
|
||||
|
||||
var (
|
||||
|
|
@ -136,8 +136,8 @@ func gokzgVerifyCellProofBatch(blobs []*Blob, commitments []Commitment, cellProo
|
|||
}
|
||||
}
|
||||
// Compute the cell and cell indices
|
||||
for _, blob := range blobs {
|
||||
cellsI, err := context.ComputeCells((*gokzg4844.Blob)(blob), 2)
|
||||
for i := range blobs {
|
||||
cellsI, err := context.ComputeCells((*gokzg4844.Blob)(&blobs[i]), 2)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,7 +225,8 @@ func testKZGCells(t *testing.T, ckzg bool) {
|
|||
t.Fatalf("failed to create KZG proof at point: %v", err)
|
||||
}
|
||||
proofs := append(proofs1, proofs2...)
|
||||
if err := VerifyCellProofs([]*Blob{blob1, blob2}, []Commitment{commitment1, commitment2}, proofs); err != nil {
|
||||
blobs := []Blob{*blob1, *blob2}
|
||||
if err := VerifyCellProofs(blobs, []Commitment{commitment1, commitment2}, proofs); err != nil {
|
||||
t.Fatalf("failed to verify KZG proof at point: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue