Skip to content

Commit

Permalink
feat: refactor, generics, bugfixes, and other nits (#23)
Browse files Browse the repository at this point in the history
* feat(merkle-trees): update to noir v0.36.0

* feat(merkle-trees): wip

* feat(merkle-trees): wip

* feat(merkle-trees): wip

* feat!: ready for noir 0.36.0

* fix: fix github actions noir version

* fix(merkle-trees): fix bug in MT add function

* fixing bug in MT implementation

* feat: making MTs generic, wip

* feat: making MTs generic, needs a test

* done, this is it, this is the thing

* done, this is it, this is the thing

* done, this is it, this is the thing

* changes according to PR, bumped Noir version too ahead of the 1.0.0-beta.0 release

* changes according to PR, bumped Noir version too ahead of the 1.0.0-beta.0 release
  • Loading branch information
signorecello authored Dec 11, 2024
1 parent 19da08d commit 28044a7
Show file tree
Hide file tree
Showing 44 changed files with 1,021 additions and 5,568 deletions.
9 changes: 1 addition & 8 deletions .dprint.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
"semiColons": "asi",
"useBraces": "preferNone",
},
"excludes": [
"**/node_modules",
"yarn.lock",
".yarn",
"packages/merkle-trees/src/globals.nr",
"packages/ecdh/src/globals.nr",
"target/",
],
"excludes": ["**/node_modules", "bun.lockb", "packages/ecdh/src/globals.nr", "target/"],
"plugins": [
"https://plugins.dprint.dev/json-0.19.4.wasm",
"https://plugins.dprint.dev/markdown-0.17.8.wasm",
Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] My changes generate no new warnings
- [ ] I have run `yarn test` without getting any errors
- [ ] I have run `bun run test` without getting any errors
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
79 changes: 39 additions & 40 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,48 @@
name: main

on:
push:
branches: [main]
pull_request:
push:
branches: [main]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
changed-files:
runs-on: ubuntu-latest
outputs:
any_nr_changed: ${{ steps.changed-files.outputs.any_changed }}
steps:
- uses: actions/checkout@v4
- uses: tj-actions/changed-files@v44
id: changed-files
with:
files: |
packages/**/*.{nr,toml}
Nargo.toml
changed-files:
runs-on: ubuntu-latest
outputs:
any_nr_changed: ${{ steps.changed-files.outputs.any_changed }}
steps:
- uses: actions/checkout@v4
- uses: tj-actions/changed-files@v44
id: changed-files
with:
files: |
packages/**/*.{nr,toml}
Nargo.toml
style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
- uses: noir-lang/[email protected]
with:
toolchain: 0.36.0
- run: yarn
- run: yarn check
style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- uses: noir-lang/[email protected]
with:
toolchain: 0.39.0
- run: bun i
- run: bun fmt

test:
needs: changed-files
if: needs.changed-files.outputs.any_nr_changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: noir-lang/[email protected]
with:
toolchain: 0.36.0
- run: nargo test
test:
needs: changed-files
if: needs.changed-files.outputs.any_nr_changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: noir-lang/[email protected]
with:
toolchain: 0.39.0
- run: nargo test
17 changes: 8 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,26 @@ jobs:
with:
fetch-depth: 0

- name: Install Node.js
uses: actions/setup-node@v4
- name: Install Node.js and Bun
uses: oven-sh/setup-bun@v2
with:
node-version: 20
cache: yarn
registry-url: "https://registry.npmjs.org"
bun-version: latest

- name: Authentication
run: |
echo npmAuthToken: "$NODE_AUTH_TOKEN" >> ./.yarnrc.yml
echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Install dependencies
run: yarn
run: bun install

- name: Publish packages
run: yarn version:publish
run: bun run version:publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- run: yarn version:release
- name: Create GitHub Release
run: bun run version:release
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
13 changes: 0 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Logs
logs
*.log
yarn-debug.log*
yarn-error.log*

# Nargo Compile
target/
Expand All @@ -29,8 +27,6 @@ node_modules/
# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
Expand All @@ -43,15 +39,6 @@ node_modules/
.npm
.DS_Store

# Yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.envrc
.tool-versions
target
2 changes: 1 addition & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"**/*.{js,json,md,nr,toml,yml,yaml}": "yarn fmt"
"**/*.{js,json,md,nr,toml,yml,yaml}": "bun fmt"
}
3 changes: 1 addition & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# dependencies
node_modules
yarn.lock
.yarn
bun.lockb

