5
5
"errors"
6
6
"fmt"
7
7
"io"
8
- "math/big"
9
8
10
9
"github.com/ethereum/go-ethereum/common"
11
10
"github.com/ethereum/go-ethereum/common/hexutil"
@@ -328,13 +327,12 @@ func (blobs Blobs) ComputeCommitmentsAndAggregatedProof() (commitments []KZGComm
328
327
if err != nil {
329
328
return nil , nil , KZGProof {}, err
330
329
}
331
- var z bls.Fr
332
- hashToFr (& z , sum )
330
+ z := kzg .BytesToBLSField (sum )
333
331
334
332
var y bls.Fr
335
- kzg .EvaluatePolyInEvaluationForm (& y , aggregatePoly [:], & z )
333
+ kzg .EvaluatePolyInEvaluationForm (& y , aggregatePoly [:], z )
336
334
337
- aggProofG1 , err := kzg .ComputeProof (aggregatePoly , & z )
335
+ aggProofG1 , err := kzg .ComputeProof (aggregatePoly , z )
338
336
if err != nil {
339
337
return nil , nil , KZGProof {}, err
340
338
}
@@ -465,17 +463,16 @@ func (b *BlobTxWrapData) verifyBlobs(inner TxData) error {
465
463
if err != nil {
466
464
return err
467
465
}
468
- var z bls.Fr
469
- hashToFr (& z , sum )
466
+ z := kzg .BytesToBLSField (sum )
470
467
471
468
var y bls.Fr
472
- kzg .EvaluatePolyInEvaluationForm (& y , aggregatePoly [:], & z )
469
+ kzg .EvaluatePolyInEvaluationForm (& y , aggregatePoly [:], z )
473
470
474
471
aggregateProofG1 , err := bls .FromCompressedG1 (b .KzgAggregatedProof [:])
475
472
if err != nil {
476
473
return fmt .Errorf ("aggregate proof parse error: %v" , err )
477
474
}
478
- if ! kzg .VerifyKZGProofFromPoints (aggregateCommitmentG1 , & z , & y , aggregateProofG1 ) {
475
+ if ! kzg .VerifyKZGProofFromPoints (aggregateCommitmentG1 , z , & y , aggregateProofG1 ) {
479
476
return errors .New ("failed to verify kzg" )
480
477
}
481
478
return nil
@@ -524,10 +521,9 @@ func computeAggregateKzgCommitment(blobs Blobs, commitments []KZGCommitment) ([]
524
521
if err != nil {
525
522
return nil , nil , err
526
523
}
527
- var r bls.Fr
528
- hashToFr (& r , sum )
524
+ r := kzg .BytesToBLSField (sum )
529
525
530
- powers := kzg .ComputePowers (& r , len (blobs ))
526
+ powers := kzg .ComputePowers (r , len (blobs ))
531
527
532
528
commitmentsG1 := make ([]bls.G1Point , len (commitments ))
533
529
for i := 0 ; i < len (commitmentsG1 ); i ++ {
@@ -548,13 +544,3 @@ func computeAggregateKzgCommitment(blobs Blobs, commitments []KZGCommitment) ([]
548
544
}
549
545
return aggregatePoly , aggregateCommitmentG1 , nil
550
546
}
551
-
552
- func hashToFr (out * bls.Fr , h [32 ]byte ) {
553
- // re-interpret as little-endian
554
- var b [32 ]byte = h
555
- for i := 0 ; i < 16 ; i ++ {
556
- b [31 - i ], b [i ] = b [i ], b [31 - i ]
557
- }
558
- zB := new (big.Int ).Mod (new (big.Int ).SetBytes (b [:]), kzg .BLSModulus )
559
- _ = kzg .BigToFr (out , zB )
560
- }
0 commit comments