公式doc
※ この通りやっても上手くいかない
環境
OS:WSL
nargo:1.0.0-beta.11
noirc:1.0.0-beta.11+fd3925aaaeb76c76319f44590d135498ef41ea6c
bb:1.2.1
Noir関連のインストール
Noirのインストール
curl -L https://raw.githubusercontent.com/noir-lang/noirup/refs/heads/main/install | bash
noirup
noirupが見つからないと言われたら以下を実行
source ~/.bashrc
BBのインストール
以下を実行してもThe requested URL returned error: 404
と言われるので
curl -L https://raw.githubusercontent.com/AztecProtocol/aztec-packages/refs/heads/master/barretenberg/bbup/install | bash
バージョン指定してインストール
bbup -v 1.2.1
証明の作成
Nargoでプロジェクトの開始
今回はhello_world
とする
export pj=hello_world
プロジェクトの初期化
nargo new $pj
hello_world
ディレクトリが作成され、src/main.nr
に回路、Nargo.toml
に環境オプションが生成される
秘密入力x
と公開入力y
が異なることを証明する回路
main.nr
fn main(x: Field, y: pub Field) {
assert(x != y);
}
#[test]
fn test_main() {
main(1, 2);
// Uncomment to make test fail
// main(1, 1);
}
入力値の設定
プロジェクトディレクトリに移動し、入力値指定用のProver.toml
を生成する
cd $pj
nargo check
Prover.toml
を開き、入力値を設定する
Prover.toml
x = "1"
y = "2"
witnessの生成
witnessファイルtarget/witness-name.gz
を生成する
nargo execute
証明の生成と検証
検証鍵を生成
bb write_vk -b ./target/$pj.json -o ./target
証明の生成
bb prove -b ./target/$pj.json -w ./target/$pj.gz -o ./target
証明の検証
bb verify -k ./target/vk -p ./target/proof -i ./target/public_inputs