Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push]

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
Expand Down
10 changes: 5 additions & 5 deletions apps/interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"_chore": "pnpm i"
},
"dependencies": {
"@aztec/aztec.js": "0.72.1",
"@aztec/foundation": "0.72.1",
"@aztec/aztec.js": "0.86.0",
"@aztec/foundation": "0.86.0",
"@hpke/core": "^1.7.1",
"@hpke/dhkem-x25519": "^1.6.1",
"@noir-lang/acvm_js": "1.0.0-beta.3",
"@noir-lang/noir_js": "1.0.0-beta.3",
"@noir-lang/noirc_abi": "1.0.0-beta.3",
"@noir-lang/acvm_js": "1.0.0-beta.5",
"@noir-lang/noir_js": "1.0.0-beta.5",
"@noir-lang/noirc_abi": "1.0.0-beta.5",
"@reown/walletkit": "^1.1.1",
"@repo/contracts": "workspace:*",
"@repo/ui": "workspace:*",
Expand Down
5 changes: 2 additions & 3 deletions packages/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "@nomicfoundation/hardhat-toolbox";
import "hardhat-deploy";
import "hardhat-plugin-noir";
import "hardhat-noir";
import { HardhatUserConfig } from "hardhat/config";
import envConfig from "./envConfig";
import "./shared/typed-hardhat-deploy";
Expand All @@ -16,8 +16,7 @@ const config: HardhatUserConfig = {
},
},
noir: {
version: "1.0.0-beta.3",
bbVersion: "0.72.1",
version: "1.0.0-beta.5",
},
networks: {},
etherscan: {
Expand Down
7 changes: 3 additions & 4 deletions packages/contracts/noir/common/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
name = "common"
type = "lib"
authors = ["Oleh Misarosh <olehmisar@gmail.com>"]
compiler_version = ">=0.39.0"

[dependencies]
protocol_types = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "aztec-packages-v0.72.1", directory = "noir-projects/noir-protocol-circuits/crates/types" }
bignum = { tag = "v0.6.0", git = "https://github.com/noir-lang/noir-bignum/" }
nodash = { tag = "v0.40.0", git = "https://github.com/olehmisar/nodash/" }
protocol_types = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v0.86.0", directory = "noir-projects/noir-protocol-circuits/crates/types" }
bignum = { tag = "v0.7.3", git = "https://github.com/noir-lang/noir-bignum/" }
nodash = { tag = "v0.41.2", git = "https://github.com/olehmisar/nodash/" }
1 change: 0 additions & 1 deletion packages/contracts/noir/common/src/erc20_note.nr
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// fails to compile if this file is moved to erc20 crate

use super::note::Note;
use nodash::ArrayExtensions;
use protocol_types::traits::Serialize;

pub struct Erc20Note {
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/noir/common/src/lib.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bignum::BigNumTrait;
use bignum::BigNum;
use protocol_types::hash::poseidon2_hash_with_separator;

mod context;
Expand Down
3 changes: 1 addition & 2 deletions packages/contracts/noir/rollup/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
name = "rollup"
type = "bin"
authors = ["Oleh Misarosh <olehmisar@gmail.com"]
compiler_version = ">=0.39.0"

[dependencies]
protocol_types = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "aztec-packages-v0.72.1", directory = "noir-projects/noir-protocol-circuits/crates/types" }
protocol_types = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v0.86.0", directory = "noir-projects/noir-protocol-circuits/crates/types" }
common = { path = "../common" }
17 changes: 9 additions & 8 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"hardhat": "^2.22.16",
"hardhat-deploy": "^0.11.45",
"hardhat-gas-reporter": "^1.0.10",
"hardhat-plugin-noir": "^0.3.0-next.0",
"hardhat-noir": "^0.5.0",
"json-stringify-deterministic": "^1.0.12",
"lodash": "^4.17.21",
"ms": "^2.1.3",
Expand All @@ -43,19 +43,20 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@aztec/aztec.js": "0.72.1",
"@aztec/bb.js": "0.72.1",
"@aztec/circuits.js": "0.72.1",
"@aztec/foundation": "0.72.1",
"@aztec/kv-store": "0.72.1",
"@aztec/merkle-tree": "0.72.1",
"@aztec/aztec.js": "0.86.0",
"@aztec/bb.js": "0.86.0",
"@aztec/foundation": "0.86.0",
"@aztec/kv-store": "0.86.0",
"@aztec/merkle-tree": "0.86.0",
"@aztec/stdlib": "0.86.0",
"@hpke/core": "^1.7.1",
"@hpke/dhkem-x25519": "^1.6.1",
"@noir-lang/noir_js": "1.0.0-beta.3",
"@noir-lang/noir_js": "1.0.0-beta.5",
"@repo/utils": "workspace:*",
"ethers": "^6.13.4",
"ky": "^1.7.2",
"lodash-es": "^4.17.21",
"ox": "^0.7.2",
"ts-essentials": "^9.4.1",
"zod": "^3.23.8"
}
Expand Down
27 changes: 22 additions & 5 deletions packages/contracts/sdk/NativeUltraHonkBackend.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { ProofData } from "@aztec/bb.js";
import type { CompiledCircuit } from "@noir-lang/noir_js";
import { chunk } from "lodash-es";
import { spawn } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import { decodeNativeHonkProof } from "./utils.js";
import { Hex } from "ox";
import { assert } from "ts-essentials";

