o1-labs / o1js

TypeScript framework for zk-SNARKs and zkApps

Home Page:https://docs.minaprotocol.com/en/zkapps/how-to-write-a-zkapp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Signature related on client `Error: Field.inv: zero`

Pfed-prog opened this issue · comments

Gm, I have been trying to diagnose and solve the following error for more than 24 hours already.

I am running mint function on server and it runs perfectly.

However, when I call the same function on client gives me Error: Field.inv: zero

Full error

    at failwith (:3000/posts/o1js/dist/web/index.js)
    at M_ (:3000/posts/o1js/dist/web/index.js)
    at E_ (:3000/posts/o1js/dist/web/index.js)
    at caml_call2 (:3000/posts/o1js/dist/web/index.js)
    at eval (:3000/posts/o1js/dist/web/index.js)
    at caml_call1 (:3000/posts/o1js/dist/web/index.js)
    at ya (:3000/posts/o1js/dist/web/index.js)
    at caml_call_gen (:3000/posts/o1js/dist/web/index.js)
    at eval (:3000/posts/o1js/dist/web/index.js)
    at caml_call_gen (:3000/posts/o1js/dist/web/index.js)
    at caml_call1 (:3000/posts/o1js/dist/web/index.js)
    at run$3 (:3000/posts/o1js/dist/web/index.js)
    at run$4 (:3000/posts/o1js/dist/web/index.js)
    at caml_call3 (:3000/posts/o1js/dist/web/index.js)
    at eval (:3000/posts/o1js/dist/web/index.js)
    at caml_call1 (:3000/posts/o1js/dist/web/index.js)
    at eval (:3000/posts/o1js/dist/web/index.js)
    at caml_call_gen (:3000/posts/o1js/dist/web/index.js)
    at caml_call_gen (:3000/posts/o1js/dist/web/index.js)
    at caml_call2 (:3000/posts/o1js/dist/web/index.js)
    at I (:3000/posts/o1js/dist/web/index.js)
    at Aa (:3000/posts/o1js/dist/web/index.js)
    at caml_call3 (:3000/posts/o1js/dist/web/index.js)
    at X (:3000/posts/o1js/dist/web/index.js)
    at eval (:3000/posts/o1js/dist/web/index.js)
    at caml_call_gen (:3000/posts/o1js/dist/web/index.js)
    at caml_call_gen (:3000/posts/o1js/dist/web/index.js)
    at caml_call3 (:3000/posts/o1js/dist/web/index.js)
    at q (:3000/posts/o1js/dist/web/index.js)
    at caml_call2 (:3000/posts/o1js/dist/web/index.js)
    at scale$10 (:3000/posts/o1js/dist/web/index.js)
    at caml_call_gen (:3000/posts/o1js/dist/web/index.js)
    at caml_call_gen (:3000/posts/o1js/dist/web/index.js)
    at Object.eval [as scale] (:3000/posts/o1js/dist/web/index.js)
    at g.scale (:3000/posts/o1js/dis…/index.js:2163:4348)
    at Nr (:3000/posts/o1js/dis…index.js:2172:60698)
    at g.verify (:3000/posts/o1js/dis…index.js:2172:60258)
    at MerkleMapContract.verifyAdminItemSignature (NFTsMapContract.js:166:24)
    at MerkleMapContract.mintNFT (NFTsMapContract.js:94:14)
    at MerkleMapContract.eval (:3000/posts/o1js/dis…/index.js:2428:2746)
    at eval (transactions.js:97:27)
    at eval (:3000/posts/o1js/dis…b/index.js:2381:607)
    at caml_call_gen (:3000/posts/o1js/dist/web/index.js)
    at caml_call1 (:3000/posts/o1js/dist/web/index.js)
    at eval (:3000/posts/o1js/dist/web/index.js)
    at caml_call1 (:3000/posts/o1js/dist/web/index.js)
    at eval (:3000/posts/o1js/dist/web/index.js)
    at caml_call1 (:3000/posts/o1js/dist/web/index.js)
    at Xa (:3000/posts/o1js/dist/web/index.js)
    at Ur (:3000/posts/o1js/dist/web/index.js)
    at caml_call1 (:3000/posts/o1js/dist/web/index.js)
    at V (:3000/posts/o1js/dist/web/index.js)
    at caml_call2 (:3000/posts/o1js/dist/web/index.js)
    at R (:3000/posts/o1js/dist/web/index.js)
    at Z (:3000/posts/o1js/dist/web/index.js)
    at caml_call2 (:3000/posts/o1js/dist/web/index.js)
    at eval (:3000/posts/o1js/dist/web/index.js)
    at caml_call1 (:3000/posts/o1js/dist/web/index.js)
    at $e (:3000/posts/o1js/dist/web/index.js)
    at De (:3000/posts/o1js/dist/web/index.js)
    at caml_call1 (:3000/posts/o1js/dist/web/index.js)
    at run_unchecked$3 (:3000/posts/o1js/dist/web/index.js)
    at caml_call_gen (:3000/posts/o1js/dist/web/index.js)
    at caml_call_gen (:3000/posts/o1js/dist/web/index.js)
    at Object.eval [as runUnchecked] (:3000/posts/o1js/dist/web/index.js)
    at Object.An [as runUnchecked] (:3000/posts/o1js/dis…index.js:2144:11176)
    at qt (:3000/posts/o1js/dis…b/index.js:2381:589)
    at Object.transaction (:3000/posts/o1js/dis…b/index.js:2414:155)
    at Object.gE (:3000/posts/o1js/dis…b/index.js:2383:182)
    at createMintTx (transactions.js:96:64)
    at async mintNFT (transactions.js:89:21)
    at async mintNFTwithMap (transactions.js:79:5)
    at async mintNFTClient (MediaDetails.tsx:80:7)
    at async onClick (MediaDetails.tsx:173:38)
