Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vkobel/zkp-hash-demo
Prove knowledge of a sha256 pre-image with ZoKrates
https://github.com/vkobel/zkp-hash-demo
Last synced: 25 days ago
JSON representation
Prove knowledge of a sha256 pre-image with ZoKrates
- Host: GitHub
- URL: https://github.com/vkobel/zkp-hash-demo
- Owner: vkobel
- License: mit
- Created: 2024-06-12T18:55:18.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-12T18:57:24.000Z (7 months ago)
- Last Synced: 2024-06-13T01:58:35.680Z (7 months ago)
- Language: Python
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# ZoKrates Hash Demo
Say we want to prove we know the secret value `68656c6c6f20776f726c64`:
```bash
$ python3 padhash.py 68656c6c6f20776f726c64
secretValue: 0 0 0 0 0 6841708 1819222135 1869769828
publicHash: 1379473483 405191205 2428772561 3398226132 3043549376 3391682572 1446190607 1803527562$ mkdir zok-working-dir && cd zok-working-dir
$ zokrates compile -i ../prove_sha256.zok
Compiling ../prove_sha256.zokCompiled code written to 'out'
Number of constraints: 26832$ zokrates compute-witness -a 0 0 0 0 0 6841708 1819222135 1869769828 1379473483 405191205 2428772561 3398226132 3043549376 3391682572 1446190607 1803527562
Computing witness...
Witness file written to 'witness'$ zokrates setup
Performing setup...
Verification key written to 'verification.key'
Proving key written to 'proving.key'
Setup completed$ zokrates generate-proof
Generating proof...
Proof written to 'proof.json'$ zokrates verify
Performing verification...
PASSED$ zokrates export-verifier
Exporting verifier...
Verifier exported to 'verifier.sol'
```## Verification contract (Sepolia)
A verification contract has been deployed: https://sepolia.etherscan.io/address/0x686f9d460637d2ddcdc9407a2adcf240733b9dd8This is just for illustration purposes only, this won't work because the prover key being created here don't match the verifier key embedded in the contract above.