forked from zkonduit/ezkl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: merge
@ezkljs/verify
package into core repo. (zkonduit#736)
- Loading branch information
1 parent
de9e3f2
commit 2be181d
Showing
20 changed files
with
2,031 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ var/ | |
*.whl | ||
*.bak | ||
node_modules | ||
/dist | ||
timingData.json | ||
!tests/wasm/pk.key | ||
!tests/wasm/vk.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# inbrowser-evm-verify | ||
|
||
We would like the Solidity verifier to be canonical and usually all you ever need. For this, we need to be able to run that verifier in browser. | ||
|
||
## How to use (Node js) | ||
|
||
```ts | ||
import localEVMVerify from '@ezkljs/verify'; | ||
|
||
// Load in the proof file as a buffer | ||
const proofFileBuffer = fs.readFileSync(`${path}/${example}/proof.pf`) | ||
|
||
// Stringified EZKL evm verifier bytecode (this is just an example don't use in production) | ||
const bytecode = '0x608060405234801561001057600080fd5b5060d38061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063cfae321714610046575b600080fd5b6100496100f1565b60405161005691906100f1565b60405180910390f35b' | ||
|
||
const result = await localEVMVerify(proofFileBuffer, bytecode) | ||
|
||
console.log('result', result) | ||
``` | ||
|
||
**Note**: Run `ezkl create-evm-verifier` to get the Solidity verifier, with which you can retrieve the bytecode once compiled. We recommend compiling to the Shanghai hardfork target, else you will have to pass an additional parameter specifying the EVM version to the `localEVMVerify` function like so (for Paris hardfork): | ||
|
||
```ts | ||
import localEVMVerify, { hardfork } from '@ezkljs/verify'; | ||
|
||
const result = await localEVMVerify(proofFileBuffer, bytecode, hardfork['Paris']) | ||
``` | ||
|
||
**Note**: You can also verify separated vk verifiers using the `localEVMVerify` function. Just pass the vk verifier bytecode as the third parameter like so: | ||
```ts | ||
import localEVMVerify from '@ezkljs/verify'; | ||
|
||
const result = await localEVMVerify(proofFileBuffer, verifierBytecode, VKBytecode) | ||
``` | ||
|
||
|
||
## How to use (Browser) | ||
|
||
```ts | ||
import localEVMVerify from '@ezkljs/verify'; | ||
|
||
// Load in the proof file as a buffer using the web apis (fetch, FileReader, etc) | ||
// We use fetch in this example to load the proof file as a buffer | ||
const proofFileBuffer = await fetch(`${path}/${example}/proof.pf`).then(res => res.arrayBuffer()) | ||
|
||
// Stringified EZKL evm verifier bytecode (this is just an example don't use in production) | ||
const bytecode = '0x608060405234801561001057600080fd5b5060d38061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063cfae321714610046575b600080fd5b6100496100f1565b60405161005691906100f1565b60405180910390f35b' | ||
|
||
const result = await browserEVMVerify(proofFileBuffer, bytecode) | ||
|
||
console.log('result', result) | ||
``` | ||
|
||
Output: | ||
|
||
```ts | ||
result: true | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "@ezkljs/verify", | ||
"version": "0.0.0", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"description": "Evm verify EZKL proofs in the browser.", | ||
"main": "dist/commonjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/commonjs/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
"scripts": { | ||
"clean": "rm -r dist || true", | ||
"build:commonjs": "tsc --project tsconfig.commonjs.json && resolve-tspaths -p tsconfig.commonjs.json", | ||
"build:esm": "tsc --project tsconfig.esm.json && resolve-tspaths -p tsconfig.esm.json", | ||
"build": "pnpm run clean && pnpm run build:commonjs && pnpm run build:esm" | ||
}, | ||
"dependencies": { | ||
"@ethereumjs/common": "^4.0.0", | ||
"@ethereumjs/evm": "^2.0.0", | ||
"@ethereumjs/statemanager": "^2.0.0", | ||
"@ethereumjs/tx": "^5.0.0", | ||
"@ethereumjs/util": "^9.0.0", | ||
"@ethereumjs/vm": "^7.0.0", | ||
"@ethersproject/abi": "^5.7.0", | ||
"@ezkljs/engine": "^9.4.4", | ||
"ethers": "^6.7.1", | ||
"json-bigint": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.8.3", | ||
"ts-loader": "^9.5.0", | ||
"ts-node": "^10.9.1", | ||
"resolve-tspaths": "^0.8.16", | ||
"tsconfig-paths": "^4.2.0", | ||
"typescript": "^5.2.2" | ||
} | ||
} |
Oops, something went wrong.