From 249f3bd1dbc03bf958ee2331435b0e688567e90a Mon Sep 17 00:00:00 2001 From: Gautam Botrel Date: Fri, 25 Mar 2022 16:20:29 -0500 Subject: [PATCH] build: fix gosec warnings --- internal/backend/bls12-377/plonk/prove.go | 4 +++- internal/backend/bls12-377/plonk/verify.go | 4 +++- internal/backend/bls12-381/plonk/prove.go | 4 +++- internal/backend/bls12-381/plonk/verify.go | 4 +++- internal/backend/bls24-315/plonk/prove.go | 4 +++- internal/backend/bls24-315/plonk/verify.go | 4 +++- internal/backend/bn254/plonk/prove.go | 4 +++- internal/backend/bn254/plonk/verify.go | 4 +++- internal/backend/bw6-633/plonk/prove.go | 4 +++- internal/backend/bw6-633/plonk/verify.go | 4 +++- internal/backend/bw6-761/plonk/prove.go | 4 +++- internal/backend/bw6-761/plonk/verify.go | 4 +++- .../backend/template/zkpschemes/plonk/plonk.prove.go.tmpl | 4 +++- .../backend/template/zkpschemes/plonk/plonk.verify.go.tmpl | 4 +++- 14 files changed, 42 insertions(+), 14 deletions(-) diff --git a/internal/backend/bls12-377/plonk/prove.go b/internal/backend/bls12-377/plonk/prove.go index ecbf54c532..ac706ba639 100644 --- a/internal/backend/bls12-377/plonk/prove.go +++ b/internal/backend/bls12-377/plonk/prove.go @@ -113,7 +113,9 @@ func Prove(spr *cs.SparseR1CS, pk *ProvingKey, fullWitness bls12_377witness.Witn // The first challenge is derived using the public data: the commitments to the permutation, // the coefficients of the circuit, and the public inputs. // derive gamma from the Comm(blinded cl), Comm(blinded cr), Comm(blinded co) - bindPublicData(&fs, "gamma", *pk.Vk, fullWitness[:spr.NbPublicVariables]) + if err := bindPublicData(&fs, "gamma", *pk.Vk, fullWitness[:spr.NbPublicVariables]); err != nil { + return nil, err + } bgamma, err := fs.ComputeChallenge("gamma") if err != nil { return nil, err diff --git a/internal/backend/bls12-377/plonk/verify.go b/internal/backend/bls12-377/plonk/verify.go index e466b77cf1..b870275384 100644 --- a/internal/backend/bls12-377/plonk/verify.go +++ b/internal/backend/bls12-377/plonk/verify.go @@ -52,7 +52,9 @@ func Verify(proof *Proof, vk *VerifyingKey, publicWitness bls12_377witness.Witne // The first challenge is derived using the public data: the commitments to the permutation, // the coefficients of the circuit, and the public inputs. // derive gamma from the Comm(blinded cl), Comm(blinded cr), Comm(blinded co) - bindPublicData(&fs, "gamma", *vk, publicWitness) + if err := bindPublicData(&fs, "gamma", *vk, publicWitness); err != nil { + return err + } bgamma, err := fs.ComputeChallenge("gamma") if err != nil { return err diff --git a/internal/backend/bls12-381/plonk/prove.go b/internal/backend/bls12-381/plonk/prove.go index e145b43352..9dcb837465 100644 --- a/internal/backend/bls12-381/plonk/prove.go +++ b/internal/backend/bls12-381/plonk/prove.go @@ -113,7 +113,9 @@ func Prove(spr *cs.SparseR1CS, pk *ProvingKey, fullWitness bls12_381witness.Witn // The first challenge is derived using the public data: the commitments to the permutation, // the coefficients of the circuit, and the public inputs. // derive gamma from the Comm(blinded cl), Comm(blinded cr), Comm(blinded co) - bindPublicData(&fs, "gamma", *pk.Vk, fullWitness[:spr.NbPublicVariables]) + if err := bindPublicData(&fs, "gamma", *pk.Vk, fullWitness[:spr.NbPublicVariables]); err != nil { + return nil, err + } bgamma, err := fs.ComputeChallenge("gamma") if err != nil { return nil, err diff --git a/internal/backend/bls12-381/plonk/verify.go b/internal/backend/bls12-381/plonk/verify.go index 07b645e9be..75eac3139b 100644 --- a/internal/backend/bls12-381/plonk/verify.go +++ b/internal/backend/bls12-381/plonk/verify.go @@ -52,7 +52,9 @@ func Verify(proof *Proof, vk *VerifyingKey, publicWitness bls12_381witness.Witne // The first challenge is derived using the public data: the commitments to the permutation, // the coefficients of the circuit, and the public inputs. // derive gamma from the Comm(blinded cl), Comm(blinded cr), Comm(blinded co) - bindPublicData(&fs, "gamma", *vk, publicWitness) + if err := bindPublicData(&fs, "gamma", *vk, publicWitness); err != nil { + return err + } bgamma, err := fs.ComputeChallenge("gamma") if err != nil { return err diff --git a/internal/backend/bls24-315/plonk/prove.go b/internal/backend/bls24-315/plonk/prove.go index a3a899fceb..17769165b0 100644 --- a/internal/backend/bls24-315/plonk/prove.go +++ b/internal/backend/bls24-315/plonk/prove.go @@ -113,7 +113,9 @@ func Prove(spr *cs.SparseR1CS, pk *ProvingKey, fullWitness bls24_315witness.Witn // The first challenge is derived using the public data: the commitments to the permutation, // the coefficients of the circuit, and the public inputs. // derive gamma from the Comm(blinded cl), Comm(blinded cr), Comm(blinded co) - bindPublicData(&fs, "gamma", *pk.Vk, fullWitness[:spr.NbPublicVariables]) + if err := bindPublicData(&fs, "gamma", *pk.Vk, fullWitness[:spr.NbPublicVariables]); err != nil { + return nil, err + } bgamma, err := fs.ComputeChallenge("gamma") if err != nil { return nil, err diff --git a/internal/backend/bls24-315/plonk/verify.go b/internal/backend/bls24-315/plonk/verify.go index a72f21407c..74000b5210 100644 --- a/internal/backend/bls24-315/plonk/verify.go +++ b/internal/backend/bls24-315/plonk/verify.go @@ -52,7 +52,9 @@ func Verify(proof *Proof, vk *VerifyingKey, publicWitness bls24_315witness.Witne // The first challenge is derived using the public data: the commitments to the permutation, // the coefficients of the circuit, and the public inputs. // derive gamma from the Comm(blinded cl), Comm(blinded cr), Comm(blinded co) - bindPublicData(&fs, "gamma", *vk, publicWitness) + if err := bindPublicData(&fs, "gamma", *vk, publicWitness); err != nil { + return err + } bgamma, err := fs.ComputeChallenge("gamma") if err != nil { return err diff --git a/internal/backend/bn254/plonk/prove.go b/internal/backend/bn254/plonk/prove.go index 132d3f4ee5..ef13b9b47f 100644 --- a/internal/backend/bn254/plonk/prove.go +++ b/internal/backend/bn254/plonk/prove.go @@ -113,7 +113,9 @@ func Prove(spr *cs.SparseR1CS, pk *ProvingKey, fullWitness bn254witness.Witness, // The first challenge is derived using the public data: the commitments to the permutation, // the coefficients of the circuit, and the public inputs. // derive gamma from the Comm(blinded cl), Comm(blinded cr), Comm(blinded co) - bindPublicData(&fs, "gamma", *pk.Vk, fullWitness[:spr.NbPublicVariables]) + if err := bindPublicData(&fs, "gamma", *pk.Vk, fullWitness[:spr.NbPublicVariables]); err != nil { + return nil, err + } bgamma, err := fs.ComputeChallenge("gamma") if err != nil { return nil, err diff --git a/internal/backend/bn254/plonk/verify.go b/internal/backend/bn254/plonk/verify.go index 8cc7b9c2f2..c3ebb39fb5 100644 --- a/internal/backend/bn254/plonk/verify.go +++ b/internal/backend/bn254/plonk/verify.go @@ -52,7 +52,9 @@ func Verify(proof *Proof, vk *VerifyingKey, publicWitness bn254witness.Witness) // The first challenge is derived using the public data: the commitments to the permutation, // the coefficients of the circuit, and the public inputs. // derive gamma from the Comm(blinded cl), Comm(blinded cr), Comm(blinded co) - bindPublicData(&fs, "gamma", *vk, publicWitness) + if err := bindPublicData(&fs, "gamma", *vk, publicWitness); err != nil { + return err + } bgamma, err := fs.ComputeChallenge("gamma") if err != nil { return err diff --git a/internal/backend/bw6-633/plonk/prove.go b/internal/backend/bw6-633/plonk/prove.go index c221fd83ea..4d9996ddc6 100644 --- a/internal/backend/bw6-633/plonk/prove.go +++ b/internal/backend/bw6-633/plonk/prove.go @@ -113,7 +113,9 @@ func Prove(spr *cs.SparseR1CS, pk *ProvingKey, fullWitness bw6_633witness.Witnes // The first challenge is derived using the public data: the commitments to the permutation, // the coefficients of the circuit, and the public inputs. // derive gamma from the Comm(blinded cl), Comm(blinded cr), Comm(blinded co) - bindPublicData(&fs, "gamma", *pk.Vk, fullWitness[:spr.NbPublicVariables]) + if err := bindPublicData(&fs, "gamma", *pk.Vk, fullWitness[:spr.NbPublicVariables]); err != nil { + return nil, err + } bgamma, err := fs.ComputeChallenge("gamma") if err != nil { return nil, err diff --git a/internal/backend/bw6-633/plonk/verify.go b/internal/backend/bw6-633/plonk/verify.go index 3f2a5418a4..2287cf75cd 100644 --- a/internal/backend/bw6-633/plonk/verify.go +++ b/internal/backend/bw6-633/plonk/verify.go @@ -52,7 +52,9 @@ func Verify(proof *Proof, vk *VerifyingKey, publicWitness bw6_633witness.Witness // The first challenge is derived using the public data: the commitments to the permutation, // the coefficients of the circuit, and the public inputs. // derive gamma from the Comm(blinded cl), Comm(blinded cr), Comm(blinded co) - bindPublicData(&fs, "gamma", *vk, publicWitness) + if err := bindPublicData(&fs, "gamma", *vk, publicWitness); err != nil { + return err + } bgamma, err := fs.ComputeChallenge("gamma") if err != nil { return err diff --git a/internal/backend/bw6-761/plonk/prove.go b/internal/backend/bw6-761/plonk/prove.go index 0e0ab8d599..8dc55a08ba 100644 --- a/internal/backend/bw6-761/plonk/prove.go +++ b/internal/backend/bw6-761/plonk/prove.go @@ -113,7 +113,9 @@ func Prove(spr *cs.SparseR1CS, pk *ProvingKey, fullWitness bw6_761witness.Witnes // The first challenge is derived using the public data: the commitments to the permutation, // the coefficients of the circuit, and the public inputs. // derive gamma from the Comm(blinded cl), Comm(blinded cr), Comm(blinded co) - bindPublicData(&fs, "gamma", *pk.Vk, fullWitness[:spr.NbPublicVariables]) + if err := bindPublicData(&fs, "gamma", *pk.Vk, fullWitness[:spr.NbPublicVariables]); err != nil { + return nil, err + } bgamma, err := fs.ComputeChallenge("gamma") if err != nil { return nil, err diff --git a/internal/backend/bw6-761/plonk/verify.go b/internal/backend/bw6-761/plonk/verify.go index 083bc47bab..403f031607 100644 --- a/internal/backend/bw6-761/plonk/verify.go +++ b/internal/backend/bw6-761/plonk/verify.go @@ -52,7 +52,9 @@ func Verify(proof *Proof, vk *VerifyingKey, publicWitness bw6_761witness.Witness // The first challenge is derived using the public data: the commitments to the permutation, // the coefficients of the circuit, and the public inputs. // derive gamma from the Comm(blinded cl), Comm(blinded cr), Comm(blinded co) - bindPublicData(&fs, "gamma", *vk, publicWitness) + if err := bindPublicData(&fs, "gamma", *vk, publicWitness); err != nil { + return err + } bgamma, err := fs.ComputeChallenge("gamma") if err != nil { return err diff --git a/internal/generator/backend/template/zkpschemes/plonk/plonk.prove.go.tmpl b/internal/generator/backend/template/zkpschemes/plonk/plonk.prove.go.tmpl index b7c7c7528b..e6a9b4f89e 100644 --- a/internal/generator/backend/template/zkpschemes/plonk/plonk.prove.go.tmpl +++ b/internal/generator/backend/template/zkpschemes/plonk/plonk.prove.go.tmpl @@ -90,7 +90,9 @@ func Prove(spr *cs.SparseR1CS, pk *ProvingKey, fullWitness {{ toLower .CurveID } // The first challenge is derived using the public data: the commitments to the permutation, // the coefficients of the circuit, and the public inputs. // derive gamma from the Comm(blinded cl), Comm(blinded cr), Comm(blinded co) - bindPublicData(&fs, "gamma", *pk.Vk, fullWitness[:spr.NbPublicVariables]) + if err := bindPublicData(&fs, "gamma", *pk.Vk, fullWitness[:spr.NbPublicVariables]); err != nil { + return nil, err + } bgamma, err := fs.ComputeChallenge("gamma") if err != nil { return nil, err diff --git a/internal/generator/backend/template/zkpschemes/plonk/plonk.verify.go.tmpl b/internal/generator/backend/template/zkpschemes/plonk/plonk.verify.go.tmpl index 0f45d9b6b3..7d896107bb 100644 --- a/internal/generator/backend/template/zkpschemes/plonk/plonk.verify.go.tmpl +++ b/internal/generator/backend/template/zkpschemes/plonk/plonk.verify.go.tmpl @@ -31,7 +31,9 @@ func Verify(proof *Proof, vk *VerifyingKey, publicWitness {{ toLower .CurveID }} // The first challenge is derived using the public data: the commitments to the permutation, // the coefficients of the circuit, and the public inputs. // derive gamma from the Comm(blinded cl), Comm(blinded cr), Comm(blinded co) - bindPublicData(&fs, "gamma", *vk, publicWitness) + if err := bindPublicData(&fs, "gamma", *vk, publicWitness); err != nil { + return err + } bgamma, err := fs.ComputeChallenge("gamma") if err != nil { return err