mkdir -p $HOME/.nargo/bin && \
curl -o $HOME/.nargo/bin/nargo-x86_64-unknown-linux-gnu.tar.gz -L https://github.com/noir-lang/noir/releases/download/v0.17.0/nargo-x86_64-unknown-linux-gnu.tar.gz && \
tar -xvf $HOME/.nargo/bin/nargo-x86_64-unknown-linux-gnu.tar.gz -C $HOME/.nargo/bin/ && \
echo -e '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.bashrc && \
source ~/.bashrc
mkdir -p $HOME/.nargo/bin && \
curl -o $HOME/.nargo/bin/nargo-aarch64-apple-darwin.tar.gz -L https://github.com/noir-lang/noir/releases/download/v0.17.0/nargo-aarch64-apple-darwin.tar.gz && \
tar -xvf $HOME/.nargo/bin/nargo-aarch64-apple-darwin.tar.gz -C $HOME/.nargo/bin/ && \
echo '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.zshrc && \
source ~/.zshrc
mkdir -p $HOME/.nargo/bin && \
curl -o $HOME/.nargo/bin/nargo-x86_64-apple-darwin.tar.gz -L https://github.com/noir-lang/noir/releases/download/v0.17.0/nargo-x86_64-apple-darwin.tar.gz && \
tar -xvf $HOME/.nargo/bin/nargo-x86_64-apple-darwin.tar.gz -C $HOME/.nargo/bin/ && \
echo '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.zshrc && \
source ~/.zshrc
nargo new hello_world
cd hello_world
nargo build
nargo check
Example where x is private and y is public
x = "6"
y = "8"
nargo prove
nargo codegen-verifier
Now deploy the UltraVerifier
contract located at circuit/contract/circuit/plonk_vk.sol
to Scroll Sepolia.
If you get the "Stack too deep error" while compiling, retry by enable the optimization to 200.
We will generate storage proofs from this contract.
Deploy this by passing the verifier contract we just deployed
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
interface IUltraVerifier {
function verify(bytes calldata _proof, bytes32[] calldata _publicInputs) external view returns (bool);
}
contract VerificationCounter
{
uint public verifyCount;
IUltraVerifier ultraVerifier;
constructor(address ultraVerifierAddress)
{
ultraVerifier = IUltraVerifier(ultraVerifierAddress);
}
function sendProof(bytes calldata _proof, bytes32[] calldata _publicInputs) public
{
ultraVerifier.verify(_proof, _publicInputs);
verifyCount+=1;
}
}
If you're verifying on remix, copy paste the proof located at circuit/contract/proofs/circuit.proof
and append a 0x
at the begining so remix doesn't complain.
Next set the public input param that you can find on the Verifier.toml
file on the following format ["0x0000000000000000000000000000000000000000000000000000000000000008"]
. In our case this represents y=8
we set as the only public input
Now the verifyCount
variable should be set to 1.
- Inclusions proof demo: https://github.com/Turupawn/EcrecoverInclusionProof
- Noir docs: https://noir-lang.org/docs/
- ZK Mooc: https://www.youtube.com/watch?v=bGEXYpt3sj0
- Scroll and Noir tutorial: https://dev.to/turupawn/aztec-noir-scroll-crea-zk-dapps-facil-40jg
- Intro to ZK en Español: https://www.youtube.com/watch?v=dSlhXtvgbI8&list=PL5LoUunXvIgI2LSiD1xH6MNIHOvMn4SHN