Skip to content

Commit 3a99f01

Browse files
committed
update to nightly
1 parent 6612f4d commit 3a99f01

File tree

6 files changed

+51
-599
lines changed

6 files changed

+51
-599
lines changed

recursive_verification/bun.lockb

52.4 KB
Binary file not shown.

recursive_verification/data.json

Lines changed: 2 additions & 510 deletions
Large diffs are not rendered by default.

recursive_verification/package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
"typescript": "^5.0.0"
1919
},
2020
"dependencies": {
21-
"@aztec/accounts": "2.0.3",
22-
"@aztec/aztec.js": "2.0.3",
23-
"@aztec/bb.js": "2.0.3",
24-
"@aztec/kv-store": "^2.0.3",
25-
"@aztec/noir-contracts.js": "^2.0.3",
26-
"@aztec/noir-noir_js": "2.0.3",
27-
"@aztec/pxe": "^2.0.3",
21+
"@aztec/accounts": "3.0.0-nightly.20251024",
22+
"@aztec/aztec.js": "3.0.0-nightly.20251024",
23+
"@aztec/bb.js": "3.0.0-nightly.20251024",
24+
"@aztec/kv-store": "3.0.0-nightly.20251024",
25+
"@aztec/noir-contracts.js": "3.0.0-nightly.20251024",
26+
"@aztec/noir-noir_js": "3.0.0-nightly.20251024",
27+
"@aztec/pxe": "3.0.0-nightly.20251024",
28+
"@aztec/test-wallet": "3.0.0-nightly.20251024",
2829
"add": "^2.0.6",
2930
"tsx": "^4.20.6"
3031
}

recursive_verification/scripts/generate_data.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,17 @@ const { witness: mainWitness } = await helloWorld.execute({ x: 1, y: 2 })
1010

1111
const mainBackend = new UltraHonkBackend(circuitJson.bytecode, { threads: 1 })
1212
const mainProofData = await mainBackend.generateProof(mainWitness)
13-
const mainVerificationKey = await mainBackend.getVerificationKey()
13+
14+
let recursiveProofArtifacts = await mainBackend.generateRecursiveProofArtifacts(mainProofData.proof, 1)
1415

1516
const isValid = await mainBackend.verifyProof(mainProofData)
1617
console.log(`Proof verification: ${isValid ? 'SUCCESS' : 'FAILED'}`)
1718

1819
const proofAsFields = deflattenFields(mainProofData.proof)
1920
const barretenbergAPI = await Barretenberg.new({ threads: 1 });
20-
const vkAsFields = (await barretenbergAPI.acirVkAsFieldsUltraHonk(mainVerificationKey))
21-
.map(field => field.toString());
22-
23-
fs.writeFileSync('data.json', JSON.stringify({ proofAsFields, vkAsFields, publicInputs: mainProofData.publicInputs }, null, 2))
2421

22+
// write recursive proof artifacts and public inputs to file, add pu
23+
fs.writeFileSync('data.json', JSON.stringify({ ...recursiveProofArtifacts, publicInputs: mainProofData.publicInputs }, null, 2))
2524
await barretenbergAPI.destroy()
26-
2725
console.log("Done")
2826
exit()

recursive_verification/scripts/run_recursion.ts

Lines changed: 27 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,53 @@
1-
import { AccountWalletWithSecretKey, Contract, createAztecNodeClient, Fq, Fr, SponsoredFeePaymentMethod, waitForPXE, type FieldLike, type PXE } from "@aztec/aztec.js"
1+
import { Contract } from "@aztec/aztec.js/contracts"
2+
import { createAztecNodeClient } from "@aztec/aztec.js/node"
3+
import { SponsoredFeePaymentMethod } from "@aztec/aztec.js/fee"
4+
import type { FieldLike } from "@aztec/aztec.js/abi"
25
import { getSponsoredFPCInstance } from "./sponsored_fpc.js";
36
import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC";
47
export const PXE_URL = 'http://localhost:8080'
58
import { ValueNotEqualContract, ValueNotEqualContractArtifact } from '../contract/artifacts/ValueNotEqual'
69
import data from '../data.json'
7-
import { createPXEService, getPXEServiceConfig } from "@aztec/pxe/server"
8-
import { createStore } from "@aztec/kv-store/lmdb"
9-
import { getSchnorrAccount } from "@aztec/accounts/schnorr"
10+
import { getPXEConfig } from "@aztec/pxe/config"
11+
import { TestWallet } from '@aztec/test-wallet/server';
12+
import { AztecAddress } from "@aztec/aztec.js/addresses"
1013

1114
const sponsoredFPC = await getSponsoredFPCInstance();
1215
const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(sponsoredFPC.address);
1316

14-
export const setupSandbox = async (): Promise<PXE> => {
15-
17+
export const setupSandbox = async (): Promise<TestWallet> => {
18+
1619
try {
1720
const nodeUrl = 'http://localhost:8080';
18-
const node = await createAztecNodeClient(nodeUrl);
19-
20-
try {
21-
await node.getNodeInfo();
22-
} catch (error) {
23-
throw new Error(`Cannot connect to node at ${nodeUrl}. ${nodeUrl.includes('localhost') ? 'Please run: aztec start --sandbox' : 'Check your connection.'}`);
24-
}
25-
26-
const l1Contracts = await node.getL1ContractAddresses();
27-
const config = getPXEServiceConfig();
28-
const fullConfig = {
29-
...config,
30-
l1Contracts,
31-
proverEnabled: true
32-
};
33-
34-
const store = await createStore('recursive_verification', {
35-
dataDirectory: 'store',
36-
dataStoreMapSizeKB: 1e6,
37-
});
38-
39-
const pxe = await createPXEService(node, fullConfig, { store });
40-
await waitForPXE(pxe);
41-
await pxe.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact });
42-
43-
return pxe;
21+
const aztecNode = await createAztecNodeClient(nodeUrl);
22+
const config = getPXEConfig();
23+
config.dataDirectory = 'pxe';
24+
config.proverEnabled = true;
25+
let wallet = await TestWallet.create(aztecNode, config);
26+
await wallet.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact });
27+
28+
return wallet;
4429
} catch (error) {
4530
console.error('Failed to setup sandbox:', error)
4631
throw error
4732
}
4833
}
4934

