From 9ea1faa4f756c8b45f4ab8198df4c1a7afd55df7 Mon Sep 17 00:00:00 2001 From: Roberto Bayardo Date: Thu, 10 Nov 2022 15:06:04 -0800 Subject: [PATCH] move more low-level kzg stuff into kzg_new (#48) * start using custom types from the 4844 spec * move ComputePowers into kzg_new * 1) move BlobsToKZGCommitment functionality into kzg_new and make it more closely follow the spec. 2) Remove the BlobsBatch stuff which seems only to be for legacy benchmarking. * Replace kzg-related data_blob.go type methods Parse, ComputeCommitment, and Point, so we can move methods that depend on them into the kzg package. * Remove ComputeCommitments which is unused. * Add BytesToBLSField go kzg_new, use it instead of hashToFr --- core/types/data_blob.go | 125 +++++++--------------------------- crypto/kzg/kzg.go | 64 ----------------- crypto/kzg/kzg_new.go | 58 ++++++++++++++-- signer/core/apitypes/types.go | 6 +- tests/kzg_bench_test.go | 61 ++++------------- tests/kzg_test.go | 14 ++-- 6 files changed, 101 insertions(+), 227 deletions(-) diff --git a/core/types/data_blob.go b/core/types/data_blob.go index d127aebf77c5..558ea344dfff 100644 --- a/core/types/data_blob.go +++ b/core/types/data_blob.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "io" - "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -58,12 +57,8 @@ func (p *KZGCommitment) UnmarshalText(text []byte) error { return hexutil.UnmarshalFixedText("KZGCommitment", text, p[:]) } -func (p *KZGCommitment) Point() (*bls.G1Point, error) { - return bls.FromCompressedG1(p[:]) -} - func (c KZGCommitment) ComputeVersionedHash() common.Hash { - return kzg.KZGToVersionedHash(c) + return common.Hash(kzg.KZGToVersionedHash(kzg.KZGCommitment(c))) } // Compressed BLS12-381 G1 element @@ -108,10 +103,6 @@ func (p *KZGProof) UnmarshalText(text []byte) error { return hexutil.UnmarshalFixedText("KZGProof", text, p[:]) } -func (p *KZGProof) Point() (*bls.G1Point, error) { - return bls.FromCompressedG1(p[:]) -} - type BLSFieldElement [32]byte func (p BLSFieldElement) MarshalText() ([]byte, error) { @@ -165,18 +156,15 @@ func (blob *Blob) HashTreeRoot(hFn tree.HashFn) tree.Root { }, params.FieldElementsPerBlob) } -func (blob *Blob) ComputeCommitment() (commitment KZGCommitment, ok bool) { +// Convert a blob to kzg.Blob +func (blob *Blob) ToKZGBlob() (kzg.Blob, bool) { frs := make([]bls.Fr, len(blob)) for i, elem := range blob { if !bls.FrFrom32(&frs[i], elem) { - return KZGCommitment{}, false + return []bls.Fr{}, false } } - // data is presented in eval form - commitmentG1 := kzg.BlobToKzg(frs) - var out KZGCommitment - copy(out[:], bls.ToCompressedG1(commitmentG1)) - return out, true + return kzg.Blob(frs), true } func (blob *Blob) MarshalText() ([]byte, error) { @@ -219,33 +207,8 @@ func (blob *Blob) UnmarshalText(text []byte) error { return nil } -// Parse blob into Fr elements array -func (blob *Blob) Parse() (out []bls.Fr, err error) { - out = make([]bls.Fr, params.FieldElementsPerBlob) - for i, chunk := range blob { - ok := bls.FrFrom32(&out[i], chunk) - if !ok { - return nil, errors.New("internal error commitments") - } - } - return out, nil -} - type BlobKzgs []KZGCommitment -// Extract the crypto material underlying these commitments -func (li BlobKzgs) Parse() ([]*bls.G1Point, error) { - out := make([]*bls.G1Point, len(li)) - for i, c := range li { - p, err := c.Point() - if err != nil { - return nil, fmt.Errorf("failed to parse commitment %d: %v", i, err) - } - out[i] = p - } - return out, nil -} - func (li *BlobKzgs) Deserialize(dr *codec.DecodingReader) error { return dr.List(func() codec.Deserializable { i := len(*li) @@ -283,16 +246,16 @@ func (li BlobKzgs) copy() BlobKzgs { type Blobs []Blob // Extract the crypto material underlying these blobs -func (blobs Blobs) Parse() ([][]bls.Fr, error) { +func (blobs Blobs) toKZGBlobSequence() ([][]bls.Fr, bool) { out := make([][]bls.Fr, len(blobs)) for i, b := range blobs { - blob, err := b.Parse() - if err != nil { - return nil, fmt.Errorf("failed to parse blob %d: %v", i, err) + blob, ok := b.ToKZGBlob() + if !ok { + return nil, false } out[i] = blob } - return out, nil + return out, true } func (a *Blobs) Deserialize(dr *codec.DecodingReader) error { @@ -333,31 +296,17 @@ func (blobs Blobs) copy() Blobs { return cpy } -// Return KZG commitments and versioned hashes that correspond to these blobs -func (blobs Blobs) ComputeCommitments() (commitments []KZGCommitment, versionedHashes []common.Hash, ok bool) { - commitments = make([]KZGCommitment, len(blobs)) - versionedHashes = make([]common.Hash, len(blobs)) - for i, blob := range blobs { - commitments[i], ok = blob.ComputeCommitment() - if !ok { - return nil, nil, false - } - versionedHashes[i] = commitments[i].ComputeVersionedHash() - } - return commitments, versionedHashes, true -} - // Return KZG commitments, versioned hashes and the aggregated KZG proof that correspond to these blobs func (blobs Blobs) ComputeCommitmentsAndAggregatedProof() (commitments []KZGCommitment, versionedHashes []common.Hash, aggregatedProof KZGProof, err error) { commitments = make([]KZGCommitment, len(blobs)) versionedHashes = make([]common.Hash, len(blobs)) for i, blob := range blobs { - var ok bool - commitments[i], ok = blob.ComputeCommitment() + frs, ok := blob.ToKZGBlob() if !ok { return nil, nil, KZGProof{}, errors.New("invalid blob for commitment") } - versionedHashes[i] = commitments[i].ComputeVersionedHash() + commitments[i] = KZGCommitment(kzg.BlobToKZGCommitment(frs)) + versionedHashes[i] = common.Hash(kzg.KZGToVersionedHash(kzg.KZGCommitment(commitments[i]))) } var kzgProof KZGProof @@ -378,13 +327,12 @@ func (blobs Blobs) ComputeCommitmentsAndAggregatedProof() (commitments []KZGComm if err != nil { return nil, nil, KZGProof{}, err } - var z bls.Fr - hashToFr(&z, sum) + z := kzg.BytesToBLSField(sum) var y bls.Fr - kzg.EvaluatePolyInEvaluationForm(&y, aggregatePoly[:], &z) + kzg.EvaluatePolyInEvaluationForm(&y, aggregatePoly[:], z) - aggProofG1, err := kzg.ComputeProof(aggregatePoly, &z) + aggProofG1, err := kzg.ComputeProof(aggregatePoly, z) if err != nil { return nil, nil, KZGProof{}, err } @@ -515,17 +463,16 @@ func (b *BlobTxWrapData) verifyBlobs(inner TxData) error { if err != nil { return err } - var z bls.Fr - hashToFr(&z, sum) + z := kzg.BytesToBLSField(sum) var y bls.Fr - kzg.EvaluatePolyInEvaluationForm(&y, aggregatePoly[:], &z) + kzg.EvaluatePolyInEvaluationForm(&y, aggregatePoly[:], z) - aggregateProofG1, err := b.KzgAggregatedProof.Point() + aggregateProofG1, err := bls.FromCompressedG1(b.KzgAggregatedProof[:]) if err != nil { return fmt.Errorf("aggregate proof parse error: %v", err) } - if !kzg.VerifyKZGProofFromPoints(aggregateCommitmentG1, &z, &y, aggregateProofG1) { + if !kzg.VerifyKZGProofFromPoints(aggregateCommitmentG1, z, &y, aggregateProofG1) { return errors.New("failed to verify kzg") } return nil @@ -568,39 +515,27 @@ func (b *BlobTxWrapData) encodeTyped(w io.Writer, txdata TxData) error { return EncodeSSZ(w, &wrapped) } -func computePowers(r *bls.Fr, n int) []bls.Fr { - var currentPower bls.Fr - bls.AsFr(¤tPower, 1) - powers := make([]bls.Fr, n) - for i := range powers { - powers[i] = currentPower - bls.MulModFr(¤tPower, ¤tPower, r) - } - return powers -} - func computeAggregateKzgCommitment(blobs Blobs, commitments []KZGCommitment) ([]bls.Fr, *bls.G1Point, error) { // create challenges sum, err := sszHash(&BlobsAndCommitments{blobs, commitments}) if err != nil { return nil, nil, err } - var r bls.Fr - hashToFr(&r, sum) + r := kzg.BytesToBLSField(sum) - powers := computePowers(&r, len(blobs)) + powers := kzg.ComputePowers(r, len(blobs)) commitmentsG1 := make([]bls.G1Point, len(commitments)) for i := 0; i < len(commitmentsG1); i++ { - p, _ := commitments[i].Point() + p, _ := bls.FromCompressedG1(commitments[i][:]) bls.CopyG1(&commitmentsG1[i], p) } aggregateCommitmentG1 := bls.LinCombG1(commitmentsG1, powers) var aggregateCommitment KZGCommitment copy(aggregateCommitment[:], bls.ToCompressedG1(aggregateCommitmentG1)) - polys, err := blobs.Parse() - if err != nil { + polys, ok := blobs.toKZGBlobSequence() + if !ok { return nil, nil, err } aggregatePoly, err := bls.PolyLinComb(polys, powers) @@ -609,13 +544,3 @@ func computeAggregateKzgCommitment(blobs Blobs, commitments []KZGCommitment) ([] } return aggregatePoly, aggregateCommitmentG1, nil } - -func hashToFr(out *bls.Fr, h [32]byte) { - // re-interpret as little-endian - var b [32]byte = h - for i := 0; i < 16; i++ { - b[31-i], b[i] = b[i], b[31-i] - } - zB := new(big.Int).Mod(new(big.Int).SetBytes(b[:]), kzg.BLSModulus) - _ = kzg.BigToFr(out, zB) -} diff --git a/crypto/kzg/kzg.go b/crypto/kzg/kzg.go index bb855ddca6ab..0d3a2cac10ed 100644 --- a/crypto/kzg/kzg.go +++ b/crypto/kzg/kzg.go @@ -3,10 +3,8 @@ package kzg import ( "encoding/json" "errors" - "fmt" "math/big" "math/bits" - "sync" "github.com/ethereum/go-ethereum/params" @@ -45,68 +43,6 @@ func init() { initDomain() } -// Convert polynomial in evaluation form to KZG commitment -func BlobToKzg(eval []bls.Fr) *bls.G1Point { - return bls.LinCombG1(kzgSetupLagrange, eval) -} - -type BlobsBatch struct { - sync.Mutex - init bool - aggregateCommitment bls.G1Point - aggregateBlob [params.FieldElementsPerBlob]bls.Fr -} - -func (batch *BlobsBatch) Join(commitments []*bls.G1Point, blobs [][]bls.Fr) error { - batch.Lock() - defer batch.Unlock() - if len(commitments) != len(blobs) { - return fmt.Errorf("expected commitments len %d to equal blobs len %d", len(commitments), len(blobs)) - } - if !batch.init && len(commitments) > 0 { - batch.init = true - bls.CopyG1(&batch.aggregateCommitment, commitments[0]) - copy(batch.aggregateBlob[:], blobs[0]) - commitments = commitments[1:] - blobs = blobs[1:] - } - for i, commit := range commitments { - batch.join(commit, blobs[i]) - } - return nil -} - -func (batch *BlobsBatch) join(commitment *bls.G1Point, blob []bls.Fr) { - // we multiply the input we are joining with a random scalar, so we can add it to the aggregate safely - randomScalar := bls.RandomFr() - - // TODO: instead of computing the lin-comb of the commitments on the go, we could buffer - // the random scalar and commitment, and run a LinCombG1 over all of them during Verify() - var tmpG1 bls.G1Point - bls.MulG1(&tmpG1, commitment, randomScalar) - bls.AddG1(&batch.aggregateCommitment, &batch.aggregateCommitment, &tmpG1) - - var tmpFr bls.Fr - for i := 0; i < params.FieldElementsPerBlob; i++ { - bls.MulModFr(&tmpFr, &blob[i], randomScalar) - bls.AddModFr(&batch.aggregateBlob[i], &batch.aggregateBlob[i], &tmpFr) - } -} - -func (batch *BlobsBatch) Verify() error { - batch.Lock() - defer batch.Unlock() - if !batch.init { - return nil // empty batch - } - // Compute both MSMs and check equality - lResult := bls.LinCombG1(kzgSetupLagrange, batch.aggregateBlob[:]) - if !bls.EqualG1(lResult, &batch.aggregateCommitment) { - return errors.New("BlobsBatch failed to Verify") - } - return nil -} - // Bit-reversal permutation helper functions // Check if `value` is a power of two integer. diff --git a/crypto/kzg/kzg_new.go b/crypto/kzg/kzg_new.go index aefc5505c0f6..8a32223b5458 100644 --- a/crypto/kzg/kzg_new.go +++ b/crypto/kzg/kzg_new.go @@ -3,6 +3,7 @@ package kzg import ( "errors" "fmt" + "math/big" "github.com/protolambda/go-kzg/bls" @@ -10,9 +11,20 @@ import ( "github.com/ethereum/go-ethereum/params" ) +// The custom types from EIP-4844 consensus spec: +// https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/polynomial-commitments.md#custom-types +// We deviate from the spec slightly in that we use: +// *bls.Fr for BLSFieldElement +// *bls.G1Point for G1Point +// *bls.G2Point for G2Point +type Blob []bls.Fr +type KZGCommitment [48]byte +type KZGProof [48]byte +type VersionedHash [32]byte + // VerifyKZGProof implements verify_kzg_proof from the EIP-4844 consensus spec: // https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/polynomial-commitments.md#verify_kzg_proof -func VerifyKZGProof(polynomialKZG [48]byte, z *bls.Fr, y *bls.Fr, kzgProof [48]byte) (bool, error) { +func VerifyKZGProof(polynomialKZG KZGCommitment, z *bls.Fr, y *bls.Fr, kzgProof KZGProof) (bool, error) { polynomialKZGG1, err := bls.FromCompressedG1(polynomialKZG[:]) if err != nil { return false, fmt.Errorf("failed to decode polynomialKZG: %v", err) @@ -39,10 +51,10 @@ func VerifyKZGProofFromPoints(polynomialKZG *bls.G1Point, z *bls.Fr, y *bls.Fr, } // KZGToVersionedHash implements kzg_to_versioned_hash from EIP-4844 -func KZGToVersionedHash(kzg [48]byte) [32]byte { +func KZGToVersionedHash(kzg KZGCommitment) VersionedHash { h := crypto.Keccak256Hash(kzg[:]) h[0] = params.BlobCommitmentVersionKZG - return h + return VersionedHash([32]byte(h)) } // PointEvaluationPrecompile implements point_evaluation_precompile from EIP-4844 @@ -75,7 +87,7 @@ func PointEvaluationPrecompile(input []byte) ([]byte, error) { // input kzg point: next 48 bytes var dataKZG [48]byte copy(dataKZG[:], input[96:144]) - if KZGToVersionedHash(dataKZG) != versionedHash { + if KZGToVersionedHash(KZGCommitment(dataKZG)) != VersionedHash(versionedHash) { return nil, errors.New("mismatched versioned hash") } @@ -83,7 +95,7 @@ func PointEvaluationPrecompile(input []byte) ([]byte, error) { var quotientKZG [48]byte copy(quotientKZG[:], input[144:192]) - ok, err := VerifyKZGProof(dataKZG, &xFr, &yFr, quotientKZG) + ok, err := VerifyKZGProof(KZGCommitment(dataKZG), &xFr, &yFr, KZGProof(quotientKZG)) if err != nil { return nil, fmt.Errorf("verify_kzg_proof error: %v", err) } @@ -92,3 +104,39 @@ func PointEvaluationPrecompile(input []byte) ([]byte, error) { } return []byte{}, nil } + +// ComputePowers implements compute_powers from the EIP-4844 consensus spec: +// https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/polynomial-commitments.md#compute_powers +func ComputePowers(r *bls.Fr, n int) []bls.Fr { + var currentPower bls.Fr + bls.AsFr(¤tPower, 1) + powers := make([]bls.Fr, n) + for i := range powers { + powers[i] = currentPower + bls.MulModFr(¤tPower, ¤tPower, r) + } + return powers +} + +// BlobToKZGCommitment implements blob_to_kzg_commitment from the EIP-4844 consensus spec: +// https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/polynomial-commitments.md#blob_to_kzg_commitment +func BlobToKZGCommitment(eval Blob) KZGCommitment { + g1 := bls.LinCombG1(kzgSetupLagrange, []bls.Fr(eval)) + var out KZGCommitment + copy(out[:], bls.ToCompressedG1(g1)) + return out +} + +// BytesToBLSField implements bytes_to_bls_field from the EIP-4844 consensus spec: +// https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/polynomial-commitments.md#bytes_to_bls_field +func BytesToBLSField(h [32]byte) *bls.Fr { + // re-interpret as little-endian + var b [32]byte = h + for i := 0; i < 16; i++ { + b[31-i], b[i] = b[i], b[31-i] + } + zB := new(big.Int).Mod(new(big.Int).SetBytes(b[:]), BLSModulus) + out := new(bls.Fr) + BigToFr(out, zB) + return out +} diff --git a/signer/core/apitypes/types.go b/signer/core/apitypes/types.go index f63f48edec03..8c4e672348df 100644 --- a/signer/core/apitypes/types.go +++ b/signer/core/apitypes/types.go @@ -38,6 +38,7 @@ import ( "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/crypto/kzg" ) var typedDataReferenceTypeRegexp = regexp.MustCompile(`^[A-Z](\w*)(\[\])?$`) @@ -149,12 +150,13 @@ func (args *SendTxArgs) ToTransaction() *types.Transaction { msg.AccessList = types.AccessListView(al) wrapData := types.BlobTxWrapData{} for _, bl := range args.Blobs { - commitment, ok := bl.ComputeCommitment() + frs, ok := bl.ToKZGBlob() if !ok { // invalid BLS blob data (e.g. element not within field element range) continue // can't error, so ignore the malformed blob } - versionedHash := commitment.ComputeVersionedHash() + commitment := types.KZGCommitment(kzg.BlobToKZGCommitment(frs)) + versionedHash := common.Hash(kzg.KZGToVersionedHash(kzg.KZGCommitment(commitment))) msg.BlobVersionedHashes = append(msg.BlobVersionedHashes, versionedHash) wrapData.BlobKzgs = append(wrapData.BlobKzgs, commitment) wrapData.Blobs = append(wrapData.Blobs, bl) diff --git a/tests/kzg_bench_test.go b/tests/kzg_bench_test.go index b5e837c3de1c..56239dea1f03 100644 --- a/tests/kzg_bench_test.go +++ b/tests/kzg_bench_test.go @@ -15,8 +15,8 @@ import ( "github.com/protolambda/ztyp/view" ) -func randomBlob() []bls.Fr { - blob := make([]bls.Fr, params.FieldElementsPerBlob) +func randomBlob() kzg.Blob { + blob := make(kzg.Blob, params.FieldElementsPerBlob) for i := 0; i < len(blob); i++ { blob[i] = *bls.RandomFr() } @@ -27,7 +27,7 @@ func BenchmarkBlobToKzg(b *testing.B) { blob := randomBlob() b.ResetTimer() for i := 0; i < b.N; i++ { - kzg.BlobToKzg(blob) + kzg.BlobToKZGCommitment(blob) } } @@ -40,12 +40,14 @@ func BenchmarkVerifyBlobs(b *testing.B) { for j := range tmp { blobs[i][j] = bls.FrTo32(&tmp[j]) } - c, ok := blobs[i].ComputeCommitment() + frs, ok := blobs[i].ToKZGBlob() if !ok { b.Fatal("Could not compute commitment") } + c := types.KZGCommitment(kzg.BlobToKZGCommitment(frs)) commitments = append(commitments, c) - hashes = append(hashes, c.ComputeVersionedHash()) + h := common.Hash(kzg.KZGToVersionedHash(kzg.KZGCommitment(c))) + hashes = append(hashes, h) } txData := &types.SignedBlobTx{ Message: types.BlobTxMessage{ @@ -94,7 +96,8 @@ func BenchmarkVerifyKZGProof(b *testing.B) { // Now let's start testing the kzg module // Create a commitment - commitment := kzg.BlobToKzg(evalPoly) + k := kzg.BlobToKZGCommitment(evalPoly) + commitment, _ := bls.FromCompressedG1(k[:]) // Create proof for testing x := uint64(17) @@ -132,12 +135,10 @@ func BenchmarkVerifyMultiple(b *testing.B) { blobElements[j] = bls.FrTo32(&blob[j]) } blobs = append(blobs, blobElements) - c, ok := blobElements.ComputeCommitment() - if !ok { - b.Fatal("Could not compute commitment") - } + c := types.KZGCommitment(kzg.BlobToKZGCommitment(blob)) commitments = append(commitments, c) - hashes = append(hashes, c.ComputeVersionedHash()) + h := common.Hash(kzg.KZGToVersionedHash(kzg.KZGCommitment(c))) + hashes = append(hashes, h) } blobsSet = append(blobsSet, blobs) commitmentsSet = append(commitmentsSet, commitments) @@ -188,41 +189,3 @@ func BenchmarkVerifyMultiple(b *testing.B) { runBenchmark(8) runBenchmark(16) } - -func BenchmarkBatchVerifyWithoutKZGProofs(b *testing.B) { - runBenchmark := func(siz int) { - b.Run(fmt.Sprintf("%d", siz), func(b *testing.B) { - var blobsSet [][][]bls.Fr - var commitmentsSet [][]*bls.G1Point - for i := 0; i < siz; i++ { - var blobs [][]bls.Fr - var commitments []*bls.G1Point - for i := 0; i < params.MaxBlobsPerBlock; i++ { - blob := randomBlob() - blobs = append(blobs, blob) - commitments = append(commitments, kzg.BlobToKzg(blob)) - } - blobsSet = append(blobsSet, blobs) - commitmentsSet = append(commitmentsSet, commitments) - } - - b.ResetTimer() - for i := 0; i < b.N; i++ { - var batchVerify kzg.BlobsBatch - for i := range blobsSet { - if err := batchVerify.Join(commitmentsSet[i], blobsSet[i]); err != nil { - b.Fatalf("unable to join: %v", err) - } - } - if err := batchVerify.Verify(); err != nil { - b.Fatalf("batch verify failed: %v", err) - } - } - }) - } - - //runBenchmark(2) - //runBenchmark(4) - runBenchmark(8) - runBenchmark(16) -} diff --git a/tests/kzg_test.go b/tests/kzg_test.go index 9dca7c47ce95..621bbe35cc10 100644 --- a/tests/kzg_test.go +++ b/tests/kzg_test.go @@ -158,11 +158,13 @@ func TestVerifyBlobs(t *testing.T) { } // Compute KZG commitments for both of the blobs above - kzg1, ok1 := blob1.ComputeCommitment() - kzg2, ok2 := blob2.ComputeCommitment() + frs1, ok1 := blob1.ToKZGBlob() + frs2, ok2 := blob2.ToKZGBlob() if ok1 == false || ok2 == false { - panic("failed to compute commitments") + panic("failed to convert blobs") } + kzg1 := types.KZGCommitment(kzg.BlobToKZGCommitment(frs1)) + kzg2 := types.KZGCommitment(kzg.BlobToKZGCommitment(frs2)) // Create the dummy object with all that data we prepared blobData := types.BlobTxWrapData{ @@ -223,7 +225,7 @@ func TestPointEvaluationTestVector(t *testing.T) { } // Create a commitment - commitment := kzg.BlobToKzg(evalPoly) + commitment := kzg.BlobToKZGCommitment(evalPoly) // Create proof for testing x := uint64(0x42) @@ -241,9 +243,7 @@ func TestPointEvaluationTestVector(t *testing.T) { // panic("failed proof verification") //} - var commitmentBytes types.KZGCommitment - copy(commitmentBytes[:], bls.ToCompressedG1(commitment)) - + commitmentBytes := types.KZGCommitment(commitment) versionedHash := commitmentBytes.ComputeVersionedHash() proofBytes := bls.ToCompressedG1(proof)