failwith	@	VM30982:2031
M_	@	VM30982:2031
E_	@	VM30982:2031
caml_call2	@	VM30982:6
eval	@	VM30982:2031
caml_call1	@	VM30982:6
ya	@	VM30982:2031
caml_call_gen	@	VM30982:4
eval	@	VM30982:4
caml_call_gen	@	VM30982:4
caml_call1	@	VM30982:6
run$3	@	VM30982:2031
run$4	@	VM30982:2031
caml_call3	@	VM30982:6
eval	@	VM30982:2031
caml_call1	@	VM30982:6
eval	@	VM30982:2031
caml_call_gen	@	VM30982:4
caml_call_gen	@	VM30982:4
caml_call2	@	VM30982:6
I	@	VM30982:2031
Aa	@	VM30982:2031
caml_call3	@	VM30982:6
X	@	VM30982:2031
eval	@	VM30982:2031
caml_call_gen	@	VM30982:4
caml_call_gen	@	VM30982:4
caml_call3	@	VM30982:6
q	@	VM30982:2031
caml_call2	@	VM30982:6
scale$10	@	VM30982:2031
caml_call_gen	@	VM30982:4
caml_call_gen	@	VM30982:4
eval	@	VM30982:4
scale	@	index.js:2163
Nr	@	index.js:2172
verify	@	index.js:2172
verifyAdminItemSignature	@	NFTsMapContract.js:166
mintNFT	@	NFTsMapContract.js:94
eval	@	index.js:2428
eval	@	transactions.js:97
eval	@	index.js:2381
caml_call_gen	@	VM30982:4
caml_call1	@	VM30982:6
eval	@	VM30982:2031
caml_call1	@	VM30982:6
eval	@	VM30982:2031
caml_call1	@	VM30982:6
Xa	@	VM30982:2031
Ur	@	VM30982:2031
caml_call1	@	VM30982:6
V	@	VM30982:2031
caml_call2	@	VM30982:6
R	@	VM30982:2031
Z	@	VM30982:2031
caml_call2	@	VM30982:6
eval	@	VM30982:2031
caml_call1	@	VM30982:6
$e	@	VM30982:2031
De	@	VM30982:2031
caml_call1	@	VM30982:6
run_unchecked$3	@	VM30982:2031
caml_call_gen	@	VM30982:4
caml_call_gen	@	VM30982:4
eval	@	VM30982:4
An	@	index.js:2144
qt	@	index.js:2381
transaction	@	index.js:2414
gE	@	index.js:2383
createMintTx	@	transactions.js:96
Объект await in createMintTx (асинхронный)		
callCallback	@	react-dom.development.js:4164
invokeGuardedCallbackDev	@	react-dom.development.js:4213
invokeGuardedCallback	@	react-dom.development.js:4277
invokeGuardedCallbackAndCatchFirstError	@	react-dom.development.js:4291
executeDispatch	@	react-dom.development.js:9041
processDispatchQueueItemsInOrder	@	react-dom.development.js:9073
processDispatchQueue	@	react-dom.development.js:9086
dispatchEventsForPlugins	@	react-dom.development.js:9097
eval	@	react-dom.development.js:9288
batchedUpdates$1	@	react-dom.development.js:26135
batchedUpdates	@	react-dom.development.js:3991
dispatchEventForPluginEventSystem	@	react-dom.development.js:9287
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay	@	react-dom.development.js:6465
dispatchEvent	@	react-dom.development.js:6457
dispatchDiscreteEvent	@	react-dom.development.js:6430

This function works perfectly without signature verification on client. It only stops working on client with signature verification. The parameters passed were the same.

Contract
https://github.com/Pfed-prog/Dspyt-NFTs-EVM/blob/master/packages/mina/src/NFTsMapContract.ts
Tests on the BE https://github.com/Pfed-prog/Dspyt-NFTs-EVM/blob/master/packages/mina/src/NFTsMapContract.test.ts

The difference is probably not between 'client' and 'server' but between the context that the method is called in. I could imagine that when the admin key is a dummy, the signature verification fails. Would be helpful if you came up with a minimal example of how the method is called, from a Node.js script, which reproduces the error

Yes, I think I found an error

The contract call as in tests after the
await fetchAccount({ publicKey: zkAppInstance.address }); is called