@@ -6172,7 +6172,7 @@ async function groth16Verify$1(_vk_verifier, _publicSignals, _proof, logger) {
6172
6172
const IC = new Uint8Array ( curve . G1 . F . n8 * 2 * publicSignals . length ) ;
6173
6173
const w = new Uint8Array ( curve . Fr . n8 * publicSignals . length ) ;
6174
6174
6175
- if ( ! publicInputsAreValid$1 ( curve , publicSignals ) ) {
6175
+ if ( ! publicInputsAreValid$2 ( curve , publicSignals ) ) {
6176
6176
if ( logger ) logger . error ( "Public inputs are not valid." ) ;
6177
6177
return false ;
6178
6178
}
@@ -6226,9 +6226,13 @@ function isWellConstructed$1(curve, proof) {
6226
6226
&& G1 . isValid ( proof . pi_c ) ;
6227
6227
}
6228
6228
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 ) {
6230
6234
for ( let i = 0 ; i < publicInputs . length ; i ++ ) {
6231
- if ( ! ffjavascript . Scalar . lt ( publicInputs [ i ] , curve . r ) ) {
6235
+ if ( ! checkValueBelongToField$2 ( curve , publicInputs [ i ] ) ) {
6232
6236
return false ;
6233
6237
}
6234
6238
}
@@ -9044,9 +9048,8 @@ async function plonkFullProve$1(_input, wasmFile, zkeyFileName, logger, wtnsCalc
9044
9048
You should have received a copy of the GNU General Public License along with
9045
9049
snarkjs. If not, see <https://www.gnu.org/licenses/>.
9046
9050
*/
9047
- const { unstringifyBigInts : unstringifyBigInts$5 } = ffjavascript . utils ;
9048
-
9049
9051
9052
+ const { unstringifyBigInts : unstringifyBigInts$5 } = ffjavascript . utils ;
9050
9053
9051
9054
async function plonkVerify$1 ( _vk_verifier , _publicSignals , _proof , logger ) {
9052
9055
let vk_verifier = unstringifyBigInts$5 ( _vk_verifier ) ;
@@ -9064,16 +9067,26 @@ async function plonkVerify$1(_vk_verifier, _publicSignals, _proof, logger) {
9064
9067
vk_verifier = fromObjectVk$1 ( curve , vk_verifier ) ;
9065
9068
9066
9069
if ( ! isWellConstructed ( curve , proof ) ) {
9067
- logger . error ( "Proof is not well constructed " ) ;
9070
+ logger . error ( "Proof commitments are not valid. " ) ;
9068
9071
return false ;
9069
9072
}
9070
9073
9071
9074
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" ) ;
9073
9081
return false ;
9074
9082
}
9083
+
9084
+ if ( ! publicInputsAreValid$1 ( curve , publicSignals ) ) {
9085
+ if ( logger ) logger . error ( "Public inputs are not valid." ) ;
9086
+ return false ;
9087
+ }
9088
+
9075
9089
const challenges = calculatechallenges ( curve , proof , publicSignals , vk_verifier ) ;
9076
-
9077
9090
if ( logger ) {
9078
9091
logger . debug ( "beta: " + Fr . toString ( challenges . beta , 16 ) ) ;
9079
9092
logger . debug ( "gamma: " + Fr . toString ( challenges . gamma , 16 ) ) ;
@@ -9191,6 +9204,32 @@ function isWellConstructed(curve, proof) {
9191
9204
return true ;
9192
9205
}
9193
9206
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
+
9194
9233
function calculatechallenges ( curve , proof , publicSignals , vk ) {
9195
9234
const Fr = curve . Fr ;
9196
9235
const res = { } ;
@@ -11751,7 +11790,7 @@ function commitmentsBelongToG1(curve, proof, vk) {
11751
11790
}
11752
11791
11753
11792
function checkValueBelongToField ( curve , value ) {
11754
- return ffjavascript . Scalar . lt ( value , curve . r ) ;
11793
+ return ffjavascript . Scalar . geq ( value , 0 ) && ffjavascript . Scalar . lt ( value , curve . r ) ;
11755
11794
}
11756
11795
11757
11796
function checkEvaluationIsValid ( curve , evaluation ) {
0 commit comments