Skip to content

Commit

Permalink
Backward compatibility with using entire g2 (#482)
Browse files Browse the repository at this point in the history
Co-authored-by: Ubuntu <[email protected]>
  • Loading branch information
bxue-l2 and Ubuntu authored Apr 16, 2024
1 parent f500a54 commit f5e23d8
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions encoding/kzg/verifier/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,24 @@ func NewVerifier(config *kzg.KzgConfig, loadG2Points bool) (*Verifier, error) {
return nil, err
}
} else {
if len(config.G2PowerOf2Path) == 0 {
return nil, errors.New("G2PowerOf2Path is empty. However, object needs to load G2Points")
if len(config.G2PowerOf2Path) == 0 && len(config.G2Path) == 0 {
return nil, errors.New("both G2Path and G2PowerOf2Path are empty. However, object needs to load G2Points")
}

if config.SRSOrder == 0 {
return nil, errors.New("SRS order cannot be 0")
}

maxPower := uint64(math.Log2(float64(config.SRSOrder)))
_, err := kzg.ReadG2PointSection(config.G2PowerOf2Path, 0, maxPower, 1)
if err != nil {
return nil, fmt.Errorf("file located at %v is invalid", config.G2PowerOf2Path)
if len(config.G2PowerOf2Path) != 0 {
if config.SRSOrder == 0 {
return nil, errors.New("SRS order cannot be 0")
}

maxPower := uint64(math.Log2(float64(config.SRSOrder)))
_, err := kzg.ReadG2PointSection(config.G2PowerOf2Path, 0, maxPower, 1)
if err != nil {
return nil, fmt.Errorf("file located at %v is invalid", config.G2PowerOf2Path)
}
} else {
log.Println("verifier requires accesses to entire g2 points. It is a legacy usage. For most operators, it is likely because G2_POWER_OF_2_PATH is improperly configured.")
}
}

srs, err := kzg.NewSrs(s1, s2)
if err != nil {
log.Println("Could not create srs", err)
Expand Down

0 comments on commit f5e23d8

Please sign in to comment.