export class NativeUltraHonkBackend {
constructor(
Expand Down Expand Up @@ -32,13 +34,17 @@ export class NativeUltraHonkBackend {
fs.writeFileSync(circuitJsonPath, JSON.stringify(this.circuit));
fs.writeFileSync(witnessOutputPath, witness);
const args = [
"prove_ultra_keccak_honk",
"prove",
"--scheme",
"ultra_honk",
"-b",
circuitJsonPath,
"-w",
witnessOutputPath,
"-o",
proofOutputPath,
"--oracle_hash",
"keccak",
];

const bbProcess = spawn(this.bbPath, args);
Expand All @@ -57,10 +63,21 @@ export class NativeUltraHonkBackend {
return;
}

const proofData = decodeNativeHonkProof(
fs.readFileSync(proofOutputPath),
const proof = fs.readFileSync(path.join(proofOutputPath, "proof"));
const publicInputs = fs.readFileSync(
path.join(proofOutputPath, "public_inputs"),
);
resolve(proofData);
assert(
publicInputs.length % 32 === 0,
"publicInputs length must be divisible by 32",
);
resolve({
proof,
// TODO: not sure if this publicInputs decoding is correct
publicInputs: chunk(Array.from(publicInputs), 32).map((x) =>
Hex.fromBytes(Uint8Array.from(x)),
),
});
});

bbProcess.on("error", (err) => {
Expand Down
5 changes: 3 additions & 2 deletions packages/contracts/sdk/NonMembershipTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export class NonMembershipTree {
"@aztec/merkle-tree"
);
const { NullifierLeaf, NullifierLeafPreimage } = await import(
"@aztec/circuits.js"
// @ts-ignore hardhat does not support ESM
"@aztec/stdlib/trees"
);
// @ts-ignore hardhat does not support ESM
const { AztecLmdbStore } = await import("@aztec/kv-store/lmdb");
Expand Down Expand Up @@ -96,7 +97,7 @@ export class NonMembershipTree {
leaf_index: bigIntToString(lowLeafIndex),
sibling_path: lowLeafSiblingPath
.toFields()
.map((x) => bigIntToString(x.toBigInt())),
.map((x: Fr) => bigIntToString(x.toBigInt())),
},
};
return witness;
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/sdk/backendSdk.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { UltraHonkBackend } from "@aztec/bb.js";
import type { CompiledCircuit } from "@noir-lang/noir_js";
import { utils } from "@repo/utils";
import os from "node:os";
import type { AsyncOrSync } from "ts-essentials";
import { NativeUltraHonkBackend } from "./NativeUltraHonkBackend";
import { RollupService } from "./RollupOnlyService";
import { type CompiledCircuit, createCoreSdk } from "./sdk";
import { createCoreSdk } from "./sdk";
import type { TreesService } from "./TreesService";

export function createBackendSdk(
Expand Down
6 changes: 1 addition & 5 deletions packages/contracts/sdk/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { CompiledCircuit } from "@noir-lang/noir_js";
import { ethers } from "ethers";
import { mapValues } from "lodash-es";
import type { AsyncOrSync } from "ts-essentials";
Expand Down Expand Up @@ -43,11 +44,6 @@ export function createInterfaceSdk(
};
}

export type CompiledCircuit = {
bytecode: string;
abi: any;
};

async function getCircuit(artifact: AsyncOrSync<CompiledCircuit>) {
const { Noir } = await import("@noir-lang/noir_js");
const { UltraHonkBackend } = await import("@aztec/bb.js");
Expand Down
21 changes: 0 additions & 21 deletions packages/contracts/sdk/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Fr } from "@aztec/aztec.js";
import { splitHonkProof } from "@aztec/bb.js";
import type { InputMap } from "@noir-lang/noir_js";
import { ethers } from "ethers";
import { assert } from "ts-essentials";
Expand Down Expand Up @@ -75,25 +74,5 @@ export async function prove(
keccak: true,
});
console.timeEnd(`${name} generateProof`);
proof = proof.slice(4); // remove length
return { proof, witness, returnValue, publicInputs };
}

export function decodeNativeHonkProof(nativeProof: Uint8Array) {
const { proof, publicInputs: publicInputsRaw } = splitHonkProof(nativeProof);
const publicInputs = deflattenFields(publicInputsRaw);
return { proof, publicInputs };
}

// TODO: import from @aztec/bb.js when available
function deflattenFields(flattenedFields: Uint8Array): string[] {
const publicInputSize = 32;
const chunkedFlattenedPublicInputs: Uint8Array[] = [];

for (let i = 0; i < flattenedFields.length; i += publicInputSize) {
const publicInput = flattenedFields.slice(i, i + publicInputSize);
chunkedFlattenedPublicInputs.push(publicInput);
}

return chunkedFlattenedPublicInputs.map((x) => ethers.hexlify(x));
}
Loading