From f5e23d89ad8bf3a4172949898ca272869af97368 Mon Sep 17 00:00:00 2001 From: Bowen Xue <93296844+bxue-l2@users.noreply.github.com> Date: Tue, 16 Apr 2024 14:52:43 -0700 Subject: [PATCH] Backward compatibility with using entire g2 (#482) Co-authored-by: Ubuntu --- encoding/kzg/verifier/verifier.go | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/encoding/kzg/verifier/verifier.go b/encoding/kzg/verifier/verifier.go index db8a71cd30..1a3de68eda 100644 --- a/encoding/kzg/verifier/verifier.go +++ b/encoding/kzg/verifier/verifier.go @@ -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)