0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Noirセットアップ

Posted at

公式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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?