# github
.github/ISSUE_TEMPLATE
Expand Down
23 changes: 0 additions & 23 deletions .yarn/patches/changelogithub-npm-0.13.3-1783949906.patch

This file was deleted.

894 changes: 0 additions & 894 deletions .yarn/releases/yarn-4.2.1.cjs

This file was deleted.

9 changes: 0 additions & 9 deletions .yarnrc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ When you submit your PR (or later change that code), a CI build will automatical

### Code rules

We always use ESLint and Prettier. To check that your code follows the rules, simply run the npm script `yarn lint`.
We always use ESLint and Prettier. To check that your code follows the rules, simply run the npm script `bun lint`.

### Commits rules

Expand Down
2 changes: 1 addition & 1 deletion Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[workspace]
members = ["packages/ecdh", "packages/merkle-trees"]
members = ["packages/ecdh", "packages/merkle-trees", "tests"]
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
## 🗂️ Repositories

- Javascript: https://github.com/privacy-scaling-explorations/zk-kit
- Solidity: https://github.com/privacy-scaling-explorations/zk-kit.solidity
- Circom: https://github.com/privacy-scaling-explorations/zk-kit.circom
- Noir: https://github.com/privacy-scaling-explorations/zk-kit.noir
- Javascript: <https://github.com/privacy-scaling-explorations/zk-kit>
- Solidity: <https://github.com/privacy-scaling-explorations/zk-kit.solidity>
- Circom: <https://github.com/privacy-scaling-explorations/zk-kit.circom>
- Noir: <https://github.com/privacy-scaling-explorations/zk-kit.noir>

## 📦 Packages

Expand All @@ -72,7 +72,7 @@
- 🐛 Create a report if you find any [bugs](https://github.com/privacy-scaling-explorations/zk-kit.noir/issues/new?assignees=&labels=bug+%F0%9F%90%9B&template=---bug.md&title=) in the code

> [!NOTE]\
> Need inspiration? Check this list of circuits from the Aztec team: https://aztecnetwork.notion.site/f06968995c124de1be359459775ca2cb?v=613d3cb893dd46899a5bd3793b01e63b.
> Need inspiration? Check this list of circuits from the Aztec team: <https://aztecnetwork.notion.site/f06968995c124de1be359459775ca2cb?v=613d3cb893dd46899a5bd3793b01e63b>.
## 🛠 Install

Expand All @@ -85,7 +85,7 @@ git clone https://github.com/privacy-scaling-explorations/zk-kit.noir.git
and install the dependencies:

```bash
cd zk-kit.noir && yarn
cd zk-kit.noir && bun
```

## 📜 Usage
Expand All @@ -103,5 +103,5 @@ git commit
Test the code with:

```bash
yarn test
bun run test
```
Binary file added bun.lockb
Binary file not shown.
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"fmt": "concurrently -c auto -n dprint,noirfmt 'dprint fmt' 'nargo fmt'",
"postinstall": "husky && git config --local core.editor cat",
"build": "nargo compile",
"test": "npm run build && mocha && nargo test --workspace",
"version:release": "changelogithub"
"test": "bun run build && mocha && nargo test --workspace",
"version:release": "bunx changelogithub"
},
"keywords": [
"zk-kit",
Expand All @@ -24,17 +24,15 @@
"workspaces": [
"packages/*"
],
"packageManager": "[email protected]",
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@noir-lang/backend_barretenberg": "^0.30.0",
"@noir-lang/noir_js": "^0.30.0",
"@noir-lang/noir_wasm": "^0.32.0",
"@aztec/bb.js": "^0.63.0",
"@noir-lang/noir_js": "^0.39.0",
"@noir-lang/noir_wasm": "^0.39.0",
"@types/chai": "^4",
"@types/mocha": "^10",
"chai": "^4.5.0",
"changelogithub": "patch:changelogithub@npm%3A0.13.3#~/.yarn/patches/changelogithub-npm-0.13.3-1783949906.patch",
"concurrently": "^9.1.0",
"czg": "^1.9.1",
"dprint": "^0.46.3",
Expand Down
5 changes: 4 additions & 1 deletion packages/ecdh/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
name = "ecdh"
type = "bin"
authors = ["YashBit"]
compiler_version = ">=0.30.0"
compiler_version = ">=0.39.0"

[dependencies]
ec = { tag = "v0.1.2", git = "https://github.com/noir-lang/ec" }
68 changes: 68 additions & 0 deletions packages/ecdh/Prover.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
private_key1 = [
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
]
private_key2 = [
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
]
Loading

0 comments on commit 28044a7

Please sign in to comment.