mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
signer/core/apitypes: add cell proofs
This commit is contained in:
parent
40505a9bc0
commit
9a0dcec95c
1 changed files with 35 additions and 14 deletions
|
|
@ -108,6 +108,7 @@ type SendTxArgs struct {
|
||||||
BlobHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
BlobHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
||||||
|
|
||||||
// For BlobTxType transactions with blob sidecar
|
// For BlobTxType transactions with blob sidecar
|
||||||
|
BlobVersion byte `json:"blobVersion,omitempty"`
|
||||||
Blobs []kzg4844.Blob `json:"blobs,omitempty"`
|
Blobs []kzg4844.Blob `json:"blobs,omitempty"`
|
||||||
Commitments []kzg4844.Commitment `json:"commitments,omitempty"`
|
Commitments []kzg4844.Commitment `json:"commitments,omitempty"`
|
||||||
Proofs []kzg4844.Proof `json:"proofs,omitempty"`
|
Proofs []kzg4844.Proof `json:"proofs,omitempty"`
|
||||||
|
|
@ -235,13 +236,26 @@ func (args *SendTxArgs) validateTxSidecar() error {
|
||||||
if args.Commitments != nil && len(args.Commitments) != n {
|
if args.Commitments != nil && len(args.Commitments) != n {
|
||||||
return fmt.Errorf("number of blobs and commitments mismatch (have=%d, want=%d)", len(args.Commitments), n)
|
return fmt.Errorf("number of blobs and commitments mismatch (have=%d, want=%d)", len(args.Commitments), n)
|
||||||
}
|
}
|
||||||
if args.Proofs != nil && len(args.Proofs) != n {
|
|
||||||
return fmt.Errorf("number of blobs and proofs mismatch (have=%d, want=%d)", len(args.Proofs), n)
|
|
||||||
}
|
|
||||||
if args.BlobHashes != nil && len(args.BlobHashes) != n {
|
if args.BlobHashes != nil && len(args.BlobHashes) != n {
|
||||||
return fmt.Errorf("number of blobs and hashes mismatch (have=%d, want=%d)", len(args.BlobHashes), n)
|
return fmt.Errorf("number of blobs and hashes mismatch (have=%d, want=%d)", len(args.BlobHashes), n)
|
||||||
}
|
}
|
||||||
|
if args.Proofs != nil {
|
||||||
|
if len(args.Proofs) == n {
|
||||||
|
// v1 transaction
|
||||||
|
for i, b := range args.Blobs {
|
||||||
|
if err := kzg4844.VerifyBlobProof(&b, args.Commitments[i], args.Proofs[i]); err != nil {
|
||||||
|
return fmt.Errorf("failed to verify blob proof: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if len(args.Proofs) == n*kzg4844.CellProofsPerBlob {
|
||||||
|
// v2 transaction
|
||||||
|
if err := kzg4844.VerifyCellProofs(args.Blobs, args.Commitments, args.Proofs); err != nil {
|
||||||
|
return fmt.Errorf("failed to verify blob proof: %v", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("number of proofs and blobs mismatch (have=%d, want=%d or %d)", len(args.Proofs), n, n*kzg4844.CellProofsPerBlob)
|
||||||
|
}
|
||||||
|
}
|
||||||
if args.Commitments == nil {
|
if args.Commitments == nil {
|
||||||
// Generate commitment and proof.
|
// Generate commitment and proof.
|
||||||
commitments := make([]kzg4844.Commitment, n)
|
commitments := make([]kzg4844.Commitment, n)
|
||||||
|
|
@ -252,20 +266,27 @@ func (args *SendTxArgs) validateTxSidecar() error {
|
||||||
return fmt.Errorf("blobs[%d]: error computing commitment: %v", i, err)
|
return fmt.Errorf("blobs[%d]: error computing commitment: %v", i, err)
|
||||||
}
|
}
|
||||||
commitments[i] = c
|
commitments[i] = c
|
||||||
p, err := kzg4844.ComputeBlobProof(&b, c)
|
}
|
||||||
if err != nil {
|
if args.BlobVersion == 1 {
|
||||||
return fmt.Errorf("blobs[%d]: error computing proof: %v", i, err)
|
for i, b := range args.Blobs {
|
||||||
|
p, err := kzg4844.ComputeCellProofs(&b)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("blobs[%d]: error computing cell proof: %v", i, err)
|
||||||
|
}
|
||||||
|
proofs = append(proofs, p...)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
for i, b := range args.Blobs {
|
||||||
|
p, err := kzg4844.ComputeBlobProof(&b, commitments[i])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("blobs[%d]: error computing proof: %v", i, err)
|
||||||
|
}
|
||||||
|
proofs[i] = p
|
||||||
}
|
}
|
||||||
proofs[i] = p
|
|
||||||
}
|
}
|
||||||
args.Commitments = commitments
|
args.Commitments = commitments
|
||||||
args.Proofs = proofs
|
args.Proofs = proofs
|
||||||
} else {
|
|
||||||
for i, b := range args.Blobs {
|
|
||||||
if err := kzg4844.VerifyBlobProof(&b, args.Commitments[i], args.Proofs[i]); err != nil {
|
|
||||||
return fmt.Errorf("failed to verify blob proof: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hashes := make([]common.Hash, n)
|
hashes := make([]common.Hash, n)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue