@@ -6172,7 +6172,7 @@ async function groth16Verify$1(_vk_verifier, _publicSignals, _proof, logger) {
61726172 const IC = new Uint8Array ( curve . G1 . F . n8 * 2 * publicSignals . length ) ;
61736173 const w = new Uint8Array ( curve . Fr . n8 * publicSignals . length ) ;
61746174
6175- if ( ! publicInputsAreValid$1 ( curve , publicSignals ) ) {
6175+ if ( ! publicInputsAreValid$2 ( curve , publicSignals ) ) {
61766176 if ( logger ) logger . error ( "Public inputs are not valid." ) ;
61776177 return false ;
61786178 }
@@ -6226,9 +6226,13 @@ function isWellConstructed$1(curve, proof) {
62266226 && G1 . isValid ( proof . pi_c ) ;
62276227}
62286228
6229- function publicInputsAreValid$1 ( curve , publicInputs ) {
6229+ function checkValueBelongToField$2 ( curve , value ) {
6230+ return ffjavascript . Scalar . geq ( value , 0 ) && ffjavascript . Scalar . lt ( value , curve . r ) ;
6231+ }
6232+
6233+ function publicInputsAreValid$2 ( curve , publicInputs ) {
62306234 for ( let i = 0 ; i < publicInputs . length ; i ++ ) {
6231- if ( ! ffjavascript . Scalar . lt ( publicInputs [ i ] , curve . r ) ) {
6235+ if ( ! checkValueBelongToField$2 ( curve , publicInputs [ i ] ) ) {
62326236 return false ;
62336237 }
62346238 }
@@ -9044,9 +9048,8 @@ async function plonkFullProve$1(_input, wasmFile, zkeyFileName, logger, wtnsCalc
90449048 You should have received a copy of the GNU General Public License along with
90459049 snarkjs. If not, see <https://www.gnu.org/licenses/>.
90469050*/
9047- const { unstringifyBigInts : unstringifyBigInts$5 } = ffjavascript . utils ;
9048-
90499051
9052+ const { unstringifyBigInts : unstringifyBigInts$5 } = ffjavascript . utils ;
90509053
90519054async function plonkVerify$1 ( _vk_verifier , _publicSignals , _proof , logger ) {
90529055 let vk_verifier = unstringifyBigInts$5 ( _vk_verifier ) ;
@@ -9064,16 +9067,26 @@ async function plonkVerify$1(_vk_verifier, _publicSignals, _proof, logger) {
90649067 vk_verifier = fromObjectVk$1 ( curve , vk_verifier ) ;
90659068
90669069 if ( ! isWellConstructed ( curve , proof ) ) {
9067- logger . error ( "Proof is not well constructed " ) ;
9070+ logger . error ( "Proof commitments are not valid. " ) ;
90689071 return false ;
90699072 }
90709073
90719074 if ( publicSignals . length != vk_verifier . nPublic ) {
9072- logger . error ( "Invalid number of public inputs" ) ;
9075+ if ( logger ) logger . error ( "Invalid number of public inputs" ) ;
9076+ return false ;
9077+ }
9078+
9079+ if ( ! evaluationsAreValid$1 ( curve , proof ) ) {
9080+ if ( logger ) logger . error ( "Proof evaluations are not valid" ) ;
90739081 return false ;
90749082 }
9083+
9084+ if ( ! publicInputsAreValid$1 ( curve , publicSignals ) ) {
9085+ if ( logger ) logger . error ( "Public inputs are not valid." ) ;
9086+ return false ;
9087+ }
9088+
90759089 const challenges = calculatechallenges ( curve , proof , publicSignals , vk_verifier ) ;
9076-
90779090 if ( logger ) {
90789091 logger . debug ( "beta: " + Fr . toString ( challenges . beta , 16 ) ) ;
90799092 logger . debug ( "gamma: " + Fr . toString ( challenges . gamma , 16 ) ) ;
@@ -9191,6 +9204,32 @@ function isWellConstructed(curve, proof) {
91919204 return true ;
91929205}
91939206
9207+ function checkValueBelongToField$1 ( curve , value ) {
9208+ return ffjavascript . Scalar . geq ( value , 0 ) && ffjavascript . Scalar . lt ( value , curve . r ) ;
9209+ }
9210+
9211+ function checkEvaluationIsValid$1 ( curve , evaluation ) {
9212+ return checkValueBelongToField$1 ( curve , ffjavascript . Scalar . fromRprLE ( evaluation ) ) ;
9213+ }
9214+
9215+ function evaluationsAreValid$1 ( curve , proof ) {
9216+ return checkEvaluationIsValid$1 ( curve , proof . eval_a )
9217+ && checkEvaluationIsValid$1 ( curve , proof . eval_b )
9218+ && checkEvaluationIsValid$1 ( curve , proof . eval_c )
9219+ && checkEvaluationIsValid$1 ( curve , proof . eval_s1 )
9220+ && checkEvaluationIsValid$1 ( curve , proof . eval_s2 )
9221+ && checkEvaluationIsValid$1 ( curve , proof . eval_zw ) ;
9222+ }
9223+
9224+ function publicInputsAreValid$1 ( curve , publicInputs ) {
9225+ for ( let i = 0 ; i < publicInputs . length ; i ++ ) {
9226+ if ( ! checkValueBelongToField$1 ( curve , publicInputs [ i ] ) ) {
9227+ return false ;
9228+ }
9229+ }
9230+ return true ;
9231+ }
9232+
91949233function calculatechallenges ( curve , proof , publicSignals , vk ) {
91959234 const Fr = curve . Fr ;
91969235 const res = { } ;
@@ -11751,7 +11790,7 @@ function commitmentsBelongToG1(curve, proof, vk) {
1175111790}
1175211791
1175311792function checkValueBelongToField ( curve , value ) {
11754- return ffjavascript . Scalar . lt ( value , curve . r ) ;
11793+ return ffjavascript . Scalar . geq ( value , 0 ) && ffjavascript . Scalar . lt ( value , curve . r ) ;
1175511794}
1175611795
1175711796function checkEvaluationIsValid ( curve , evaluation ) {
0 commit comments