Skip to content

Commit

Permalink
style: remove redundant logs by returning msg in errors (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf authored Sep 28, 2024
1 parent 7d8425c commit 6306286
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
6 changes: 2 additions & 4 deletions encoding/kzg/pointsIO.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ func ReadG2PointOnPowerOf2(exponent uint64, g *KzgConfig) (bn254.G2Affine, error
func ReadG1Points(filepath string, n uint64, numWorker uint64) ([]bn254.G1Affine, error) {
g1f, err := os.Open(filepath)
if err != nil {
log.Println("Cannot ReadG1Points", filepath, err)
return nil, fmt.Errorf("error cannot open g1 points file %w", err)
return nil, fmt.Errorf("error cannot open g1 points file %s: %w", filepath, err)
}

defer func() {
Expand Down Expand Up @@ -170,8 +169,7 @@ func ReadG1PointSection(filepath string, from, to uint64, numWorker uint64) ([]b
}
g1f, err := os.Open(filepath)
if err != nil {
log.Println("ReadG1PointSection.ERR.0", err)
return nil, err
return nil, fmt.Errorf("error cannot open g1 points file %w", err)
}

defer func() {
Expand Down
11 changes: 4 additions & 7 deletions encoding/kzg/verifier/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ func NewVerifier(config *kzg.KzgConfig, loadG2Points bool) (*Verifier, error) {
// read the whole order, and treat it as entire SRS for low degree proof
s1, err := kzg.ReadG1Points(config.G1Path, config.SRSNumberToLoad, config.NumWorker)
if err != nil {
log.Println("failed to read G1 points", err)
return nil, err
return nil, fmt.Errorf("failed to read %d G1 points from %s: %v", config.SRSNumberToLoad, config.G1Path, err)
}

s2 := make([]bn254.G2Affine, 0)
Expand All @@ -56,8 +55,7 @@ func NewVerifier(config *kzg.KzgConfig, loadG2Points bool) (*Verifier, error) {

s2, err = kzg.ReadG2Points(config.G2Path, config.SRSNumberToLoad, config.NumWorker)
if err != nil {
log.Println("failed to read G2 points", err)
return nil, err
return nil, fmt.Errorf("failed to read %d G2 points from %s: %v", config.SRSNumberToLoad, config.G2Path, err)
}

g2Trailing, err = kzg.ReadG2PointSection(
Expand All @@ -67,7 +65,7 @@ func NewVerifier(config *kzg.KzgConfig, loadG2Points bool) (*Verifier, error) {
config.NumWorker,
)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to read trailing G2 points from %s: %v", config.G2Path, err)
}
} else {
if len(config.G2PowerOf2Path) == 0 && len(config.G2Path) == 0 {
Expand All @@ -90,8 +88,7 @@ func NewVerifier(config *kzg.KzgConfig, loadG2Points bool) (*Verifier, error) {
}
srs, err := kzg.NewSrs(s1, s2)
if err != nil {
log.Println("Could not create srs", err)
return nil, err
return nil, fmt.Errorf("failed to create SRS: %v", err)
}

fmt.Println("numthread", runtime.GOMAXPROCS(0))
Expand Down

0 comments on commit 6306286

Please sign in to comment.