50-
export async function deployWallet(pxe: PXE): Promise<AccountWalletWithSecretKey> {
51-
let secretKey = Fr.random();
52-
let signingKey = Fq.random();
53-
let salt = Fr.random();
54-
let schnorrAccount = await getSchnorrAccount(pxe, secretKey, signingKey, salt);
55-
let tx = await schnorrAccount.deploy({ fee: { paymentMethod: sponsoredPaymentMethod } }).wait({ timeout: 120000 });
56-
let wallet = await schnorrAccount.getWallet();
57-
return wallet
58-
}
5935

6036
async function main() {
61-
const pxe = await setupSandbox();
62-
const wallet = await deployWallet(pxe)
63-
64-
const valueNotEqual = await Contract.deploy(wallet, ValueNotEqualContractArtifact, [
65-
10, wallet.getAddress()
66-
], 'initialize').send({ from: wallet.getAddress(), fee: { paymentMethod: sponsoredPaymentMethod } }).deployed() as ValueNotEqualContract
37+
const testWallet = await setupSandbox();
38+
const account = await testWallet.createAccount();
39+
const manager = await account.getDeployMethod();
40+
await manager.send({ from: AztecAddress.ZERO, fee: { paymentMethod: sponsoredPaymentMethod } }).deployed()
41+
const accounts = await testWallet.getAccounts();
6742

68-
console.log("Contract Deployed at address", valueNotEqual.address.toString())
43+
const valueNotEqual = await Contract.deploy(testWallet, ValueNotEqualContractArtifact, [
44+
10, accounts[0].item
45+
], 'initialize').send({ from: accounts[0].item, fee: { paymentMethod: sponsoredPaymentMethod } }).deployed() as ValueNotEqualContract
6946

70-
const tx = await valueNotEqual.methods.increment(wallet.getAddress(), data.vkAsFields as unknown as FieldLike[], data.proofAsFields as unknown as FieldLike[], data.publicInputs as unknown as FieldLike[]).send({ from: wallet.getAddress(), fee: { paymentMethod: sponsoredPaymentMethod } }).wait()
47+
const tx = await valueNotEqual.methods.increment(accounts[0].item, data.vkAsFields as unknown as FieldLike[], data.proofAsFields as unknown as FieldLike[], data.publicInputs as unknown as FieldLike[]).send({ from: accounts[0].item, fee: { paymentMethod: sponsoredPaymentMethod } }).wait()
7148

7249
console.log(`Tx hash: ${tx.txHash.toString()}`)
73-
const counterValue = await valueNotEqual.methods.get_counter(wallet.getAddress()).simulate({ from: wallet.getAddress() })
50+
const counterValue = await valueNotEqual.methods.get_counter(accounts[0].item).simulate({ from: accounts[0].item })
7451
console.log(`Counter value: ${counterValue}`)
7552
}
7653

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import {
2-
type ContractInstanceWithAddress,
3-
Fr,
4-
type PXE,
5-
type Wallet,
6-
getContractInstanceFromInstantiationParams,
7-
} from '@aztec/aztec.js';
1+
import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
2+
import { Fr } from '@aztec/aztec.js/fields';
3+
import type { Wallet } from '@aztec/aztec.js/wallet';
84
import type { LogFn } from '@aztec/foundation/log';
95
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
106

11-
const SPONSORED_FPC_SALT = new Fr(0);
7+
const SPONSORED_FPC_SALT = new Fr(BigInt(0));
128

139
export async function getSponsoredFPCInstance(): Promise<ContractInstanceWithAddress> {
1410
return await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
@@ -20,23 +16,11 @@ export async function getSponsoredFPCAddress() {
2016
return (await getSponsoredFPCInstance()).address;
2117
}
2218

23-
export async function setupSponsoredFPC(deployer: Wallet, log: LogFn) {
24-
const deployed = await SponsoredFPCContract.deploy(deployer)
25-
.send({
26-
from: deployer.getAddress(),
27-
contractAddressSalt: SPONSORED_FPC_SALT,
28-
universalDeploy: true,
29-
})
30-
.deployed();
19+
export async function setupSponsoredFPC(wallet: Wallet) {
20+
const instance = await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
21+
salt: new Fr(SPONSORED_FPC_SALT),
22+
});
3123

32-
log(`SponsoredFPC: ${deployed.address}`);
24+
await wallet.registerContract({ instance, artifact: SponsoredFPCContract.artifact });
25+
return instance;
3326
}
34-
35-
export async function getDeployedSponsoredFPCAddress(pxe: PXE) {
36-
const fpc = await getSponsoredFPCAddress();
37-
const contracts = await pxe.getContracts();
38-
if (!contracts.find(c => c.equals(fpc))) {
39-
throw new Error('SponsoredFPC not deployed.');
40-
}
41-
return fpc;
42-
}

0 commit comments

Comments
 (0)