Skip to content

Commit bfb4334

Browse files
committed
Merge branch 'master' into tf/merge-js-test-workflows
* master: feat: codegen typed interfaces for functions in `noir_codegen` (#3533) chore: add dependency on noir_js from docs package (#3559) chore: Docs 0.19.3 (#3545) chore(debugger): Inject abstract foreign call executor to debugger (#3550) chore: nargo fmt (#3549)
2 parents d12c793 + 290c463 commit bfb4334

193 files changed

Lines changed: 12676 additions & 95 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docs-pr.yml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
if: needs.add_label.outputs.has_label == 'true'
5656
steps:
5757
- name: Checkout code
58-
uses: actions/checkout@v2
58+
uses: actions/checkout@v4
5959

6060
- name: Setup Node.js
6161
uses: actions/setup-node@v2
@@ -71,24 +71,8 @@ jobs:
7171
run: |
7272
npm i wasm-opt -g
7373
74-
- name: Install dependencies
75-
run: yarn
76-
77-
- name: Build acvm_js
78-
run: yarn workspace @noir-lang/acvm_js build
79-
80-
- name: Build noirc_abi
81-
run: yarn workspace @noir-lang/noirc_abi build
82-
83-
- name: Build noir_js_types
84-
run: yarn workspace @noir-lang/types build
85-
86-
- name: Build barretenberg wrapper
87-
run: yarn workspace @noir-lang/backend_barretenberg build
88-
89-
- name: Run noir_js
90-
run: |
91-
yarn workspace @noir-lang/noir_js build
74+
- name: Install Yarn dependencies
75+
uses: ./.github/actions/setup
9276

9377
- name: Remove pre-releases
9478
working-directory: docs
@@ -97,8 +81,9 @@ jobs:
9781
run: yarn setStable
9882

9983
- name: Build docs
84+
working-directory: docs
10085
run:
101-
yarn workspace docs build
86+
yarn workspaces foreach -Rt run build
10287

10388
- name: Deploy to Netlify
10489
uses: nwtgck/actions-netlify@v2.1
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: noir_codegen
2+
3+
on:
4+
pull_request:
5+
merge_group:
6+
push:
7+
branches:
8+
- master
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build-nargo:
16+
runs-on: ubuntu-22.04
17+
strategy:
18+
matrix:
19+
target: [x86_64-unknown-linux-gnu]
20+
21+
steps:
22+
- name: Checkout Noir repo
23+
uses: actions/checkout@v4
24+
25+
- name: Setup toolchain
26+
uses: dtolnay/rust-toolchain@1.71.1
27+
28+
- uses: Swatinem/rust-cache@v2
29+
with:
30+
key: ${{ matrix.target }}
31+
cache-on-failure: true
32+
save-if: ${{ github.event_name != 'merge_group' }}
33+
34+
- name: Build Nargo
35+
run: cargo build --package nargo_cli --release
36+
37+
- name: Package artifacts
38+
run: |
39+
mkdir dist
40+
cp ./target/release/nargo ./dist/nargo
41+
7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz
42+
43+
- name: Upload artifact
44+
uses: actions/upload-artifact@v3
45+
with:
46+
name: nargo
47+
path: ./dist/*
48+
retention-days: 3
49+
50+
test:
51+
needs: [build-nargo]
52+
name: Test noir_codegen
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v4
57+
58+
- name: Install Yarn dependencies
59+
uses: ./.github/actions/setup
60+
61+
- name: Setup toolchain
62+
uses: dtolnay/rust-toolchain@1.71.1
63+
with:
64+
targets: wasm32-unknown-unknown
65+
66+
- uses: Swatinem/rust-cache@v2
67+
with:
68+
key: wasm32-unknown-unknown-noir-js
69+
cache-on-failure: true
70+
save-if: ${{ github.event_name != 'merge_group' }}
71+
72+
- name: Install jq
73+
run: sudo apt-get install jq
74+
75+
- name: Install wasm-bindgen-cli
76+
uses: taiki-e/install-action@v2
77+
with:
78+
tool: wasm-bindgen-cli@0.2.86
79+
80+
- name: Install wasm-opt
81+
run: |
82+
npm i wasm-opt -g
83+
84+
- name: Build acvm_js
85+
run: yarn workspace @noir-lang/acvm_js build
86+
87+
- name: Build noirc_abi
88+
run: yarn workspace @noir-lang/noirc_abi build
89+
90+
- name: Build noir_js_types
91+
run: yarn workspace @noir-lang/types build
92+
93+
- name: Build noir_js
94+
run: yarn workspace @noir-lang/noir_js build
95+
96+
- name: Run noir_codegen tests
97+
run: yarn workspace @noir-lang/noir_codegen test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ compiler/wasm/web
5353
tooling/noirc_abi_wasm/nodejs
5454
tooling/noirc_abi_wasm/web
5555
tooling/noir_js/lib
56+
57+
# docs autogen build
58+
/docs/docs/noir_js/reference/

docs/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Generated files
88
.docusaurus
99
.cache-loader
10-
/docs/noir_js/reference/
10+
/docs/docs/noir_js/reference/
1111

1212
# Misc
1313
.DS_Store
@@ -21,4 +21,4 @@ npm-debug.log*
2121
yarn-debug.log*
2222
yarn-error.log*
2323

24-
package-lock.json
24+
package-lock.json

docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@docusaurus/preset-classic": "^2.4.0",
1414
"@easyops-cn/docusaurus-search-local": "^0.35.0",
1515
"@mdx-js/react": "^1.6.22",
16+
"@noir-lang/noir_js": "workspace:*",
1617
"axios": "^1.4.0",
1718
"clsx": "^1.2.1",
1819
"docusaurus-plugin-typedoc": "1.0.0-next.18",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: Merkle Proof Membership
3+
description:
4+
Learn how to use merkle membership proof in Noir to prove that a given leaf is a member of a
5+
merkle tree with a specified root, at a given index.
6+
keywords:
7+
[merkle proof, merkle membership proof, Noir, rust, hash function, Pedersen, sha256, merkle tree]
8+
---
9+
10+
Let's walk through an example of a merkle membership proof in Noir that proves that a given leaf is
11+
in a merkle tree.
12+
13+
```rust
14+
use dep::std;
15+
16+
fn main(message : [Field; 62], index : Field, hashpath : [Field; 40], root : Field) {
17+
let leaf = std::hash::hash_to_field(message);
18+
let merkle_root = std::merkle::compute_merkle_root(leaf, index, hashpath);
19+
assert(merkle_root == root);
20+
}
21+
22+
```
23+
24+
The message is hashed using `hash_to_field`. The specific hash function that is being used is chosen
25+
by the backend. The only requirement is that this hash function can heuristically be used as a
26+
random oracle. If only collision resistance is needed, then one can call `std::hash::pedersen_hash`
27+
instead.
28+
29+
```rust
30+
let leaf = std::hash::hash_to_field(message);
31+
```
32+
33+
The leaf is then passed to a compute_merkle_root function with the root, index and hashpath. The returned root can then be asserted to be the same as the provided root.
34+
35+
```rust
36+
let merkle_root = std::merkle::compute_merkle_root(leaf, index, hashpath);
37+
assert (merkle_root == root);
38+
```
39+
40+
> **Note:** It is possible to re-implement the merkle tree implementation without standard library.
41+
> However, for most usecases, it is enough. In general, the standard library will always opt to be
42+
> as conservative as possible, while striking a balance with efficiency.
43+
44+
An example, the merkle membership proof, only requires a hash function that has collision
45+
resistance, hence a hash function like Pedersen is allowed, which in most cases is more efficient
46+
than the even more conservative sha256.
47+
48+
[View an example on the starter repo](https://github.com/noir-lang/noir-examples/blob/3ea09545cabfa464124ec2f3ea8e60c608abe6df/stealthdrop/circuits/src/main.nr#L20)

0 commit comments

Comments
 (0)