From e3c69bc34898a56b960fd31e6b883f94ebb31fc7 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 12 Jun 2023 13:35:05 +0000 Subject: [PATCH 01/13] temp --- .../acir-simulator/src/public/index.test.ts | 7 +++ .../public_private_contract/Nargo.toml | 6 +++ .../public_private_contract/src/main.nr | 52 +++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 yarn-project/noir-contracts/src/contracts/public_private_contract/Nargo.toml create mode 100644 yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index ee080ac313ae..7ef0fe39c815 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -219,5 +219,12 @@ describe('ACIR public execution simulator', () => { expect(result.returnValues).toEqual([new Fr(42n + initialValue)]); }); + }); + + describe("Create commitment in public contact", () => { + + + + }); }); diff --git a/yarn-project/noir-contracts/src/contracts/public_private_contract/Nargo.toml b/yarn-project/noir-contracts/src/contracts/public_private_contract/Nargo.toml new file mode 100644 index 000000000000..c7581265e836 --- /dev/null +++ b/yarn-project/noir-contracts/src/contracts/public_private_contract/Nargo.toml @@ -0,0 +1,6 @@ +[package] +authors = [""] +compiler_version = "0.1" + +[dependencies] +aztec3 = { path = "../noir-aztec3" } diff --git a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr new file mode 100644 index 000000000000..31695b3e258d --- /dev/null +++ b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr @@ -0,0 +1,52 @@ +contract PublicToken { + use dep::aztec3::abi::PrivateContextInputs; + use dep::aztec3::context::PrivateFunctionContext; + use dep::aztec3::abi::PublicContextInputs; + use dep::aztec3::types::point::Point; + use dep::aztec3::state_vars::storage_map::StorageMap; + use dep::aztec3::state_vars::storage_field::StorageField; + + global balances = StorageMap { storage_slot: 1 }; + + fn constructor( + inputs: pub PrivateContextInputs, + ) -> pub [Field; dep::aztec3::abi::PUBLIC_INPUTS_LENGTH] { + PrivateFunctionContext::new().finish(inputs) + } + + open fn mint( + _inputs: PublicContextInputs, + amount: Field, + secretHash: Field, + _padding: [Field; dep::aztec3::abi::MAX_ARGS - 3] + ) -> pub Field { + let recipient_balance = balances.at(recipient.x); + recipient_balance.write(recipient_balance.read() + amount) + } + + open fn transfer( + inputs: PublicContextInputs, + amount: Field, + recipient: Point, + _padding: [Field; dep::aztec3::abi::MAX_ARGS - 3] + ) -> pub Field { + let sender = inputs.call_context.msg_sender; + + let sender_balance = balances.at(sender); + let recipient_balance = balances.at(recipient.x); + + let current_sender_balance = sender_balance.read(); + let current_recipient_balance = recipient_balance.read(); + + // TODO: Handle larger integer values ("long integers are not yet supported") + if (current_sender_balance as u120) > (amount as u120) { + // TODO: Compiler complains if we don't assign the result of the write to anything + let _void1 = sender_balance.write(current_sender_balance - amount); + recipient_balance.write(current_recipient_balance + amount) + } else { + // TODO: Revert if there is not enough balance + current_recipient_balance + } + } + +} From 1242ff11e34c1854d915e37ca38bc362c05a569d Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 12 Jun 2023 15:53:38 +0000 Subject: [PATCH 02/13] feat: create commitments and l1 messages in a public call --- yarn-project/acir-simulator/src/acvm/acvm.ts | 2 + .../src/client/private_execution.ts | 2 + .../src/client/unconstrained_execution.ts | 2 + .../acir-simulator/src/public/execution.ts | 4 + .../acir-simulator/src/public/executor.ts | 16 ++- .../acir-simulator/src/public/index.test.ts | 68 +++++++++++- .../src/contracts/noir-aztec3/src/oracle.nr | 6 +- .../src/oracle/create_commitment.nr | 7 ++ .../src/oracle/create_l2_to_l1_message.nr | 7 ++ .../public_private_contract/src/main.nr | 101 ++++++++++++++---- .../noir-contracts/src/examples/index.ts | 2 + .../src/examples/public_private_contract.json | 67 ++++++++++++ .../src/sequencer/public_processor.ts | 4 +- 13 files changed, 256 insertions(+), 32 deletions(-) create mode 100644 yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/create_commitment.nr create mode 100644 yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/create_l2_to_l1_message.nr create mode 100644 yarn-project/noir-contracts/src/examples/public_private_contract.json diff --git a/yarn-project/acir-simulator/src/acvm/acvm.ts b/yarn-project/acir-simulator/src/acvm/acvm.ts index 5d2ffdeac2c1..c44cc1d77afc 100644 --- a/yarn-project/acir-simulator/src/acvm/acvm.ts +++ b/yarn-project/acir-simulator/src/acvm/acvm.ts @@ -29,6 +29,8 @@ export interface ACIRCallback { enqueuePublicFunctionCall(params: ACVMField[]): Promise; storageRead(params: ACVMField[]): Promise<[ACVMField]>; storageWrite(params: ACVMField[]): Promise<[ACVMField]>; + createCommitment(params: ACVMField[]): Promise<[ACVMField]>; + createL2ToL1Message(params: ACVMField[]): Promise<[ACVMField]>; viewNotesPage(params: ACVMField[]): Promise; getL1ToL2Message(params: ACVMField[]): Promise; /** diff --git a/yarn-project/acir-simulator/src/client/private_execution.ts b/yarn-project/acir-simulator/src/client/private_execution.ts index 2704ff6ec971..7dfc773875fd 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.ts @@ -218,6 +218,8 @@ export class PrivateFunctionExecution { viewNotesPage: notAvailable, storageRead: notAvailable, storageWrite: notAvailable, + createCommitment: notAvailable, + createL2ToL1Message: notAvailable, callPublicFunction: notAvailable, emitEncryptedLog: async ([ acvmContractAddress, diff --git a/yarn-project/acir-simulator/src/client/unconstrained_execution.ts b/yarn-project/acir-simulator/src/client/unconstrained_execution.ts index 6e27599f0744..a16d54bda8cd 100644 --- a/yarn-project/acir-simulator/src/client/unconstrained_execution.ts +++ b/yarn-project/acir-simulator/src/client/unconstrained_execution.ts @@ -71,6 +71,8 @@ export class UnconstrainedFunctionExecution { callPublicFunction: notAvailable, storageRead: notAvailable, storageWrite: notAvailable, + createCommitment: notAvailable, + createL2ToL1Message: notAvailable, emitEncryptedLog: notAvailable, }); diff --git a/yarn-project/acir-simulator/src/public/execution.ts b/yarn-project/acir-simulator/src/public/execution.ts index 2b0ca88e61e7..604c51720e4a 100644 --- a/yarn-project/acir-simulator/src/public/execution.ts +++ b/yarn-project/acir-simulator/src/public/execution.ts @@ -15,6 +15,10 @@ export interface PublicExecutionResult { execution: PublicExecution; /** The return values of the function. */ returnValues: Fr[]; + /** The new commitments to be inserted into the commitments tree. */ + newCommitments: Fr[]; + /** The new l2 to l1 messages generated in this call. */ + newL2ToL1Messages: Fr[]; /** The contract storage reads performed by the function. */ contractStorageReads: ContractStorageRead[]; /** The contract storage update requests performed by the function. */ diff --git a/yarn-project/acir-simulator/src/public/executor.ts b/yarn-project/acir-simulator/src/public/executor.ts index 490d929e6808..344442f4d31c 100644 --- a/yarn-project/acir-simulator/src/public/executor.ts +++ b/yarn-project/acir-simulator/src/public/executor.ts @@ -3,7 +3,7 @@ import { padArrayEnd } from '@aztec/foundation/collection'; import { createDebugLogger } from '@aztec/foundation/log'; import { TxExecutionRequest } from '@aztec/types'; import { select_return_flattened as selectPublicWitnessFlattened } from '@noir-lang/noir_util_wasm'; -import { acvm, frToAztecAddress, frToSelector, fromACVMField, toACVMField, toACVMWitness } from '../acvm/index.js'; +import { ZERO_ACVM_FIELD, acvm, frToAztecAddress, frToSelector, fromACVMField, toACVMField, toACVMWitness } from '../acvm/index.js'; import { CommitmentsDB, PublicContractsDB, PublicStateDB } from './db.js'; import { PublicExecution, PublicExecutionResult } from './execution.js'; import { ContractStorageActionsCollector } from './state_actions.js'; @@ -42,6 +42,8 @@ export class PublicExecutor { const initialWitness = getInitialWitness(execution.args, execution.callContext, this.treeRoots); const storageActions = new ContractStorageActionsCollector(this.stateDb, execution.contractAddress); + const newCommitments: Fr[] = []; + const newL2ToL1Messages: Fr[] = []; const nestedExecutions: PublicExecutionResult[] = []; const notAvailable = () => Promise.reject(`Built-in not available for public execution simulation`); @@ -72,6 +74,16 @@ export class PublicExecutor { this.log(`Oracle storage write: slot=${storageSlot.toShortString()} value=${value.toString()}`); return [toACVMField(newValue)]; }, + createCommitment: async ([commitment]) => { + this.log("Creating commitment: " + commitment.toString()); + newCommitments.push(fromACVMField(commitment)); + return await Promise.resolve([ZERO_ACVM_FIELD]); + }, + createL2ToL1Message: async ([message]) => { + this.log("Creating L2 to L1 message: " + message.toString()); + newL2ToL1Messages.push(fromACVMField(message)); + return await Promise.resolve([ZERO_ACVM_FIELD]); + }, callPublicFunction: async ([address, functionSelector, ...args]) => { this.log(`Public function call: addr=${address} selector=${functionSelector} args=${args.join(',')}`); const childExecutionResult = await this.callPublicFunction( @@ -92,6 +104,8 @@ export class PublicExecutor { return { execution, + newCommitments, + newL2ToL1Messages, contractStorageReads, contractStorageUpdateRequests, returnValues, diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index 7ef0fe39c815..202a93a3fdac 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -1,10 +1,10 @@ -import { Grumpkin } from '@aztec/circuits.js/barretenberg'; +import { Grumpkin, pedersenCompressInputs } from '@aztec/circuits.js/barretenberg'; import { CallContext, FunctionData, CircuitsWasm, PrivateHistoricTreeRoots } from '@aztec/circuits.js'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; import { FunctionAbi } from '@aztec/foundation/abi'; -import { ChildAbi, ParentAbi, PublicTokenContractAbi } from '@aztec/noir-contracts/examples'; +import { ChildAbi, ParentAbi, PublicToPrivateContractAbi, PublicTokenContractAbi } from '@aztec/noir-contracts/examples'; import { MockProxy, mock } from 'jest-mock-extended'; import { default as memdown, type MemDown } from 'memdown'; import { encodeArguments } from '../abi_coder/encoder.js'; @@ -221,10 +221,70 @@ describe('ACIR public execution simulator', () => { }); }); - describe("Create commitment in public contact", () => { - + describe("Public -> Private messaging", () => { + it("Should be able to create a commitment from the public context", async () => { + const contractAddress = AztecAddress.random(); + const publicToPrivateAbi = PublicToPrivateContractAbi.functions.find(f => f.name === 'mintFromPublicToPrivate')!; + const functionData = new FunctionData(Buffer.alloc(4), false, false); + const amount = new Fr(140); + const secretHash = Fr.random(); + const args = encodeArguments(publicToPrivateAbi, [amount, secretHash]); + const callContext = CallContext.from({ + msgSender: AztecAddress.random(), + storageContractAddress: contractAddress, + portalContractAddress: EthAddress.random(), + isContractDeployment: false, + isDelegateCall: false, + isStaticCall: false, + }); + publicContracts.getBytecode.mockResolvedValue(Buffer.from(publicToPrivateAbi.bytecode, 'hex')); + + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + const result = await executor.execute(execution); + + const expectedReturn = Fr.ZERO; + expect(result.returnValues).toEqual([expectedReturn]); + + // Assert the commitment was created + expect(result.newCommitments.length).toEqual(1); + + const expectedNewCommitmentValue = pedersenCompressInputs(await CircuitsWasm.get(), [amount.toBuffer(), secretHash.toBuffer()]) + expect(result.newCommitments[0].toBuffer()).toEqual(expectedNewCommitmentValue); + }); + + it("Should be able to create a L2 to L1 message from the public context", async () => { + const contractAddress = AztecAddress.random(); + const createL2ToL1MessagePublicAbi = PublicToPrivateContractAbi.functions.find(f => f.name === 'createL2ToL1MessagePublic')!; + const functionData = new FunctionData(Buffer.alloc(4), false, false); + const amount = new Fr(140); + const secretHash = Fr.random(); + const args = encodeArguments(createL2ToL1MessagePublicAbi, [amount, secretHash]); + + const callContext = CallContext.from({ + msgSender: AztecAddress.random(), + storageContractAddress: contractAddress, + portalContractAddress: EthAddress.random(), + isContractDeployment: false, + isDelegateCall: false, + isStaticCall: false, + }); + + publicContracts.getBytecode.mockResolvedValue(Buffer.from(createL2ToL1MessagePublicAbi.bytecode, 'hex')); + + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + const result = await executor.execute(execution); + + const expectedReturn = Fr.ZERO; + expect(result.returnValues).toEqual([expectedReturn]); + + // Assert the l2 to l1 message was created + expect(result.newL2ToL1Messages.length).toEqual(1); + + const expectedNewMessageValue = pedersenCompressInputs(await CircuitsWasm.get(), [amount.toBuffer(), secretHash.toBuffer()]) + expect(result.newL2ToL1Messages[0].toBuffer()).toEqual(expectedNewMessageValue); + }); }); }); diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle.nr index 27a2b80cb38c..847848523b46 100644 --- a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle.nr +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle.nr @@ -1,10 +1,12 @@ +mod call_private_function; +mod create_commitment; +mod create_l2_to_l1_message; +mod debug_log; mod get_l1_to_l2_message; mod get_secret_key; mod rand; mod enqueue_public_function_call; -mod debug_log; mod public_call; mod notes; mod storage; -mod call_private_function; mod logs; \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/create_commitment.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/create_commitment.nr new file mode 100644 index 000000000000..28beb87fa620 --- /dev/null +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/create_commitment.nr @@ -0,0 +1,7 @@ + +#[oracle(createCommitment)] +fn create_commitment_oracle(_commitment: Field) -> Field {} + +unconstrained fn create_commitment(commitment: Field) { + constrain create_commitment_oracle(commitment) == 0; +} diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/create_l2_to_l1_message.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/create_l2_to_l1_message.nr new file mode 100644 index 000000000000..4a768542a122 --- /dev/null +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/create_l2_to_l1_message.nr @@ -0,0 +1,7 @@ + +#[oracle(createL2ToL1Message)] +fn create_l2_to_l1_message_oracle(_message: Field) -> Field {} + +unconstrained fn create_l2_to_l1_message(message: Field) { + constrain create_l2_to_l1_message_oracle(message) == 0; +} diff --git a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr index 31695b3e258d..1ab705e0aca2 100644 --- a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr @@ -1,4 +1,6 @@ -contract PublicToken { +use dep::std::hash::pedersen; + +contract PublicPrivate { use dep::aztec3::abi::PrivateContextInputs; use dep::aztec3::context::PrivateFunctionContext; use dep::aztec3::abi::PublicContextInputs; @@ -6,6 +8,11 @@ contract PublicToken { use dep::aztec3::state_vars::storage_map::StorageMap; use dep::aztec3::state_vars::storage_field::StorageField; + use dep::aztec3::oracle::create_commitment::create_commitment; + use dep::aztec3::oracle::create_l2_to_l1_message::create_l2_to_l1_message; + + use crate::TransparentNote; + global balances = StorageMap { storage_slot: 1 }; fn constructor( @@ -14,39 +21,87 @@ contract PublicToken { PrivateFunctionContext::new().finish(inputs) } - open fn mint( + + open fn mintFromPublicToPrivate( _inputs: PublicContextInputs, amount: Field, secretHash: Field, _padding: [Field; dep::aztec3::abi::MAX_ARGS - 3] ) -> pub Field { - let recipient_balance = balances.at(recipient.x); - recipient_balance.write(recipient_balance.read() + amount) + + // Create a commitment to the amount + let note = TransparentNote::new(amount, secretHash); + + // Public oracle call to emit new commitment. + create_commitment(note.get_commitment()); + 0 } - open fn transfer( - inputs: PublicContextInputs, + open fn createL2ToL1MessagePublic( + _inputs: PublicContextInputs, amount: Field, - recipient: Point, + secretHash: Field, _padding: [Field; dep::aztec3::abi::MAX_ARGS - 3] ) -> pub Field { - let sender = inputs.call_context.msg_sender; + + // Create a commitment to the amount + let note = TransparentNote::new(amount, secretHash); - let sender_balance = balances.at(sender); - let recipient_balance = balances.at(recipient.x); - - let current_sender_balance = sender_balance.read(); - let current_recipient_balance = recipient_balance.read(); - - // TODO: Handle larger integer values ("long integers are not yet supported") - if (current_sender_balance as u120) > (amount as u120) { - // TODO: Compiler complains if we don't assign the result of the write to anything - let _void1 = sender_balance.write(current_sender_balance - amount); - recipient_balance.write(current_recipient_balance + amount) - } else { - // TODO: Revert if there is not enough balance - current_recipient_balance - } + // Public oracle call to emit new commitment. + create_l2_to_l1_message(note.get_commitment()); + 0 } + + // open fn transfer( + // inputs: PublicContextInputs, + // amount: Field, + // recipient: Point, + // _padding: [Field; dep::aztec3::abi::MAX_ARGS - 3] + // ) -> pub Field { + // let sender = inputs.call_context.msg_sender; + + // let sender_balance = balances.at(sender); + // let recipient_balance = balances.at(recipient.x); + + // let current_sender_balance = sender_balance.read(); + // let current_recipient_balance = recipient_balance.read(); + + // // TODO: Handle larger integer values ("long integers are not yet supported") + // if (current_sender_balance as u120) > (amount as u120) { + // // TODO: Compiler complains if we don't assign the result of the write to anything + // let _void1 = sender_balance.write(current_sender_balance - amount); + // recipient_balance.write(current_recipient_balance + amount) + // } else { + // // TODO: Revert if there is not enough balance + // current_recipient_balance + // } + // } + } + + +struct TransparentNote { + amount: Field, + secretHash: Field, +} + +impl TransparentNote { + fn new(amount: Field, secretHash: Field) -> Self { + Self { amount, secretHash } + } + + // fn new_from_secret(amount: Field, secret: Field) -> Self { + + // } + + fn get_commitment(self) -> Field { + pedersen([self.amount, self.secretHash])[0] + } + + fn knows_secret(self, secret: Field) { + let hash = pedersen([secret])[0]; + constrain self.secretHash == hash; + } + +} \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/examples/index.ts b/yarn-project/noir-contracts/src/examples/index.ts index 660d8c1cfd36..2dab4182e33a 100644 --- a/yarn-project/noir-contracts/src/examples/index.ts +++ b/yarn-project/noir-contracts/src/examples/index.ts @@ -4,6 +4,7 @@ import ZkTokenContractJson from './zk_token_contract.json' assert { type: 'json' import ParentJson from './parent_contract.json' assert { type: 'json' }; import ChildJson from './child_contract.json' assert { type: 'json' }; import PublicTokenContractJson from './public_token_contract.json' assert { type: 'json' }; +import PublicToPrivateContractJson from "./public_private_contract.json" assert { type: "json" } import { ContractAbi } from '@aztec/foundation/abi' assert { type: 'json' }; import NonNativeTokenContractJson from './non_native_token_contract.json' assert { type: 'json' }; import AccountContractJson from './account_contract.json' assert { type: 'json' }; @@ -13,5 +14,6 @@ export const ZkTokenContractAbi = ZkTokenContractJson as ContractAbi; export const ParentAbi = ParentJson as ContractAbi; export const ChildAbi = ChildJson as ContractAbi; export const PublicTokenContractAbi = PublicTokenContractJson as ContractAbi; +export const PublicToPrivateContractAbi = PublicToPrivateContractJson as ContractAbi; export const NonNativeTokenContractAbi = NonNativeTokenContractJson as ContractAbi; export const AccountContractAbi = AccountContractJson as ContractAbi; diff --git a/yarn-project/noir-contracts/src/examples/public_private_contract.json b/yarn-project/noir-contracts/src/examples/public_private_contract.json new file mode 100644 index 000000000000..7cdd01f03948 --- /dev/null +++ b/yarn-project/noir-contracts/src/examples/public_private_contract.json @@ -0,0 +1,67 @@ +{ + "name": "PublicPrivate", + "functions": [ + { + "name": "constructor", + "functionType": "secret", + "parameters": [], + "returnTypes": [], + "bytecode": "00000000410000000e0000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000002f00000012000000130000001400000015000000160000001700000018000000190000001a0000001b0000001c0000001d0000001e0000001f000000200000002100000022000000230000002400000025000000260000002700000028000000290000002a0000002b0000002c0000002d0000002e0000002f000000300000003100000032000000330000003400000035000000360000003700000038000000390000003a0000003b0000003c0000003d0000003e0000003f00000040000000340000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000f0000000000000000000000000000000000000000000000000000000000000000000000010500080000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe00000002000000100000001100000000000000000200000000000000000000000000000000000000000000000000000000000000000000010400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000012000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000013000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000015000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000016000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000017000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000019000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000021000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000022000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000023000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000024000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000025000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000026000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000027000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000028000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000029000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000031000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000032000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000033000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000034000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010800000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000035000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000036000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000037000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000038000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000039000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000400000000000000000000000000000000000000000000000000000000000000000000000", + "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" + }, + { + "name": "createL2ToL1MessagePublic", + "functionType": "open", + "parameters": [ + { + "name": "amount", + "type": { + "kind": "field" + }, + "visibility": "private" + }, + { + "name": "secretHash", + "type": { + "kind": "field" + }, + "visibility": "private" + } + ], + "returnTypes": [ + { + "kind": "field" + } + ], + "bytecode": "0000000016000000000000000100000015000000070000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000030000000000000000000000000000000000000000000000000000000000000000000000010500020000000b000000fe0000000c000000fe000000020000001200000013000000070100000000000000000001000000000000000000000000000000000000000000000000000000000000000000000112000000000000000000000000000000000000000000000000000000000000000000000000000000050100009881a34a4d509103a454726170a453746f7081a64f7261636c6595b36372656174654c32546f4c314d6573736167659181b052656769737465724d656d496e64657881a8526567697374657237909181ad5265676973746572496e6465783b9081a842696e6172794f709581a8556e7369676e6564910181a3436d70a2457181a852656769737465723b81a8436f6e7374616e74d940303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303e81a84a4d5049464e4f549281a852656769737465723e01a843616c6c4261636b81a9426f6f747374726170919137010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000150000000000000000000000000000000000000000000000000000000000000000000000", + "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" + }, + { + "name": "mintFromPublicToPrivate", + "functionType": "open", + "parameters": [ + { + "name": "amount", + "type": { + "kind": "field" + }, + "visibility": "private" + }, + { + "name": "secretHash", + "type": { + "kind": "field" + }, + "visibility": "private" + } + ], + "returnTypes": [ + { + "kind": "field" + } + ], + "bytecode": "0000000016000000000000000100000015000000070000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000030000000000000000000000000000000000000000000000000000000000000000000000010500020000000b000000fe0000000c000000fe000000020000001200000013000000070100000000000000000001000000000000000000000000000000000000000000000000000000000000000000000112000000000000000000000000000000000000000000000000000000000000000000000000000000020100009881a34a4d509103a454726170a453746f7081a64f7261636c6595b0637265617465436f6d6d69746d656e749181b052656769737465724d656d496e64657881a8526567697374657237909181ad5265676973746572496e6465783b9081a842696e6172794f709581a8556e7369676e6564910181a3436d70a2457181a852656769737465723b81a8436f6e7374616e74d940303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303e81a84a4d5049464e4f549281a852656769737465723e01a843616c6c4261636b81a9426f6f747374726170919137010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000150000000000000000000000000000000000000000000000000000000000000000000000", + "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" + } + ] +} diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.ts index ce05f2f3793c..32a42376e09f 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.ts @@ -230,9 +230,9 @@ export class PublicProcessor { callContext: result.execution.callContext, proverAddress: AztecAddress.random(), argsHash: await computeVarArgsHash(wasm, result.execution.args), - newCommitments: padArrayEnd([], Fr.ZERO, NEW_COMMITMENTS_LENGTH), + newCommitments: padArrayEnd(result.newCommitments, Fr.ZERO, NEW_COMMITMENTS_LENGTH), newNullifiers: padArrayEnd([], Fr.ZERO, NEW_NULLIFIERS_LENGTH), - newL2ToL1Msgs: padArrayEnd([], Fr.ZERO, NEW_L2_TO_L1_MSGS_LENGTH), + newL2ToL1Msgs: padArrayEnd(result.newL2ToL1Messages, Fr.ZERO, NEW_L2_TO_L1_MSGS_LENGTH), returnValues: padArrayEnd(result.returnValues, Fr.ZERO, RETURN_VALUES_LENGTH), contractStorageReads: padArrayEnd( result.contractStorageReads, From 28915ceabbb6004f92c378b84c06697be1838038 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 12 Jun 2023 18:15:29 +0000 Subject: [PATCH 03/13] feat: consume public message in private context --- yarn-project/acir-simulator/src/acvm/acvm.ts | 1 + .../acir-simulator/src/acvm/serialize.ts | 22 ++++- .../src/client/client_execution_context.ts | 19 +++- .../src/client/private_execution.test.ts | 57 ++++++++++- .../src/client/private_execution.ts | 11 ++- .../src/client/unconstrained_execution.ts | 1 + yarn-project/acir-simulator/src/public/db.ts | 2 +- .../acir-simulator/src/public/executor.ts | 13 ++- .../acir-simulator/src/public/index.test.ts | 33 ++++--- .../contracts/noir-aztec3/src/messaging.nr | 1 + .../messaging/get_commitment_getter_data.nr | 24 +++++ .../src/contracts/noir-aztec3/src/oracle.nr | 1 + .../noir-aztec3/src/oracle/get_commitment.nr | 12 +++ .../public_private_contract/src/main.nr | 94 ++++++++++++------- .../src/examples/public_private_contract.json | 44 +++++++++ 15 files changed, 274 insertions(+), 61 deletions(-) create mode 100644 yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/get_commitment_getter_data.nr create mode 100644 yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/get_commitment.nr diff --git a/yarn-project/acir-simulator/src/acvm/acvm.ts b/yarn-project/acir-simulator/src/acvm/acvm.ts index c44cc1d77afc..b4e73f1d3d13 100644 --- a/yarn-project/acir-simulator/src/acvm/acvm.ts +++ b/yarn-project/acir-simulator/src/acvm/acvm.ts @@ -32,6 +32,7 @@ export interface ACIRCallback { createCommitment(params: ACVMField[]): Promise<[ACVMField]>; createL2ToL1Message(params: ACVMField[]): Promise<[ACVMField]>; viewNotesPage(params: ACVMField[]): Promise; + getCommitment(params: ACVMField[]): Promise; getL1ToL2Message(params: ACVMField[]): Promise; /** * Oracle call used to emit an encrypted log. diff --git a/yarn-project/acir-simulator/src/acvm/serialize.ts b/yarn-project/acir-simulator/src/acvm/serialize.ts index 097fd315f2c4..7e534cbad87e 100644 --- a/yarn-project/acir-simulator/src/acvm/serialize.ts +++ b/yarn-project/acir-simulator/src/acvm/serialize.ts @@ -8,7 +8,7 @@ import { PrivateCircuitPublicInputs, PublicCallRequest, } from '@aztec/circuits.js'; -import { MessageLoadOracleInputs } from '../client/db_oracle.js'; +import { CommitmentDataOracleInputs, MessageLoadOracleInputs } from '../client/db_oracle.js'; import { Fr } from '@aztec/foundation/fields'; // Utilities to write TS classes to ACVM Field arrays @@ -126,7 +126,7 @@ export async function toAcvmEnqueuePublicFunctionResult(item: PublicCallRequest) * @param l1ToL2MessagesTreeRoot - The L1 to L2 messages tree root * @returns The Message Oracle Fields. */ -export function toAcvmMessageLoadOracleInputs( +export function toAcvmL1ToL2MessageLoadOracleInputs( messageLoadOracleInputs: MessageLoadOracleInputs, l1ToL2MessagesTreeRoot: Fr, ): ACVMField[] { @@ -138,6 +138,24 @@ export function toAcvmMessageLoadOracleInputs( ]; } +/** + * Converts the result of loading commitments to ACVM fields. + * @param commitmentLoadOracleInputs - The result of loading messages to convert. + * @param l1ToL2MessagesTreeRoot - The L1 to L2 messages tree root + * @returns The Message Oracle Fields. + */ +export function toAcvmCommitmentLoadOracleInputs( + messageLoadOracleInputs: CommitmentDataOracleInputs, + l1ToL2MessagesTreeRoot: Fr, +): ACVMField[] { + return [ + toACVMField(messageLoadOracleInputs.commitment), + ...messageLoadOracleInputs.siblingPath.map(f => toACVMField(f)), + toACVMField(messageLoadOracleInputs.index), + toACVMField(l1ToL2MessagesTreeRoot), + ]; +} + /** * Inserts a list of ACVM fields to a witness. * @param witnessStartIndex - The index where to start inserting the fields. diff --git a/yarn-project/acir-simulator/src/client/client_execution_context.ts b/yarn-project/acir-simulator/src/client/client_execution_context.ts index 2f4e67719484..dab3d1ab9405 100644 --- a/yarn-project/acir-simulator/src/client/client_execution_context.ts +++ b/yarn-project/acir-simulator/src/client/client_execution_context.ts @@ -6,7 +6,8 @@ import { createDummyNote, fromACVMField, toACVMField, - toAcvmMessageLoadOracleInputs, + toAcvmCommitmentLoadOracleInputs, + toAcvmL1ToL2MessageLoadOracleInputs, } from '../acvm/index.js'; import { NoteLoadOracleInputs, DBOracle } from './db_oracle.js'; @@ -91,10 +92,22 @@ export class ClientTxExecutionContext { /** * Fetches the a message from the db, given its key. * @param msgKey - A buffer representing the message key. - * @returns The message data + * @returns The l1 to l2 message data */ public async getL1ToL2Message(msgKey: Fr): Promise { const messageInputs = await this.db.getL1ToL2Message(msgKey); - return toAcvmMessageLoadOracleInputs(messageInputs, this.historicRoots.l1ToL2MessagesTreeRoot); + return toAcvmL1ToL2MessageLoadOracleInputs(messageInputs, this.historicRoots.l1ToL2MessagesTreeRoot); } + + /** + * Fetches a path to prove existence of a commitment in the db, given its contract side commitment (before silo). + * @param contractAddress - The contract address. + * @param commitment - The commitment. + * @returns The commitment data. + */ + public async getCommitment(contractAddress: AztecAddress, commitment: Fr): Promise { + const commitmentInputs = await this.db.getCommitmentOracle(contractAddress, commitment); + return toAcvmCommitmentLoadOracleInputs(commitmentInputs, this.historicRoots.privateDataTreeRoot); + } + } diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index bdb1faf7ea60..afb956fd9393 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -1,4 +1,4 @@ -import { Grumpkin } from '@aztec/circuits.js/barretenberg'; +import { Grumpkin, pedersenCompressInputs } from '@aztec/circuits.js/barretenberg'; import { ARGS_LENGTH, CallContext, @@ -12,7 +12,7 @@ import { PublicCallRequest, TxContext, } from '@aztec/circuits.js'; -import { computeSecretMessageHash } from '@aztec/circuits.js/abis'; +import { computeSecretMessageHash, siloCommitment } from '@aztec/circuits.js/abis'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer'; import { padArrayEnd } from '@aztec/foundation/collection'; @@ -24,6 +24,7 @@ import { ChildAbi, NonNativeTokenContractAbi, ParentAbi, + PublicToPrivateContractAbi, TestContractAbi, ZkTokenContractAbi, } from '@aztec/noir-contracts/examples'; @@ -437,6 +438,58 @@ describe('Private Execution test suite', () => { const newNullifiers = result.callStackItem.publicInputs.newNullifiers.filter(field => !field.equals(Fr.ZERO)); expect(newNullifiers).toHaveLength(1); }, 30_000); + + it("Should be able to consume a dummy public to private message", async () => { + const db = levelup(createMemDown()); + const pedersen = new Pedersen(bbWasm); + + const contractAddress = AztecAddress.random(); + const amount = 100n; + const abi = PublicToPrivateContractAbi.functions.find(f => f.name === 'mintFromPublicMessage')!; + + const wasm = await CircuitsWasm.get(); + const secret = new Fr(1n); + const commitment = Fr.fromBuffer(pedersenCompressInputs(wasm, [toBufferBE(recipient.x, 32), secret.toBuffer() ])); + const siloedCommitment = siloCommitment(wasm, contractAddress, commitment); + + const tree: AppendOnlyTree = await newTree( + StandardTree, + db, + pedersen, + 'privateDataTree', + PRIVATE_DATA_TREE_HEIGHT, + ); + + await tree.appendLeaves([siloedCommitment.toBuffer()]); + + const l1ToL2Root = Fr.fromBuffer(tree.getRoot(false)); + const historicRoots = new PrivateHistoricTreeRoots(Fr.ZERO, Fr.ZERO, Fr.ZERO, l1ToL2Root, Fr.ZERO); + + oracle.getCommitmentOracle.mockImplementation(async () => { + // Check the calculated commitment is correct + return Promise.resolve({ + commitment: siloedCommitment, + index: 0n, + siblingPath: (await tree.getSiblingPath(0n, false)).toFieldArray(), + }); + }); + + const txRequest = new TxExecutionRequest( + AztecAddress.random(), + contractAddress, + new FunctionData(Buffer.alloc(4), true, true), + encodeArguments(abi, [amount, secret, recipient]), + Fr.random(), + txContext, + Fr.ZERO, + ); + + const result = await acirSimulator.run(txRequest, abi, contractAddress, EthAddress.ZERO, historicRoots); + + // Check a nullifier has been created + const newNullifiers = result.callStackItem.publicInputs.newNullifiers.filter(field => !field.equals(Fr.ZERO)); + expect(newNullifiers).toHaveLength(1); + }, 30_000); }); describe('enqueued calls', () => { diff --git a/yarn-project/acir-simulator/src/client/private_execution.ts b/yarn-project/acir-simulator/src/client/private_execution.ts index 7dfc773875fd..6707181156c6 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.ts @@ -194,8 +194,15 @@ export class PrivateFunctionExecution { return toAcvmCallPrivateStackItem(childExecutionResult.callStackItem); }, - getL1ToL2Message: ([msgKey]: ACVMField[]) => this.context.getL1ToL2Message(fromACVMField(msgKey)), - + getL1ToL2Message: ([msgKey]: ACVMField[]) => { + console.log(this.context); + return this.context.getL1ToL2Message(fromACVMField(msgKey)); + }, + getCommitment: ([commitment]: ACVMField[]) => { + console.log("hewuheoiahoA"); + console.log(this.context); + return this.context.getCommitment(this.contractAddress, fromACVMField(commitment)); + }, debugLog: (fields: ACVMField[]) => { this.log(fieldsToFormattedStr(fields)); return Promise.resolve([ZERO_ACVM_FIELD]); diff --git a/yarn-project/acir-simulator/src/client/unconstrained_execution.ts b/yarn-project/acir-simulator/src/client/unconstrained_execution.ts index a16d54bda8cd..968b5238bb3c 100644 --- a/yarn-project/acir-simulator/src/client/unconstrained_execution.ts +++ b/yarn-project/acir-simulator/src/client/unconstrained_execution.ts @@ -64,6 +64,7 @@ export class UnconstrainedFunctionExecution { return Promise.resolve([ZERO_ACVM_FIELD]); }, getL1ToL2Message: ([msgKey]: ACVMField[]) => this.context.getL1ToL2Message(fromACVMField(msgKey)), + getCommitment: ([commitment]: ACVMField[]) => this.context.getCommitment(this.contractAddress, fromACVMField(commitment)), enqueuePublicFunctionCall: notAvailable, notifyCreatedNote: notAvailable, notifyNullifiedNote: notAvailable, diff --git a/yarn-project/acir-simulator/src/public/db.ts b/yarn-project/acir-simulator/src/public/db.ts index 4fbb0eeb6aba..04c740e800b3 100644 --- a/yarn-project/acir-simulator/src/public/db.ts +++ b/yarn-project/acir-simulator/src/public/db.ts @@ -47,6 +47,6 @@ export interface PublicContractsDB { /** Database interface for providing access to commitment tree and l1 to l2 messages tree (append only data trees). */ export interface CommitmentsDB { getL1ToL2Message(msgKey: Fr): Promise; - getCommitmentOracle(address: AztecAddress, msgKey: Fr): Promise; + getCommitmentOracle(address: AztecAddress, commitment: Fr): Promise; getTreeRoots(): PrivateHistoricTreeRoots; } diff --git a/yarn-project/acir-simulator/src/public/executor.ts b/yarn-project/acir-simulator/src/public/executor.ts index 344442f4d31c..177b8bf7b110 100644 --- a/yarn-project/acir-simulator/src/public/executor.ts +++ b/yarn-project/acir-simulator/src/public/executor.ts @@ -3,7 +3,7 @@ import { padArrayEnd } from '@aztec/foundation/collection'; import { createDebugLogger } from '@aztec/foundation/log'; import { TxExecutionRequest } from '@aztec/types'; import { select_return_flattened as selectPublicWitnessFlattened } from '@noir-lang/noir_util_wasm'; -import { ZERO_ACVM_FIELD, acvm, frToAztecAddress, frToSelector, fromACVMField, toACVMField, toACVMWitness } from '../acvm/index.js'; +import { ACVMField, ZERO_ACVM_FIELD, acvm, frToAztecAddress, frToSelector, fromACVMField, toACVMField, toACVMWitness, toAcvmCommitmentLoadOracleInputs, toAcvmL1ToL2MessageLoadOracleInputs } from '../acvm/index.js'; import { CommitmentsDB, PublicContractsDB, PublicStateDB } from './db.js'; import { PublicExecution, PublicExecutionResult } from './execution.js'; import { ContractStorageActionsCollector } from './state_actions.js'; @@ -59,7 +59,16 @@ export class PublicExecutor { emitEncryptedLog: notAvailable, viewNotesPage: notAvailable, debugLog: notAvailable, - getL1ToL2Message: notAvailable, // l1 to l2 messages in public contexts TODO: https://github.com/AztecProtocol/aztec-packages/issues/616 + + // TODO(Maddiaa): both getL1ToL2 and getCommitment share alot of code with the private conterpart? could be refactored + getL1ToL2Message: async ([msgKey]: ACVMField[]) => { + const messageInputs = await this.commitmentsDb.getL1ToL2Message(fromACVMField(msgKey)) + return toAcvmL1ToL2MessageLoadOracleInputs(messageInputs, this.treeRoots.l1ToL2MessagesTreeRoot); + }, // l1 to l2 messages in public contexts TODO: https://github.com/AztecProtocol/aztec-packages/issues/616 + getCommitment: async ([commitment]: ACVMField[]) => { + const commitmentInputs = await this.commitmentsDb.getCommitmentOracle(execution.contractAddress, fromACVMField(commitment)) + return toAcvmCommitmentLoadOracleInputs(commitmentInputs, this.treeRoots.privateDataTreeRoot); + }, storageRead: async ([slot]) => { const storageSlot = fromACVMField(slot); const value = await storageActions.read(storageSlot); diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index 202a93a3fdac..efba86f0c19c 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -222,13 +222,21 @@ describe('ACIR public execution simulator', () => { }); describe("Public -> Private messaging", () => { + let contractAddress: AztecAddress; + let functionData: FunctionData; + let amount: Fr; + let params: Fr[]; + + beforeEach(() => { + contractAddress = AztecAddress.random(); + functionData = new FunctionData(Buffer.alloc(4), false, false); + amount = new Fr(140); + params = [amount, Fr.random()]; + }); + it("Should be able to create a commitment from the public context", async () => { - const contractAddress = AztecAddress.random(); const publicToPrivateAbi = PublicToPrivateContractAbi.functions.find(f => f.name === 'mintFromPublicToPrivate')!; - const functionData = new FunctionData(Buffer.alloc(4), false, false); - const amount = new Fr(140); - const secretHash = Fr.random(); - const args = encodeArguments(publicToPrivateAbi, [amount, secretHash]); + const args = encodeArguments(publicToPrivateAbi, params); const callContext = CallContext.from({ msgSender: AztecAddress.random(), @@ -244,23 +252,17 @@ describe('ACIR public execution simulator', () => { const execution: PublicExecution = { contractAddress, functionData, args, callContext }; const result = await executor.execute(execution); - const expectedReturn = Fr.ZERO; - expect(result.returnValues).toEqual([expectedReturn]); - // Assert the commitment was created expect(result.newCommitments.length).toEqual(1); - const expectedNewCommitmentValue = pedersenCompressInputs(await CircuitsWasm.get(), [amount.toBuffer(), secretHash.toBuffer()]) + const expectedNewCommitmentValue = pedersenCompressInputs(await CircuitsWasm.get(), params.map(a => a.toBuffer())) expect(result.newCommitments[0].toBuffer()).toEqual(expectedNewCommitmentValue); }); it("Should be able to create a L2 to L1 message from the public context", async () => { const contractAddress = AztecAddress.random(); const createL2ToL1MessagePublicAbi = PublicToPrivateContractAbi.functions.find(f => f.name === 'createL2ToL1MessagePublic')!; - const functionData = new FunctionData(Buffer.alloc(4), false, false); - const amount = new Fr(140); - const secretHash = Fr.random(); - const args = encodeArguments(createL2ToL1MessagePublicAbi, [amount, secretHash]); + const args = encodeArguments(createL2ToL1MessagePublicAbi, params); const callContext = CallContext.from({ msgSender: AztecAddress.random(), @@ -276,13 +278,10 @@ describe('ACIR public execution simulator', () => { const execution: PublicExecution = { contractAddress, functionData, args, callContext }; const result = await executor.execute(execution); - const expectedReturn = Fr.ZERO; - expect(result.returnValues).toEqual([expectedReturn]); - // Assert the l2 to l1 message was created expect(result.newL2ToL1Messages.length).toEqual(1); - const expectedNewMessageValue = pedersenCompressInputs(await CircuitsWasm.get(), [amount.toBuffer(), secretHash.toBuffer()]) + const expectedNewMessageValue = pedersenCompressInputs(await CircuitsWasm.get(), params.map(a => a.toBuffer())) expect(result.newL2ToL1Messages[0].toBuffer()).toEqual(expectedNewMessageValue); }); diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging.nr index af5d95d5af14..d8f6ab11bc7f 100644 --- a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging.nr +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging.nr @@ -1,2 +1,3 @@ +mod get_commitment_getter_data; mod l1_to_l2_message; mod l1_to_l2_message_getter_data; \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/get_commitment_getter_data.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/get_commitment_getter_data.nr new file mode 100644 index 000000000000..3be5e82c16de --- /dev/null +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/get_commitment_getter_data.nr @@ -0,0 +1,24 @@ +use crate::messaging::l1_to_l2_message::L1_TO_L2_MESSAGE_LEN; +use crate::messaging::l1_to_l2_message::L1ToL2Message; +use crate::utils::arr_copy_slice; + +struct CommitmentGetterData { + message: Field, + sibling_path: [Field; crate::PRIVATE_DATA_TREE_HEIGHT], + leaf_index: Field, + root: Field, +} + +fn commitment_message_getter_len() -> comptime Field { + 1 + 1 + crate::PRIVATE_DATA_TREE_HEIGHT + 1 +} + +// TODO: 11 as const +fn make_commitment_getter_data(fields: [Field; 11], start: comptime Field) -> CommitmentGetterData { + CommitmentGetterData { + message: fields[start], + leaf_index: fields[1], + sibling_path: arr_copy_slice(fields, [0; crate::PRIVATE_DATA_TREE_HEIGHT], 2), + root: fields[start + 1 + 1 + crate::PRIVATE_DATA_TREE_HEIGHT], + } +} \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle.nr index 847848523b46..1561689556cb 100644 --- a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle.nr +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle.nr @@ -2,6 +2,7 @@ mod call_private_function; mod create_commitment; mod create_l2_to_l1_message; mod debug_log; +mod get_commitment; mod get_l1_to_l2_message; mod get_secret_key; mod rand; diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/get_commitment.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/get_commitment.nr new file mode 100644 index 000000000000..51456803b75e --- /dev/null +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/get_commitment.nr @@ -0,0 +1,12 @@ +// Oracle function to get a commitment, its sibling path and index, without getting its preimage. + + +// commitment + crate::PRIVATE_DATA_TREE_HEIGHT (8) + index + root; +global COMMITMENT_GETTER_LENGTH = 11; + +#[oracle(getCommitment)] +fn get_commitment_oracle(_commitment: Field) -> [Field; COMMITMENT_GETTER_LENGTH] {} + +unconstrained fn get_commitment(commitment: Field) -> [Field; COMMITMENT_GETTER_LENGTH] { + get_commitment_oracle(commitment) +} diff --git a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr index 1ab705e0aca2..6d09c6759827 100644 --- a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr @@ -4,16 +4,29 @@ contract PublicPrivate { use dep::aztec3::abi::PrivateContextInputs; use dep::aztec3::context::PrivateFunctionContext; use dep::aztec3::abi::PublicContextInputs; - use dep::aztec3::types::point::Point; + + // Public state use dep::aztec3::state_vars::storage_map::StorageMap; use dep::aztec3::state_vars::storage_field::StorageField; + // Private state + use dep::aztec3::types::point::Point; + use dep::aztec3::state_vars::map::Map; + use dep::aztec3::state_vars::set::Set; + use dep::aztec3::notes::value_note::Note; + + use dep::aztec3::messaging::get_commitment_getter_data::make_commitment_getter_data; + + use crate::TransparentNote; + + // oracles + use dep::aztec3::oracle::logs::emit_encrypted_log; use dep::aztec3::oracle::create_commitment::create_commitment; use dep::aztec3::oracle::create_l2_to_l1_message::create_l2_to_l1_message; + use dep::aztec3::oracle::get_commitment::get_commitment; - use crate::TransparentNote; - global balances = StorageMap { storage_slot: 1 }; + global balances = Map { storage_slot: 1 }; fn constructor( inputs: pub PrivateContextInputs, @@ -27,7 +40,7 @@ contract PublicPrivate { amount: Field, secretHash: Field, _padding: [Field; dep::aztec3::abi::MAX_ARGS - 3] - ) -> pub Field { + ) -> Field{ // Create a commitment to the amount let note = TransparentNote::new(amount, secretHash); @@ -42,7 +55,7 @@ contract PublicPrivate { amount: Field, secretHash: Field, _padding: [Field; dep::aztec3::abi::MAX_ARGS - 3] - ) -> pub Field { + ) -> Field { // Create a commitment to the amount let note = TransparentNote::new(amount, secretHash); @@ -53,30 +66,37 @@ contract PublicPrivate { } - // open fn transfer( - // inputs: PublicContextInputs, - // amount: Field, - // recipient: Point, - // _padding: [Field; dep::aztec3::abi::MAX_ARGS - 3] - // ) -> pub Field { - // let sender = inputs.call_context.msg_sender; - - // let sender_balance = balances.at(sender); - // let recipient_balance = balances.at(recipient.x); - - // let current_sender_balance = sender_balance.read(); - // let current_recipient_balance = recipient_balance.read(); - - // // TODO: Handle larger integer values ("long integers are not yet supported") - // if (current_sender_balance as u120) > (amount as u120) { - // // TODO: Compiler complains if we don't assign the result of the write to anything - // let _void1 = sender_balance.write(current_sender_balance - amount); - // recipient_balance.write(current_recipient_balance + amount) - // } else { - // // TODO: Revert if there is not enough balance - // current_recipient_balance - // } - // } + fn mintFromPublicMessage( + inputs: pub PrivateContextInputs, + amount: pub Field, + secret: pub Field, + owner: pub Point, + ) -> pub [Field; dep::aztec3::abi::PUBLIC_INPUTS_LENGTH] { + let mut context = PrivateFunctionContext::new(); + context.args = context.args.push_array([amount, secret, owner.x, owner.y]); + + let from_public_note = TransparentNote::new_from_secret(amount, secret); + + let commitment = from_public_note.get_commitment(); + + let commitment_oracle_call = get_commitment(commitment); + let commitment_data = make_commitment_getter_data(commitment_oracle_call, 0); + + constrain inputs.roots.private_data_tree_root == commitment_data.root; + + let nullifier = TransparentNote::compute_nullifier(secret, commitment, commitment_data.leaf_index); + context = context.push_new_nullifier(nullifier); + + // Mint the tokens + let owner_balance = balances.at(owner.x); + let note = Note::new(amount, owner); + + // Insert note and emit encrypted preimage + context = owner_balance.insert(context, note); + constrain emit_encrypted_log(inputs.call_context.storage_contract_address, owner_balance.storage_slot, note.owner, note) == 0; + + context.finish(inputs) + } } @@ -91,9 +111,13 @@ impl TransparentNote { Self { amount, secretHash } } - // fn new_from_secret(amount: Field, secret: Field) -> Self { - - // } + fn new_from_secret(amount: Field, secret: Field) -> Self { + let secretHash = pedersen([secret])[0]; + TransparentNote { + amount, + secretHash, + } + } fn get_commitment(self) -> Field { pedersen([self.amount, self.secretHash])[0] @@ -104,4 +128,10 @@ impl TransparentNote { constrain self.secretHash == hash; } + fn compute_nullifier(secret: Field, siloed_commitment: Field, index: Field) -> Field { + // Create a nullifier for the message based on its index in the tree + + pedersen([secret, siloed_commitment, index])[0] + } + } \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/examples/public_private_contract.json b/yarn-project/noir-contracts/src/examples/public_private_contract.json index 7cdd01f03948..ff7b5e4fd307 100644 --- a/yarn-project/noir-contracts/src/examples/public_private_contract.json +++ b/yarn-project/noir-contracts/src/examples/public_private_contract.json @@ -36,6 +36,50 @@ "bytecode": "0000000016000000000000000100000015000000070000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000030000000000000000000000000000000000000000000000000000000000000000000000010500020000000b000000fe0000000c000000fe000000020000001200000013000000070100000000000000000001000000000000000000000000000000000000000000000000000000000000000000000112000000000000000000000000000000000000000000000000000000000000000000000000000000050100009881a34a4d509103a454726170a453746f7081a64f7261636c6595b36372656174654c32546f4c314d6573736167659181b052656769737465724d656d496e64657881a8526567697374657237909181ad5265676973746572496e6465783b9081a842696e6172794f709581a8556e7369676e6564910181a3436d70a2457181a852656769737465723b81a8436f6e7374616e74d940303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303e81a84a4d5049464e4f549281a852656769737465723e01a843616c6c4261636b81a9426f6f747374726170919137010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000150000000000000000000000000000000000000000000000000000000000000000000000", "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" }, + { + "name": "mintFromPublicMessage", + "functionType": "secret", + "parameters": [ + { + "name": "amount", + "type": { + "kind": "field" + }, + "visibility": "public" + }, + { + "name": "secret", + "type": { + "kind": "field" + }, + "visibility": "public" + }, + { + "name": "owner", + "type": { + "kind": "struct", + "fields": [ + { + "name": "x", + "type": { + "kind": "field" + } + }, + { + "name": "y", + "type": { + "kind": "field" + } + } + ] + }, + "visibility": "public" + } + ], + "returnTypes": [], + "bytecode": "0000000068000000120000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f0000001000000011000000120000002f000000390000003a0000003b0000003c0000003d0000003e0000003f000000400000004100000042000000430000004400000045000000460000004700000048000000490000004a0000004b0000004c0000004d0000004e0000004f000000500000005100000052000000530000005400000055000000560000005700000058000000590000005a0000005b0000005c0000005d0000005e0000005f00000060000000610000006200000063000000640000006500000066000000670000004e0000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000300000000000000000000000000000000000000000000000000000000000000000000000105000100000010000000fe000000020000001300000014000000010500020000000f000000fe00000013000000fe00000002000000150000001600000007010000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011500000000000000000000000000000000000000000000000000000000000000000000000100000001000b0000001700000018000000190000001a0000001b0000001c0000001d0000001e0000001f0000002000000021000000960100009981a34a4d509103a454726170a453746f7081a34d6f769281a85265676973746572cd021081a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030323381a64f7261636c6595ad676574436f6d6d69746d656e749181b052656769737465724d656d496e64657881a85265676973746572cd0209909181a541727261799281a8436f6e7374616e74d940303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303032330b9081a34d6f769281a85265676973746572cd021081a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030323381a34d6f769281a852656769737465720081a85265676973746572cd0210a843616c6c4261636b81a9426f6f7473747261709191cd0209010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000300000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000022000000000000000000000000000000000000000000000000000000000000000000000002000022000000230000000001000000010000000000000000000000000000000000000000000000000000000000000000000001220000002300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002400000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001220000002400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000022000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012400000000000000000000000000000000000000000000000000000000000000000000000105000300000010000000fe00000015000000fe00000018000000fe00000002000000250000002600000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000027000000000000000000000000000000000000000000000000000000000000000000000400000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002800000000000000000000000000000000000000000000000000000000000000000000010105000300000027000000fe00000028000000fe00000011000000fe00000002000000290000002a00000007000000000100000000002b000000740000009781a34a4d509103a454726170a453746f7081a64f7261636c6595ae67657452616e646f6d4669656c6490909181ad5265676973746572496e646578cd035b9081a34d6f769281a852656769737465720081a85265676973746572cd035ba843616c6c4261636b81a9426f6f7473747261709190010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002c000000000000000000000000000000000000000000000000000000000000000000000200000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002d0000000000000000000000000000000000000000000000000000000000000000000003010500070000002c000000fe00000028000000fe0000002d000000fe00000011000000fe00000012000000fe0000002b000000fe0000000f000000fe000000020000002e0000002f00000007090000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012900000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012800000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012d00000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012b00000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010f000000000000000000000000000000000000000000000000000000000000000000000001000000000030000000a90100009781a34a4d509103a454726170a453746f7081a64f7261636c6595b16e6f74696679437265617465644e6f74659981b052656769737465724d656d496e64657881a85265676973746572cd03da81b052656769737465724d656d496e64657881a85265676973746572cd03db81b052656769737465724d656d496e64657881a85265676973746572cd03dc81b052656769737465724d656d496e64657881a85265676973746572cd03dd81b052656769737465724d656d496e64657881a85265676973746572cd03de81b052656769737465724d656d496e64657881a85265676973746572cd03df81b052656769737465724d656d496e64657881a85265676973746572cd03e081b052656769737465724d656d496e64657881a85265676973746572cd03e181b052656769737465724d656d496e64657881a85265676973746572cd03e2909181ad5265676973746572496e646578cd03ee9081a34d6f769281a852656769737465720081a85265676973746572cd03eea843616c6c4261636b81a9426f6f7473747261709199cd03dacd03dbcd03dccd03ddcd03decd03dfcd03e0cd03e1cd03e2010000000000000000000000000000000000000000000000000000000000000000000000000000000102000030000000310000000001000000010000000000000000000000000000000000000000000000000000000000000000000001300000003100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001300000003200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000001320000000000000000000000000000000000000000000000000000000000000000000000070a0000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010600000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012900000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012800000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012d00000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012b00000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010f000000000000000000000000000000000000000000000000000000000000000000000001000000000033000000ca0100009781a34a4d509103a454726170a453746f7081a64f7261636c6595b0656d6974456e637279707465644c6f679a81b052656769737465724d656d496e64657881a85265676973746572cd048381b052656769737465724d656d496e64657881a85265676973746572cd048481b052656769737465724d656d496e64657881a85265676973746572cd048581b052656769737465724d656d496e64657881a85265676973746572cd048681b052656769737465724d656d496e64657881a85265676973746572cd048781b052656769737465724d656d496e64657881a85265676973746572cd048881b052656769737465724d656d496e64657881a85265676973746572cd048981b052656769737465724d656d496e64657881a85265676973746572cd048a81b052656769737465724d656d496e64657881a85265676973746572cd048b81b052656769737465724d656d496e64657881a85265676973746572cd048c909181ad5265676973746572496e646578cd04999081a34d6f769281a852656769737465720081a85265676973746572cd0499a843616c6c4261636b81a9426f6f747374726170919acd0483cd0484cd0485cd0486cd0487cd0488cd0489cd048acd048bcd048c010000000000000000000000000000000000000000000000000000000000000000000000000000000102000033000000340000000001000000010000000000000000000000000000000000000000000000000000000000000000000001330000003400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003500000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001330000003500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000330000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000135000000000000000000000000000000000000000000000000000000000000000000000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000360000000000000000000000000000000000000000000000000000000000000000000000010500080000000f000000fe00000010000000fe00000011000000fe00000012000000fe00000036000000fe00000036000000fe00000036000000fe00000036000000fe00000002000000370000003800000000000000000200000000000000000000000000000000000000000000000000000000000000000000010400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000039000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000041000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000042000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000043000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000044000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000045000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000046000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000047000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000048000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000049000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000051000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000052000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000053000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000054000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000055000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000056000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000057000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000058000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000059000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010800000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000061000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000062000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000063000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000064000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000065000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000066000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000670000000000000000000000000000000000000000000000000000000000000000000000", + "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" + }, { "name": "mintFromPublicToPrivate", "functionType": "open", From 7dc2ca3b72195a054b30151522bdf4444658414b Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 12 Jun 2023 18:16:31 +0000 Subject: [PATCH 04/13] chore: formatting:fix --- .../src/client/client_execution_context.ts | 3 +- .../src/client/private_execution.test.ts | 4 +- .../src/client/private_execution.ts | 2 +- .../src/client/unconstrained_execution.ts | 3 +- .../acir-simulator/src/public/executor.ts | 26 +++-- .../acir-simulator/src/public/index.test.ts | 94 +++++++++++-------- 6 files changed, 79 insertions(+), 53 deletions(-) diff --git a/yarn-project/acir-simulator/src/client/client_execution_context.ts b/yarn-project/acir-simulator/src/client/client_execution_context.ts index dab3d1ab9405..9e5695dad68e 100644 --- a/yarn-project/acir-simulator/src/client/client_execution_context.ts +++ b/yarn-project/acir-simulator/src/client/client_execution_context.ts @@ -102,12 +102,11 @@ export class ClientTxExecutionContext { /** * Fetches a path to prove existence of a commitment in the db, given its contract side commitment (before silo). * @param contractAddress - The contract address. - * @param commitment - The commitment. + * @param commitment - The commitment. * @returns The commitment data. */ public async getCommitment(contractAddress: AztecAddress, commitment: Fr): Promise { const commitmentInputs = await this.db.getCommitmentOracle(contractAddress, commitment); return toAcvmCommitmentLoadOracleInputs(commitmentInputs, this.historicRoots.privateDataTreeRoot); } - } diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index afb956fd9393..79f866dfb94c 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -439,7 +439,7 @@ describe('Private Execution test suite', () => { expect(newNullifiers).toHaveLength(1); }, 30_000); - it("Should be able to consume a dummy public to private message", async () => { + it('Should be able to consume a dummy public to private message', async () => { const db = levelup(createMemDown()); const pedersen = new Pedersen(bbWasm); @@ -449,7 +449,7 @@ describe('Private Execution test suite', () => { const wasm = await CircuitsWasm.get(); const secret = new Fr(1n); - const commitment = Fr.fromBuffer(pedersenCompressInputs(wasm, [toBufferBE(recipient.x, 32), secret.toBuffer() ])); + const commitment = Fr.fromBuffer(pedersenCompressInputs(wasm, [toBufferBE(recipient.x, 32), secret.toBuffer()])); const siloedCommitment = siloCommitment(wasm, contractAddress, commitment); const tree: AppendOnlyTree = await newTree( diff --git a/yarn-project/acir-simulator/src/client/private_execution.ts b/yarn-project/acir-simulator/src/client/private_execution.ts index 6707181156c6..dc22096d722b 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.ts @@ -199,7 +199,7 @@ export class PrivateFunctionExecution { return this.context.getL1ToL2Message(fromACVMField(msgKey)); }, getCommitment: ([commitment]: ACVMField[]) => { - console.log("hewuheoiahoA"); + console.log('hewuheoiahoA'); console.log(this.context); return this.context.getCommitment(this.contractAddress, fromACVMField(commitment)); }, diff --git a/yarn-project/acir-simulator/src/client/unconstrained_execution.ts b/yarn-project/acir-simulator/src/client/unconstrained_execution.ts index 968b5238bb3c..acbe874345e6 100644 --- a/yarn-project/acir-simulator/src/client/unconstrained_execution.ts +++ b/yarn-project/acir-simulator/src/client/unconstrained_execution.ts @@ -64,7 +64,8 @@ export class UnconstrainedFunctionExecution { return Promise.resolve([ZERO_ACVM_FIELD]); }, getL1ToL2Message: ([msgKey]: ACVMField[]) => this.context.getL1ToL2Message(fromACVMField(msgKey)), - getCommitment: ([commitment]: ACVMField[]) => this.context.getCommitment(this.contractAddress, fromACVMField(commitment)), + getCommitment: ([commitment]: ACVMField[]) => + this.context.getCommitment(this.contractAddress, fromACVMField(commitment)), enqueuePublicFunctionCall: notAvailable, notifyCreatedNote: notAvailable, notifyNullifiedNote: notAvailable, diff --git a/yarn-project/acir-simulator/src/public/executor.ts b/yarn-project/acir-simulator/src/public/executor.ts index 177b8bf7b110..1ed451071a88 100644 --- a/yarn-project/acir-simulator/src/public/executor.ts +++ b/yarn-project/acir-simulator/src/public/executor.ts @@ -3,7 +3,18 @@ import { padArrayEnd } from '@aztec/foundation/collection'; import { createDebugLogger } from '@aztec/foundation/log'; import { TxExecutionRequest } from '@aztec/types'; import { select_return_flattened as selectPublicWitnessFlattened } from '@noir-lang/noir_util_wasm'; -import { ACVMField, ZERO_ACVM_FIELD, acvm, frToAztecAddress, frToSelector, fromACVMField, toACVMField, toACVMWitness, toAcvmCommitmentLoadOracleInputs, toAcvmL1ToL2MessageLoadOracleInputs } from '../acvm/index.js'; +import { + ACVMField, + ZERO_ACVM_FIELD, + acvm, + frToAztecAddress, + frToSelector, + fromACVMField, + toACVMField, + toACVMWitness, + toAcvmCommitmentLoadOracleInputs, + toAcvmL1ToL2MessageLoadOracleInputs, +} from '../acvm/index.js'; import { CommitmentsDB, PublicContractsDB, PublicStateDB } from './db.js'; import { PublicExecution, PublicExecutionResult } from './execution.js'; import { ContractStorageActionsCollector } from './state_actions.js'; @@ -59,14 +70,17 @@ export class PublicExecutor { emitEncryptedLog: notAvailable, viewNotesPage: notAvailable, debugLog: notAvailable, - + // TODO(Maddiaa): both getL1ToL2 and getCommitment share alot of code with the private conterpart? could be refactored getL1ToL2Message: async ([msgKey]: ACVMField[]) => { - const messageInputs = await this.commitmentsDb.getL1ToL2Message(fromACVMField(msgKey)) + const messageInputs = await this.commitmentsDb.getL1ToL2Message(fromACVMField(msgKey)); return toAcvmL1ToL2MessageLoadOracleInputs(messageInputs, this.treeRoots.l1ToL2MessagesTreeRoot); }, // l1 to l2 messages in public contexts TODO: https://github.com/AztecProtocol/aztec-packages/issues/616 getCommitment: async ([commitment]: ACVMField[]) => { - const commitmentInputs = await this.commitmentsDb.getCommitmentOracle(execution.contractAddress, fromACVMField(commitment)) + const commitmentInputs = await this.commitmentsDb.getCommitmentOracle( + execution.contractAddress, + fromACVMField(commitment), + ); return toAcvmCommitmentLoadOracleInputs(commitmentInputs, this.treeRoots.privateDataTreeRoot); }, storageRead: async ([slot]) => { @@ -84,12 +98,12 @@ export class PublicExecutor { return [toACVMField(newValue)]; }, createCommitment: async ([commitment]) => { - this.log("Creating commitment: " + commitment.toString()); + this.log('Creating commitment: ' + commitment.toString()); newCommitments.push(fromACVMField(commitment)); return await Promise.resolve([ZERO_ACVM_FIELD]); }, createL2ToL1Message: async ([message]) => { - this.log("Creating L2 to L1 message: " + message.toString()); + this.log('Creating L2 to L1 message: ' + message.toString()); newL2ToL1Messages.push(fromACVMField(message)); return await Promise.resolve([ZERO_ACVM_FIELD]); }, diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index efba86f0c19c..d13bbb9d8473 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -4,7 +4,12 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; import { FunctionAbi } from '@aztec/foundation/abi'; -import { ChildAbi, ParentAbi, PublicToPrivateContractAbi, PublicTokenContractAbi } from '@aztec/noir-contracts/examples'; +import { + ChildAbi, + ParentAbi, + PublicToPrivateContractAbi, + PublicTokenContractAbi, +} from '@aztec/noir-contracts/examples'; import { MockProxy, mock } from 'jest-mock-extended'; import { default as memdown, type MemDown } from 'memdown'; import { encodeArguments } from '../abi_coder/encoder.js'; @@ -221,12 +226,12 @@ describe('ACIR public execution simulator', () => { }); }); - describe("Public -> Private messaging", () => { + describe('Public -> Private messaging', () => { let contractAddress: AztecAddress; let functionData: FunctionData; let amount: Fr; let params: Fr[]; - + beforeEach(() => { contractAddress = AztecAddress.random(); functionData = new FunctionData(Buffer.alloc(4), false, false); @@ -234,56 +239,63 @@ describe('ACIR public execution simulator', () => { params = [amount, Fr.random()]; }); - it("Should be able to create a commitment from the public context", async () => { - const publicToPrivateAbi = PublicToPrivateContractAbi.functions.find(f => f.name === 'mintFromPublicToPrivate')!; - const args = encodeArguments(publicToPrivateAbi, params); + it('Should be able to create a commitment from the public context', async () => { + const publicToPrivateAbi = PublicToPrivateContractAbi.functions.find(f => f.name === 'mintFromPublicToPrivate')!; + const args = encodeArguments(publicToPrivateAbi, params); - const callContext = CallContext.from({ - msgSender: AztecAddress.random(), - storageContractAddress: contractAddress, - portalContractAddress: EthAddress.random(), - isContractDeployment: false, - isDelegateCall: false, - isStaticCall: false, - }); + const callContext = CallContext.from({ + msgSender: AztecAddress.random(), + storageContractAddress: contractAddress, + portalContractAddress: EthAddress.random(), + isContractDeployment: false, + isDelegateCall: false, + isStaticCall: false, + }); - publicContracts.getBytecode.mockResolvedValue(Buffer.from(publicToPrivateAbi.bytecode, 'hex')); + publicContracts.getBytecode.mockResolvedValue(Buffer.from(publicToPrivateAbi.bytecode, 'hex')); - const execution: PublicExecution = { contractAddress, functionData, args, callContext }; - const result = await executor.execute(execution); + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + const result = await executor.execute(execution); - // Assert the commitment was created - expect(result.newCommitments.length).toEqual(1); + // Assert the commitment was created + expect(result.newCommitments.length).toEqual(1); - const expectedNewCommitmentValue = pedersenCompressInputs(await CircuitsWasm.get(), params.map(a => a.toBuffer())) - expect(result.newCommitments[0].toBuffer()).toEqual(expectedNewCommitmentValue); + const expectedNewCommitmentValue = pedersenCompressInputs( + await CircuitsWasm.get(), + params.map(a => a.toBuffer()), + ); + expect(result.newCommitments[0].toBuffer()).toEqual(expectedNewCommitmentValue); }); - it("Should be able to create a L2 to L1 message from the public context", async () => { - const contractAddress = AztecAddress.random(); - const createL2ToL1MessagePublicAbi = PublicToPrivateContractAbi.functions.find(f => f.name === 'createL2ToL1MessagePublic')!; - const args = encodeArguments(createL2ToL1MessagePublicAbi, params); + it('Should be able to create a L2 to L1 message from the public context', async () => { + const contractAddress = AztecAddress.random(); + const createL2ToL1MessagePublicAbi = PublicToPrivateContractAbi.functions.find( + f => f.name === 'createL2ToL1MessagePublic', + )!; + const args = encodeArguments(createL2ToL1MessagePublicAbi, params); - const callContext = CallContext.from({ - msgSender: AztecAddress.random(), - storageContractAddress: contractAddress, - portalContractAddress: EthAddress.random(), - isContractDeployment: false, - isDelegateCall: false, - isStaticCall: false, - }); + const callContext = CallContext.from({ + msgSender: AztecAddress.random(), + storageContractAddress: contractAddress, + portalContractAddress: EthAddress.random(), + isContractDeployment: false, + isDelegateCall: false, + isStaticCall: false, + }); - publicContracts.getBytecode.mockResolvedValue(Buffer.from(createL2ToL1MessagePublicAbi.bytecode, 'hex')); + publicContracts.getBytecode.mockResolvedValue(Buffer.from(createL2ToL1MessagePublicAbi.bytecode, 'hex')); - const execution: PublicExecution = { contractAddress, functionData, args, callContext }; - const result = await executor.execute(execution); + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + const result = await executor.execute(execution); - // Assert the l2 to l1 message was created - expect(result.newL2ToL1Messages.length).toEqual(1); + // Assert the l2 to l1 message was created + expect(result.newL2ToL1Messages.length).toEqual(1); - const expectedNewMessageValue = pedersenCompressInputs(await CircuitsWasm.get(), params.map(a => a.toBuffer())) - expect(result.newL2ToL1Messages[0].toBuffer()).toEqual(expectedNewMessageValue); + const expectedNewMessageValue = pedersenCompressInputs( + await CircuitsWasm.get(), + params.map(a => a.toBuffer()), + ); + expect(result.newL2ToL1Messages[0].toBuffer()).toEqual(expectedNewMessageValue); }); - }); }); From 230bf199339381888ca32668d0a90bfa0eefed3f Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 12 Jun 2023 18:40:07 +0000 Subject: [PATCH 05/13] refactor: implement with read requests --- yarn-project/acir-simulator/src/acvm/serialize.ts | 1 - .../src/client/client_execution_context.ts | 7 +++++-- .../src/client/private_execution.test.ts | 14 ++++++++++---- .../acir-simulator/src/client/private_execution.ts | 9 ++++----- .../src/client/unconstrained_execution.ts | 2 +- .../src/messaging/get_commitment_getter_data.nr | 12 +++++------- .../noir-aztec3/src/oracle/get_commitment.nr | 4 ++-- .../contracts/public_private_contract/src/main.nr | 4 ++++ .../src/examples/public_private_contract.json | 4 ++-- 9 files changed, 33 insertions(+), 24 deletions(-) diff --git a/yarn-project/acir-simulator/src/acvm/serialize.ts b/yarn-project/acir-simulator/src/acvm/serialize.ts index 7e534cbad87e..1aa0283df2c3 100644 --- a/yarn-project/acir-simulator/src/acvm/serialize.ts +++ b/yarn-project/acir-simulator/src/acvm/serialize.ts @@ -150,7 +150,6 @@ export function toAcvmCommitmentLoadOracleInputs( ): ACVMField[] { return [ toACVMField(messageLoadOracleInputs.commitment), - ...messageLoadOracleInputs.siblingPath.map(f => toACVMField(f)), toACVMField(messageLoadOracleInputs.index), toACVMField(l1ToL2MessagesTreeRoot), ]; diff --git a/yarn-project/acir-simulator/src/client/client_execution_context.ts b/yarn-project/acir-simulator/src/client/client_execution_context.ts index 9e5695dad68e..2ae7f73fa395 100644 --- a/yarn-project/acir-simulator/src/client/client_execution_context.ts +++ b/yarn-project/acir-simulator/src/client/client_execution_context.ts @@ -105,8 +105,11 @@ export class ClientTxExecutionContext { * @param commitment - The commitment. * @returns The commitment data. */ - public async getCommitment(contractAddress: AztecAddress, commitment: Fr): Promise { + public async getCommitment(contractAddress: AztecAddress, commitment: Fr){ const commitmentInputs = await this.db.getCommitmentOracle(contractAddress, commitment); - return toAcvmCommitmentLoadOracleInputs(commitmentInputs, this.historicRoots.privateDataTreeRoot); + return { + acvmData: toAcvmCommitmentLoadOracleInputs(commitmentInputs, this.historicRoots.privateDataTreeRoot), + index: commitmentInputs.index, + }; } } diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index 79f866dfb94c..bd77f6418651 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -449,7 +449,8 @@ describe('Private Execution test suite', () => { const wasm = await CircuitsWasm.get(); const secret = new Fr(1n); - const commitment = Fr.fromBuffer(pedersenCompressInputs(wasm, [toBufferBE(recipient.x, 32), secret.toBuffer()])); + const secretHash = pedersenCompressInputs(wasm, [secret.toBuffer()]); + const commitment = Fr.fromBuffer(pedersenCompressInputs(wasm, [toBufferBE(amount, 32), secretHash])); const siloedCommitment = siloCommitment(wasm, contractAddress, commitment); const tree: AppendOnlyTree = await newTree( @@ -462,8 +463,8 @@ describe('Private Execution test suite', () => { await tree.appendLeaves([siloedCommitment.toBuffer()]); - const l1ToL2Root = Fr.fromBuffer(tree.getRoot(false)); - const historicRoots = new PrivateHistoricTreeRoots(Fr.ZERO, Fr.ZERO, Fr.ZERO, l1ToL2Root, Fr.ZERO); + const privateDataTreeRoot = Fr.fromBuffer(tree.getRoot(false)); + const historicRoots = new PrivateHistoricTreeRoots(Fr.ZERO, Fr.ZERO, Fr.ZERO, privateDataTreeRoot, Fr.ZERO); oracle.getCommitmentOracle.mockImplementation(async () => { // Check the calculated commitment is correct @@ -486,9 +487,14 @@ describe('Private Execution test suite', () => { const result = await acirSimulator.run(txRequest, abi, contractAddress, EthAddress.ZERO, historicRoots); - // Check a nullifier has been created + // Check a nullifier has been created. const newNullifiers = result.callStackItem.publicInputs.newNullifiers.filter(field => !field.equals(Fr.ZERO)); expect(newNullifiers).toHaveLength(1); + + // Check the commitment read request was created successfully. + const readRequests = result.callStackItem.publicInputs.readRequests.filter(field => !field.equals(Fr.ZERO)); + expect(readRequests).toHaveLength(1); + expect(readRequests[0]).toEqual(commitment); }, 30_000); }); diff --git a/yarn-project/acir-simulator/src/client/private_execution.ts b/yarn-project/acir-simulator/src/client/private_execution.ts index dc22096d722b..ff89a6b75289 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.ts @@ -195,13 +195,12 @@ export class PrivateFunctionExecution { return toAcvmCallPrivateStackItem(childExecutionResult.callStackItem); }, getL1ToL2Message: ([msgKey]: ACVMField[]) => { - console.log(this.context); return this.context.getL1ToL2Message(fromACVMField(msgKey)); }, - getCommitment: ([commitment]: ACVMField[]) => { - console.log('hewuheoiahoA'); - console.log(this.context); - return this.context.getCommitment(this.contractAddress, fromACVMField(commitment)); + getCommitment: async ([commitment]: ACVMField[]) => { + const commitmentData = await this.context.getCommitment(this.contractAddress, fromACVMField(commitment)); + readRequestCommitmentIndices.push(commitmentData.index); + return commitmentData.acvmData; }, debugLog: (fields: ACVMField[]) => { this.log(fieldsToFormattedStr(fields)); diff --git a/yarn-project/acir-simulator/src/client/unconstrained_execution.ts b/yarn-project/acir-simulator/src/client/unconstrained_execution.ts index acbe874345e6..19a338bfd05a 100644 --- a/yarn-project/acir-simulator/src/client/unconstrained_execution.ts +++ b/yarn-project/acir-simulator/src/client/unconstrained_execution.ts @@ -65,7 +65,7 @@ export class UnconstrainedFunctionExecution { }, getL1ToL2Message: ([msgKey]: ACVMField[]) => this.context.getL1ToL2Message(fromACVMField(msgKey)), getCommitment: ([commitment]: ACVMField[]) => - this.context.getCommitment(this.contractAddress, fromACVMField(commitment)), + this.context.getCommitment(this.contractAddress, fromACVMField(commitment)).then(commitmentData => commitmentData.acvmData), enqueuePublicFunctionCall: notAvailable, notifyCreatedNote: notAvailable, notifyNullifiedNote: notAvailable, diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/get_commitment_getter_data.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/get_commitment_getter_data.nr index 3be5e82c16de..8b5dcafefb18 100644 --- a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/get_commitment_getter_data.nr +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/get_commitment_getter_data.nr @@ -4,21 +4,19 @@ use crate::utils::arr_copy_slice; struct CommitmentGetterData { message: Field, - sibling_path: [Field; crate::PRIVATE_DATA_TREE_HEIGHT], leaf_index: Field, root: Field, } fn commitment_message_getter_len() -> comptime Field { - 1 + 1 + crate::PRIVATE_DATA_TREE_HEIGHT + 1 + 1 + 1 + 1 } -// TODO: 11 as const -fn make_commitment_getter_data(fields: [Field; 11], start: comptime Field) -> CommitmentGetterData { +// TODO: 3 as const +fn make_commitment_getter_data(fields: [Field; 3], start: comptime Field) -> CommitmentGetterData { CommitmentGetterData { message: fields[start], - leaf_index: fields[1], - sibling_path: arr_copy_slice(fields, [0; crate::PRIVATE_DATA_TREE_HEIGHT], 2), - root: fields[start + 1 + 1 + crate::PRIVATE_DATA_TREE_HEIGHT], + leaf_index: fields[start + 1], + root: fields[start + 2], } } \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/get_commitment.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/get_commitment.nr index 51456803b75e..1e40cb41e88e 100644 --- a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/get_commitment.nr +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/get_commitment.nr @@ -1,8 +1,8 @@ // Oracle function to get a commitment, its sibling path and index, without getting its preimage. -// commitment + crate::PRIVATE_DATA_TREE_HEIGHT (8) + index + root; -global COMMITMENT_GETTER_LENGTH = 11; +// commitment + index + root; +global COMMITMENT_GETTER_LENGTH = 3; #[oracle(getCommitment)] fn get_commitment_oracle(_commitment: Field) -> [Field; COMMITMENT_GETTER_LENGTH] {} diff --git a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr index 6d09c6759827..295a2b406795 100644 --- a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr @@ -79,8 +79,12 @@ contract PublicPrivate { let commitment = from_public_note.get_commitment(); + // Perform read request for the kernel. + context = context.push_read_request(commitment); + let commitment_oracle_call = get_commitment(commitment); let commitment_data = make_commitment_getter_data(commitment_oracle_call, 0); + constrain inputs.roots.private_data_tree_root == commitment_data.root; diff --git a/yarn-project/noir-contracts/src/examples/public_private_contract.json b/yarn-project/noir-contracts/src/examples/public_private_contract.json index ff7b5e4fd307..9114e0c74959 100644 --- a/yarn-project/noir-contracts/src/examples/public_private_contract.json +++ b/yarn-project/noir-contracts/src/examples/public_private_contract.json @@ -6,7 +6,7 @@ "functionType": "secret", "parameters": [], "returnTypes": [], - "bytecode": "00000000410000000e0000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000002f00000012000000130000001400000015000000160000001700000018000000190000001a0000001b0000001c0000001d0000001e0000001f000000200000002100000022000000230000002400000025000000260000002700000028000000290000002a0000002b0000002c0000002d0000002e0000002f000000300000003100000032000000330000003400000035000000360000003700000038000000390000003a0000003b0000003c0000003d0000003e0000003f00000040000000340000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000f0000000000000000000000000000000000000000000000000000000000000000000000010500080000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe00000002000000100000001100000000000000000200000000000000000000000000000000000000000000000000000000000000000000010400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000012000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000013000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000015000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000016000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000017000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000019000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000021000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000022000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000023000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000024000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000025000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000026000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000027000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000028000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000029000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000031000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000032000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000033000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000034000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010800000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000035000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000036000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000037000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000038000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000039000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000400000000000000000000000000000000000000000000000000000000000000000000000", + "bytecode": "000000003b0000000e0000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000002900000012000000130000001400000015000000160000001700000018000000190000001a0000001b0000001c0000001d0000001e0000001f000000200000002100000022000000230000002400000025000000260000002700000028000000290000002a0000002b0000002c0000002d0000002e0000002f000000300000003100000032000000330000003400000035000000360000003700000038000000390000003a0000002e0000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000f0000000000000000000000000000000000000000000000000000000000000000000000010500080000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe0000000f000000fe00000002000000100000001100000000000000000200000000000000000000000000000000000000000000000000000000000000000000010400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000012000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000013000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000015000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000016000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000017000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000019000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000021000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000022000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000023000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000024000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000025000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000026000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000027000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000028000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000029000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000031000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000032000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000033000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000034000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000035000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000036000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000037000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000038000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010800000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000039000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003a0000000000000000000000000000000000000000000000000000000000000000000000", "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" }, { @@ -77,7 +77,7 @@ } ], "returnTypes": [], - "bytecode": "0000000068000000120000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f0000001000000011000000120000002f000000390000003a0000003b0000003c0000003d0000003e0000003f000000400000004100000042000000430000004400000045000000460000004700000048000000490000004a0000004b0000004c0000004d0000004e0000004f000000500000005100000052000000530000005400000055000000560000005700000058000000590000005a0000005b0000005c0000005d0000005e0000005f00000060000000610000006200000063000000640000006500000066000000670000004e0000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000300000000000000000000000000000000000000000000000000000000000000000000000105000100000010000000fe000000020000001300000014000000010500020000000f000000fe00000013000000fe00000002000000150000001600000007010000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011500000000000000000000000000000000000000000000000000000000000000000000000100000001000b0000001700000018000000190000001a0000001b0000001c0000001d0000001e0000001f0000002000000021000000960100009981a34a4d509103a454726170a453746f7081a34d6f769281a85265676973746572cd021081a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030323381a64f7261636c6595ad676574436f6d6d69746d656e749181b052656769737465724d656d496e64657881a85265676973746572cd0209909181a541727261799281a8436f6e7374616e74d940303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303032330b9081a34d6f769281a85265676973746572cd021081a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030323381a34d6f769281a852656769737465720081a85265676973746572cd0210a843616c6c4261636b81a9426f6f7473747261709191cd0209010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000300000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000022000000000000000000000000000000000000000000000000000000000000000000000002000022000000230000000001000000010000000000000000000000000000000000000000000000000000000000000000000001220000002300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002400000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001220000002400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000022000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012400000000000000000000000000000000000000000000000000000000000000000000000105000300000010000000fe00000015000000fe00000018000000fe00000002000000250000002600000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000027000000000000000000000000000000000000000000000000000000000000000000000400000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002800000000000000000000000000000000000000000000000000000000000000000000010105000300000027000000fe00000028000000fe00000011000000fe00000002000000290000002a00000007000000000100000000002b000000740000009781a34a4d509103a454726170a453746f7081a64f7261636c6595ae67657452616e646f6d4669656c6490909181ad5265676973746572496e646578cd035b9081a34d6f769281a852656769737465720081a85265676973746572cd035ba843616c6c4261636b81a9426f6f7473747261709190010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002c000000000000000000000000000000000000000000000000000000000000000000000200000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002d0000000000000000000000000000000000000000000000000000000000000000000003010500070000002c000000fe00000028000000fe0000002d000000fe00000011000000fe00000012000000fe0000002b000000fe0000000f000000fe000000020000002e0000002f00000007090000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012900000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012800000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012d00000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012b00000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010f000000000000000000000000000000000000000000000000000000000000000000000001000000000030000000a90100009781a34a4d509103a454726170a453746f7081a64f7261636c6595b16e6f74696679437265617465644e6f74659981b052656769737465724d656d496e64657881a85265676973746572cd03da81b052656769737465724d656d496e64657881a85265676973746572cd03db81b052656769737465724d656d496e64657881a85265676973746572cd03dc81b052656769737465724d656d496e64657881a85265676973746572cd03dd81b052656769737465724d656d496e64657881a85265676973746572cd03de81b052656769737465724d656d496e64657881a85265676973746572cd03df81b052656769737465724d656d496e64657881a85265676973746572cd03e081b052656769737465724d656d496e64657881a85265676973746572cd03e181b052656769737465724d656d496e64657881a85265676973746572cd03e2909181ad5265676973746572496e646578cd03ee9081a34d6f769281a852656769737465720081a85265676973746572cd03eea843616c6c4261636b81a9426f6f7473747261709199cd03dacd03dbcd03dccd03ddcd03decd03dfcd03e0cd03e1cd03e2010000000000000000000000000000000000000000000000000000000000000000000000000000000102000030000000310000000001000000010000000000000000000000000000000000000000000000000000000000000000000001300000003100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001300000003200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000001320000000000000000000000000000000000000000000000000000000000000000000000070a0000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010600000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012900000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012800000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012d00000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012b00000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010f000000000000000000000000000000000000000000000000000000000000000000000001000000000033000000ca0100009781a34a4d509103a454726170a453746f7081a64f7261636c6595b0656d6974456e637279707465644c6f679a81b052656769737465724d656d496e64657881a85265676973746572cd048381b052656769737465724d656d496e64657881a85265676973746572cd048481b052656769737465724d656d496e64657881a85265676973746572cd048581b052656769737465724d656d496e64657881a85265676973746572cd048681b052656769737465724d656d496e64657881a85265676973746572cd048781b052656769737465724d656d496e64657881a85265676973746572cd048881b052656769737465724d656d496e64657881a85265676973746572cd048981b052656769737465724d656d496e64657881a85265676973746572cd048a81b052656769737465724d656d496e64657881a85265676973746572cd048b81b052656769737465724d656d496e64657881a85265676973746572cd048c909181ad5265676973746572496e646578cd04999081a34d6f769281a852656769737465720081a85265676973746572cd0499a843616c6c4261636b81a9426f6f747374726170919acd0483cd0484cd0485cd0486cd0487cd0488cd0489cd048acd048bcd048c010000000000000000000000000000000000000000000000000000000000000000000000000000000102000033000000340000000001000000010000000000000000000000000000000000000000000000000000000000000000000001330000003400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003500000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001330000003500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000330000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000135000000000000000000000000000000000000000000000000000000000000000000000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000360000000000000000000000000000000000000000000000000000000000000000000000010500080000000f000000fe00000010000000fe00000011000000fe00000012000000fe00000036000000fe00000036000000fe00000036000000fe00000036000000fe00000002000000370000003800000000000000000200000000000000000000000000000000000000000000000000000000000000000000010400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000039000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000041000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000042000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000043000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000044000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000045000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000046000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000047000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000048000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000049000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000051000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000052000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000053000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000054000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000055000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000056000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000057000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000058000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000059000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010800000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000061000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000062000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000063000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000064000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000065000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000066000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000670000000000000000000000000000000000000000000000000000000000000000000000", + "bytecode": "000000005a000000120000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f000000100000001100000012000000290000003100000032000000330000003400000035000000360000003700000038000000390000003a0000003b0000003c0000003d0000003e0000003f000000400000004100000042000000430000004400000045000000460000004700000048000000490000004a0000004b0000004c0000004d0000004e0000004f00000050000000510000005200000053000000540000005500000056000000570000005800000059000000480000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000300000000000000000000000000000000000000000000000000000000000000000000000105000100000010000000fe000000020000001300000014000000010500020000000f000000fe00000013000000fe000000020000001500000016000000070100000000000000000001000000000000000000000000000000000000000000000000000000000000000000000115000000000000000000000000000000000000000000000000000000000000000000000001000000010003000000170000001800000019000000960100009981a34a4d509103a454726170a453746f7081a34d6f769281a85265676973746572cd029c81a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333081a64f7261636c6595ad676574436f6d6d69746d656e749181b052656769737465724d656d496e64657881a85265676973746572cd0295909181a541727261799281a8436f6e7374616e74d94030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303330039081a34d6f769281a85265676973746572cd029c81a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333081a34d6f769281a852656769737465720081a85265676973746572cd029ca843616c6c4261636b81a9426f6f7473747261709191cd0295010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000300000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001a00000000000000000000000000000000000000000000000000000000000000000000000200001a0000001b00000000010000000100000000000000000000000000000000000000000000000000000000000000000000011a0000001b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001c000000000000000000000000000000000000000000000000000000000000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000011a0000001c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001a000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011c00000000000000000000000000000000000000000000000000000000000000000000000105000300000010000000fe00000015000000fe00000018000000fe000000020000001d0000001e00000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001f000000000000000000000000000000000000000000000000000000000000000000000400000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000200000000000000000000000000000000000000000000000000000000000000000000001010500030000001f000000fe00000020000000fe00000011000000fe000000020000002100000022000000070000000001000000000023000000740000009781a34a4d509103a454726170a453746f7081a64f7261636c6595ae67657452616e646f6d4669656c6490909181ad5265676973746572496e646578cd03649081a34d6f769281a852656769737465720081a85265676973746572cd0364a843616c6c4261636b81a9426f6f7473747261709190010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000024000000000000000000000000000000000000000000000000000000000000000000000200000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002500000000000000000000000000000000000000000000000000000000000000000000030105000700000024000000fe00000020000000fe00000025000000fe00000011000000fe00000012000000fe00000023000000fe0000000f000000fe00000002000000260000002700000007090000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012500000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012300000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010f000000000000000000000000000000000000000000000000000000000000000000000001000000000028000000a90100009781a34a4d509103a454726170a453746f7081a64f7261636c6595b16e6f74696679437265617465644e6f74659981b052656769737465724d656d496e64657881a85265676973746572cd03e781b052656769737465724d656d496e64657881a85265676973746572cd03e881b052656769737465724d656d496e64657881a85265676973746572cd03e981b052656769737465724d656d496e64657881a85265676973746572cd03ea81b052656769737465724d656d496e64657881a85265676973746572cd03eb81b052656769737465724d656d496e64657881a85265676973746572cd03ec81b052656769737465724d656d496e64657881a85265676973746572cd03ed81b052656769737465724d656d496e64657881a85265676973746572cd03ee81b052656769737465724d656d496e64657881a85265676973746572cd03ef909181ad5265676973746572496e646578cd03fb9081a34d6f769281a852656769737465720081a85265676973746572cd03fba843616c6c4261636b81a9426f6f7473747261709199cd03e7cd03e8cd03e9cd03eacd03ebcd03eccd03edcd03eecd03ef010000000000000000000000000000000000000000000000000000000000000000000000000000000102000028000000290000000001000000010000000000000000000000000000000000000000000000000000000000000000000001280000002900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002a00000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001280000002a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000028000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012a0000000000000000000000000000000000000000000000000000000000000000000000070a0000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010600000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012500000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012300000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010f00000000000000000000000000000000000000000000000000000000000000000000000100000000002b000000ca0100009781a34a4d509103a454726170a453746f7081a64f7261636c6595b0656d6974456e637279707465644c6f679a81b052656769737465724d656d496e64657881a85265676973746572cd04a281b052656769737465724d656d496e64657881a85265676973746572cd04a381b052656769737465724d656d496e64657881a85265676973746572cd04a481b052656769737465724d656d496e64657881a85265676973746572cd04a581b052656769737465724d656d496e64657881a85265676973746572cd04a681b052656769737465724d656d496e64657881a85265676973746572cd04a781b052656769737465724d656d496e64657881a85265676973746572cd04a881b052656769737465724d656d496e64657881a85265676973746572cd04a981b052656769737465724d656d496e64657881a85265676973746572cd04aa81b052656769737465724d656d496e64657881a85265676973746572cd04ab909181ad5265676973746572496e646578cd04b89081a34d6f769281a852656769737465720081a85265676973746572cd04b8a843616c6c4261636b81a9426f6f747374726170919acd04a2cd04a3cd04a4cd04a5cd04a6cd04a7cd04a8cd04a9cd04aacd04ab01000000000000000000000000000000000000000000000000000000000000000000000000000000010200002b0000002c00000000010000000100000000000000000000000000000000000000000000000000000000000000000000012b0000002c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002d000000000000000000000000000000000000000000000000000000000000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000012b0000002d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012d000000000000000000000000000000000000000000000000000000000000000000000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002e0000000000000000000000000000000000000000000000000000000000000000000000010500080000000f000000fe00000010000000fe00000011000000fe00000012000000fe0000002e000000fe0000002e000000fe0000002e000000fe0000002e000000fe000000020000002f0000003000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000031000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000032000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000033000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000034000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000035000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000036000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000037000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000038000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000039000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000041000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000042000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000043000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000044000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000045000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000046000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000047000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000048000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000049000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000051000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000052000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000053000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000054000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000055000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000056000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000057000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010800000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000058000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000590000000000000000000000000000000000000000000000000000000000000000000000", "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" }, { From 902fc7266ed75c8d3a7c9da97313cf50ac0d9f0c Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 13 Jun 2023 11:34:19 +0000 Subject: [PATCH 06/13] feat: e2e consume public commitment test --- .../src/e2e_cross_chain_messaging.test.ts | 2 +- .../e2e_public_to_private_messaging.test.ts | 85 +++++++++++++++++++ .../src/balance_utils.nr | 38 +++++++++ .../public_private_contract/src/main.nr | 12 ++- .../src/examples/public_private_contract.json | 34 ++++++++ .../src/sequencer/public_processor.test.ts | 4 + 6 files changed, 173 insertions(+), 2 deletions(-) create mode 100644 yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts create mode 100644 yarn-project/noir-contracts/src/contracts/public_private_contract/src/balance_utils.nr diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts index 1cf363078de5..67dc589f81be 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts @@ -70,7 +70,7 @@ describe('e2e_cross_chain_messaging', () => { tokenPortalAddress = contracts.tokenPortalAddress; await expectBalance(accounts[0], initialBalance); logger('Successfully deployed contracts and initialized portal'); - }, 40_000); + }, 60_000); afterEach(async () => { await aztecNode?.stop(); diff --git a/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts new file mode 100644 index 000000000000..c95788e0974b --- /dev/null +++ b/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts @@ -0,0 +1,85 @@ + +import { AztecNodeService } from '@aztec/aztec-node'; +import { AztecAddress, AztecRPCServer, Contract, ContractDeployer, Fr, TxStatus } from '@aztec/aztec.js'; +import { PublicToPrivateContractAbi } from '@aztec/noir-contracts/examples'; + +import { DebugLogger } from '@aztec/foundation/log'; +import { pointToPublicKey, setup } from './utils.js'; +import { pedersenCompressInputs } from '@aztec/circuits.js/barretenberg'; +import { CircuitsWasm } from '@aztec/circuits.js'; + +describe('e2e_public_to_private_messaging', () => { + let aztecNode: AztecNodeService; + let aztecRpcServer: AztecRPCServer; + let accounts: AztecAddress[]; + let logger: DebugLogger; + + let contract: Contract; + + beforeEach(async () => { + ({ aztecNode, aztecRpcServer, accounts, logger } = await setup(2)); + }, 60_000); + + afterEach(async () => { + await aztecNode?.stop(); + await aztecRpcServer?.stop(); + }); + + const expectBalance = async (owner: AztecAddress, expectedBalance: bigint) => { + const ownerPublicKey = await aztecRpcServer.getAccountPublicKey(owner); + const [balance] = await contract.methods.getBalance(pointToPublicKey(ownerPublicKey)).view({ from: owner }); + logger(`Account ${owner} balance: ${balance}`); + expect(balance).toBe(expectedBalance); + }; + + const deployContract = async () => { + logger(`Deploying Public to Private L2 contract...`); + const deployer = new ContractDeployer(PublicToPrivateContractAbi, aztecRpcServer); + const tx = deployer.deploy().send(); + const receipt = await tx.getReceipt(); + contract = new Contract(receipt.contractAddress!, PublicToPrivateContractAbi, aztecRpcServer); + await tx.isMined(0, 0.1); + await tx.getReceipt(); + logger('L2 contract deployed'); + return contract; + }; + + /** + * Milestone 5.4: Intra-contract Public -\> Private calls. + */ + it('5.4: Should be able to create a commitment in a public function and spend in a private function', async () => { + const mintAmount = 100n; + + const [owner, receiver] = accounts; + + const deployedContract = await deployContract(); + + // Create a secret for the transparent message + // TODO(Maddiaa): replace this with the other secret calculation cbind. + const wasm = await CircuitsWasm.get(); + const secret = Fr.random(); + const secretHash = pedersenCompressInputs(wasm, [secret.toBuffer()]); + + // Create the commitment to be spent in the private domain + const publicTx = deployedContract.methods + .mintFromPublicToPrivate(mintAmount, secretHash) + .send({ from: receiver }); + + await publicTx.isMined(0, 0.1); + const publicReceipt = await publicTx.getReceipt(); + + expect(publicReceipt.status).toBe(TxStatus.MINED); + + // Create the transaction spending the commitment + const privateTx = deployedContract.methods + .mintFromPublicMessage(mintAmount, secret, pointToPublicKey(await aztecRpcServer.getAccountPublicKey(owner))) + .send({ from: owner }); + + await privateTx.isMined() + const privateReceipt = await privateTx.getReceipt(); + + expect(privateReceipt.status).toBe(TxStatus.MINED); + await expectBalance(owner, mintAmount); + }, 60_000); + +}); diff --git a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/balance_utils.nr b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/balance_utils.nr new file mode 100644 index 000000000000..58d6c4454268 --- /dev/null +++ b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/balance_utils.nr @@ -0,0 +1,38 @@ +use dep::aztec3::notes::value_note::Note; +use dep::aztec3::notes::value_note::NOTE_LEN; +use dep::aztec3::types::point::Point; +use dep::aztec3::utils::arr_copy_slice; + +use dep::aztec3::oracle::notes::view_notes_page_internal; +use dep::aztec3::oracle::notes::NOTES_PER_PAGE; + +fn view_notes_page( + storage_slot: Field, + offset: Field, +) -> (Field, [Note; NOTES_PER_PAGE]){ + let fields = view_notes_page_internal(storage_slot, offset); + let total_notes = fields[0]; + let mut notes = [Note::dummy(); NOTES_PER_PAGE]; + for i in 0..NOTES_PER_PAGE { + let read_offset: comptime Field = 1 + i*NOTE_LEN; + let note = Note::deserialize(arr_copy_slice(fields, [0; NOTE_LEN], read_offset)); + notes[i] = note; + }; + (total_notes, notes) +} + + +// TODO(1.5) We don't support yet more than one page of notes +// noir is having issues with loop handling in unconstrained functions +// rewrite to unconstrained and integrate into noir-aztec3 when fixed +fn get_balance(storage_slot: Field) -> Field { + let mut balance = 0; + + let mut current_batch = view_notes_page(storage_slot, 0).1; + + for j in 0..current_batch.len() { + balance += current_batch[j].value; + } + + balance +} \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr index 295a2b406795..40c0450ba8f8 100644 --- a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr @@ -1,6 +1,8 @@ use dep::std::hash::pedersen; contract PublicPrivate { + mod balance_utils; + use dep::aztec3::abi::PrivateContextInputs; use dep::aztec3::context::PrivateFunctionContext; use dep::aztec3::abi::PublicContextInputs; @@ -25,7 +27,6 @@ contract PublicPrivate { use dep::aztec3::oracle::create_l2_to_l1_message::create_l2_to_l1_message; use dep::aztec3::oracle::get_commitment::get_commitment; - global balances = Map { storage_slot: 1 }; fn constructor( @@ -102,6 +103,15 @@ contract PublicPrivate { context.finish(inputs) } + /// ABI getBalance type "unconstrained" + fn getBalance( + owner: Point, + _padding: [Field; dep::aztec3::abi::MAX_ARGS - 2] + ) -> pub Field { + let owner_balance = balances.at(owner.x); + + balance_utils::get_balance(owner_balance.storage_slot) + } } diff --git a/yarn-project/noir-contracts/src/examples/public_private_contract.json b/yarn-project/noir-contracts/src/examples/public_private_contract.json index 9114e0c74959..3bd4a472e4a9 100644 --- a/yarn-project/noir-contracts/src/examples/public_private_contract.json +++ b/yarn-project/noir-contracts/src/examples/public_private_contract.json @@ -36,6 +36,40 @@ "bytecode": "0000000016000000000000000100000015000000070000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000030000000000000000000000000000000000000000000000000000000000000000000000010500020000000b000000fe0000000c000000fe000000020000001200000013000000070100000000000000000001000000000000000000000000000000000000000000000000000000000000000000000112000000000000000000000000000000000000000000000000000000000000000000000000000000050100009881a34a4d509103a454726170a453746f7081a64f7261636c6595b36372656174654c32546f4c314d6573736167659181b052656769737465724d656d496e64657881a8526567697374657237909181ad5265676973746572496e6465783b9081a842696e6172794f709581a8556e7369676e6564910181a3436d70a2457181a852656769737465723b81a8436f6e7374616e74d940303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303e81a84a4d5049464e4f549281a852656769737465723e01a843616c6c4261636b81a9426f6f747374726170919137010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000150000000000000000000000000000000000000000000000000000000000000000000000", "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" }, + { + "name": "getBalance", + "functionType": "unconstrained", + "parameters": [ + { + "name": "owner", + "type": { + "kind": "struct", + "fields": [ + { + "name": "x", + "type": { + "kind": "field" + } + }, + { + "name": "y", + "type": { + "kind": "field" + } + } + ] + }, + "visibility": "private" + } + ], + "returnTypes": [ + { + "kind": "field" + } + ], + "bytecode": "000000007c0000000000000001000000730000005400000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000009000000000000000000000000000000000000000000000000000000000000000000000400000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000a00000000000000000000000000000000000000000000000000000000000000000000010105000300000009000000fe0000000a000000fe00000001000000fe000000020000000b0000000c00000007020000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001003d0000000d0000000e0000000f000000100000001100000012000000130000001400000015000000160000001700000018000000190000001a0000001b0000001c0000001d0000001e0000001f000000200000002100000022000000230000002400000025000000260000002700000028000000290000002a0000002b0000002c0000002d0000002e0000002f000000300000003100000032000000330000003400000035000000360000003700000038000000390000003a0000003b0000003c0000003d0000003e0000003f00000040000000410000004200000043000000440000004500000046000000470000004800000049000000080200009981a34a4d509103a454726170a453746f7081a34d6f769281a852656769737465725d81a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303381a64f7261636c6595ad766965774e6f746573506167659381b052656769737465724d656d496e64657881a852656769737465725281b052656769737465724d656d496e64657881a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030306181b052656769737465724d656d496e64657881a8526567697374657253909181a541727261799281a8436f6e7374616e74d940303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333d9081a34d6f769281a852656769737465725d81a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303381a34d6f769281a852656769737465720081a852656769737465725da843616c6c4261636b81a9426f6f747374726170919252530100000000000000000000000000000000000000000000000000000000000000000000000000000001020100000000000100000000000000000000000000000000000000000000000000000000000000000000010e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024b0000004a0000000000010000000100000000000000000000000000000000000000000000000000000000000000000000014a0000004a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004a0000000000000000000000000000000000000000000000000000000000000000000000020100000000000100000000000000000000000000000000000000000000000000000000000000000000014b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000004d0000004c00000000010b00010000004c000000fc0000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000014d0000004d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004d000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004b00000000000000000000000000000000000000000000000000000000000000000000014c00000010000000000000000000000000000000000000000000000000000000000000004d000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000e00000000000000000000000000000000000000000000000000000000000000000000014a00000000000000000000000000000000000000000000000000000000000000000000024b000000000000000000000000000000000000000000000000000000000000000000000002010000000000010000000000000000000000000000000000000000000000000000000000000000000001140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f0000004e0000000000010000000100000000000000000000000000000000000000000000000000000000000000000000014e0000004e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004e0000000000000000000000000000000000000000000000000000000000000000000000020100000000000100000000000000000000000000000000000000000000000000000000000000000000014f000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000510000005000000000010b000100000050000000fc000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001510000005100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000051000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004f000000000000000000000000000000000000000000000000000000000000000000000150000000100000000000000000000000000000000000000000000000000000000000000051000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001400000000000000000000000000000000000000000000000000000000000000000000014e00000000000000000000000000000000000000000000000000000000000000000000024f0000000000000000000000000000000000000000000000000000000000000000000000020100000000000100000000000000000000000000000000000000000000000000000000000000000000011a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025300000052000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001520000005200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005200000000000000000000000000000000000000000000000000000000000000000000000201000000000001000000000000000000000000000000000000000000000000000000000000000000000153000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000550000005400000000010b000100000054000000fc000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001550000005500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000055000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000053000000000000000000000000000000000000000000000000000000000000000000000154000000100000000000000000000000000000000000000000000000000000000000000055000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001a000000000000000000000000000000000000000000000000000000000000000000000152000000000000000000000000000000000000000000000000000000000000000000000253000000000000000000000000000000000000000000000000000000000000000000000002010000000000010000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025700000056000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001560000005600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005600000000000000000000000000000000000000000000000000000000000000000000000201000000000001000000000000000000000000000000000000000000000000000000000000000000000157000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000590000005800000000010b000100000058000000fc000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001590000005900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000059000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000057000000000000000000000000000000000000000000000000000000000000000000000158000000100000000000000000000000000000000000000000000000000000000000000059000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000020000000000000000000000000000000000000000000000000000000000000000000000156000000000000000000000000000000000000000000000000000000000000000000000257000000000000000000000000000000000000000000000000000000000000000000000002010000000000010000000000000000000000000000000000000000000000000000000000000000000001260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025b0000005a0000000000010000000100000000000000000000000000000000000000000000000000000000000000000000015a0000005a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005a0000000000000000000000000000000000000000000000000000000000000000000000020100000000000100000000000000000000000000000000000000000000000000000000000000000000015b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000005d0000005c00000000010b00010000005c000000fc0000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000015d0000005d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005d000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005b00000000000000000000000000000000000000000000000000000000000000000000015c00000010000000000000000000000000000000000000000000000000000000000000005d000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002600000000000000000000000000000000000000000000000000000000000000000000015a00000000000000000000000000000000000000000000000000000000000000000000025b0000000000000000000000000000000000000000000000000000000000000000000000020100000000000100000000000000000000000000000000000000000000000000000000000000000000012c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025f0000005e0000000000010000000100000000000000000000000000000000000000000000000000000000000000000000015e0000005e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005e0000000000000000000000000000000000000000000000000000000000000000000000020100000000000100000000000000000000000000000000000000000000000000000000000000000000015f000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000610000006000000000010b000100000060000000fc000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001610000006100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000061000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005f000000000000000000000000000000000000000000000000000000000000000000000160000000100000000000000000000000000000000000000000000000000000000000000061000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002c00000000000000000000000000000000000000000000000000000000000000000000015e00000000000000000000000000000000000000000000000000000000000000000000025f000000000000000000000000000000000000000000000000000000000000000000000002010000000000010000000000000000000000000000000000000000000000000000000000000000000001320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000026300000062000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001620000006200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006200000000000000000000000000000000000000000000000000000000000000000000000201000000000001000000000000000000000000000000000000000000000000000000000000000000000163000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000650000006400000000010b000100000064000000fc000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001650000006500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000065000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000063000000000000000000000000000000000000000000000000000000000000000000000164000000100000000000000000000000000000000000000000000000000000000000000065000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000032000000000000000000000000000000000000000000000000000000000000000000000162000000000000000000000000000000000000000000000000000000000000000000000263000000000000000000000000000000000000000000000000000000000000000000000002010000000000010000000000000000000000000000000000000000000000000000000000000000000001380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000026700000066000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001660000006600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006600000000000000000000000000000000000000000000000000000000000000000000000201000000000001000000000000000000000000000000000000000000000000000000000000000000000167000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000690000006800000000010b000100000068000000fc000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001690000006900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000069000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000067000000000000000000000000000000000000000000000000000000000000000000000168000000100000000000000000000000000000000000000000000000000000000000000069000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000380000000000000000000000000000000000000000000000000000000000000000000001660000000000000000000000000000000000000000000000000000000000000000000002670000000000000000000000000000000000000000000000000000000000000000000000020100000000000100000000000000000000000000000000000000000000000000000000000000000000013e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000026b0000006a0000000000010000000100000000000000000000000000000000000000000000000000000000000000000000016a0000006a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006a0000000000000000000000000000000000000000000000000000000000000000000000020100000000000100000000000000000000000000000000000000000000000000000000000000000000016b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000006d0000006c00000000010b00010000006c000000fc0000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000016d0000006d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006d000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006b00000000000000000000000000000000000000000000000000000000000000000000016c00000010000000000000000000000000000000000000000000000000000000000000006d000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003e00000000000000000000000000000000000000000000000000000000000000000000016a00000000000000000000000000000000000000000000000000000000000000000000026b000000000000000000000000000000000000000000000000000000000000000000000002010000000000010000000000000000000000000000000000000000000000000000000000000000000001440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000026f0000006e0000000000010000000100000000000000000000000000000000000000000000000000000000000000000000016e0000006e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006e0000000000000000000000000000000000000000000000000000000000000000000000020100000000000100000000000000000000000000000000000000000000000000000000000000000000016f000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000710000007000000000010b000100000070000000fc000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001710000007100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000071000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006f000000000000000000000000000000000000000000000000000000000000000000000170000000100000000000000000000000000000000000000000000000000000000000000071000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004400000000000000000000000000000000000000000000000000000000000000000000016e00000000000000000000000000000000000000000000000000000000000000000000026f000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000014900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000007200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000075000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000013d00000000000000000000000000000000000000000000000000000000000000000000014300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000076000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000000000013700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000077000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000012500000000000000000000000000000000000000000000000000000000000000000000012b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000078000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000017700000000000000000000000000000000000000000000000000000000000000000000017800000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000079000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000017500000000000000000000000000000000000000000000000000000000000000000000017600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000007a000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000017900000000000000000000000000000000000000000000000000000000000000000000017a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000007b000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000011300000000000000000000000000000000000000000000000000000000000000000000011900000000000000000000000000000000000000000000000000000000000000000000017c000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000011f00000000000000000000000000000000000000000000000000000000000000000000017b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000007c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000017200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000730000000000000000000000000000000000000000000000000000000000000000000000", + "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" + }, { "name": "mintFromPublicMessage", "functionType": "secret", diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts index 46b4b33f9f4e..942af1783fe1 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts @@ -275,6 +275,8 @@ function makePublicExecutionResultFromRequest(item: PublicCallRequest): PublicEx execution: item, nestedExecutions: [], returnValues: [new Fr(1n)], + newCommitments: [], + newL2ToL1Messages: [], contractStorageReads: [], contractStorageUpdateRequests: [], }; @@ -295,6 +297,8 @@ function makePublicExecutionResult( execution, nestedExecutions, returnValues: [], + newCommitments: [], + newL2ToL1Messages: [], contractStorageReads: [], contractStorageUpdateRequests: [], }; From cccbf0a8c12ee911f27d040c86235f5db088c837 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 13 Jun 2023 11:36:08 +0000 Subject: [PATCH 07/13] chore(ci): add to circle ci --- .circleci/config.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8eed9134807b..70a21586cd49 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -429,6 +429,17 @@ jobs: name: "Test" command: cond_spot_run_tests end-to-end e2e_cross_chain_messaging.test.ts + e2e-public-to-private-messaging: + docker: + - image: aztecprotocol/alpine-build-image + resource_class: small + steps: + - *checkout + - *setup_env + - run: + name: "Test" + command: cond_spot_run_tests end-to-end e2e_public_to_private_messaging.test.ts + e2e-account-contract: docker: - image: aztecprotocol/alpine-build-image @@ -610,6 +621,7 @@ workflows: - e2e-nested-contract: *e2e_test - e2e-public-token-contract: *e2e_test - e2e-cross-chain-messaging: *e2e_test + - e2e-public-to-private-messaging: *e2e_test - e2e-account-contract: *e2e_test - integration-l1-publisher: *e2e_test - integration-archiver-l1-to-l2: *e2e_test @@ -623,6 +635,7 @@ workflows: - e2e-nested-contract - e2e-public-token-contract - e2e-cross-chain-messaging + - e2e-public-to-private-messaging - e2e-account-contract - integration-l1-publisher - integration-archiver-l1-to-l2 From b0741d38d3686a268742d3a325ffb37c6aa44256 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 13 Jun 2023 11:37:54 +0000 Subject: [PATCH 08/13] chore: fmt fix: fmt --- .../src/client/client_execution_context.ts | 2 +- .../acir-simulator/src/client/private_execution.ts | 2 +- .../src/client/unconstrained_execution.ts | 4 +++- .../src/e2e_public_to_private_messaging.test.ts | 10 +++------- yarn-project/noir-contracts/src/examples/index.ts | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/yarn-project/acir-simulator/src/client/client_execution_context.ts b/yarn-project/acir-simulator/src/client/client_execution_context.ts index 2ae7f73fa395..12f2dbea10c7 100644 --- a/yarn-project/acir-simulator/src/client/client_execution_context.ts +++ b/yarn-project/acir-simulator/src/client/client_execution_context.ts @@ -105,7 +105,7 @@ export class ClientTxExecutionContext { * @param commitment - The commitment. * @returns The commitment data. */ - public async getCommitment(contractAddress: AztecAddress, commitment: Fr){ + public async getCommitment(contractAddress: AztecAddress, commitment: Fr) { const commitmentInputs = await this.db.getCommitmentOracle(contractAddress, commitment); return { acvmData: toAcvmCommitmentLoadOracleInputs(commitmentInputs, this.historicRoots.privateDataTreeRoot), diff --git a/yarn-project/acir-simulator/src/client/private_execution.ts b/yarn-project/acir-simulator/src/client/private_execution.ts index ff89a6b75289..7be6a42428cd 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.ts @@ -198,7 +198,7 @@ export class PrivateFunctionExecution { return this.context.getL1ToL2Message(fromACVMField(msgKey)); }, getCommitment: async ([commitment]: ACVMField[]) => { - const commitmentData = await this.context.getCommitment(this.contractAddress, fromACVMField(commitment)); + const commitmentData = await this.context.getCommitment(this.contractAddress, fromACVMField(commitment)); readRequestCommitmentIndices.push(commitmentData.index); return commitmentData.acvmData; }, diff --git a/yarn-project/acir-simulator/src/client/unconstrained_execution.ts b/yarn-project/acir-simulator/src/client/unconstrained_execution.ts index 19a338bfd05a..d68691701e5b 100644 --- a/yarn-project/acir-simulator/src/client/unconstrained_execution.ts +++ b/yarn-project/acir-simulator/src/client/unconstrained_execution.ts @@ -65,7 +65,9 @@ export class UnconstrainedFunctionExecution { }, getL1ToL2Message: ([msgKey]: ACVMField[]) => this.context.getL1ToL2Message(fromACVMField(msgKey)), getCommitment: ([commitment]: ACVMField[]) => - this.context.getCommitment(this.contractAddress, fromACVMField(commitment)).then(commitmentData => commitmentData.acvmData), + this.context + .getCommitment(this.contractAddress, fromACVMField(commitment)) + .then(commitmentData => commitmentData.acvmData), enqueuePublicFunctionCall: notAvailable, notifyCreatedNote: notAvailable, notifyNullifiedNote: notAvailable, diff --git a/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts index c95788e0974b..4bb59040f91c 100644 --- a/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts @@ -1,4 +1,3 @@ - import { AztecNodeService } from '@aztec/aztec-node'; import { AztecAddress, AztecRPCServer, Contract, ContractDeployer, Fr, TxStatus } from '@aztec/aztec.js'; import { PublicToPrivateContractAbi } from '@aztec/noir-contracts/examples'; @@ -61,9 +60,7 @@ describe('e2e_public_to_private_messaging', () => { const secretHash = pedersenCompressInputs(wasm, [secret.toBuffer()]); // Create the commitment to be spent in the private domain - const publicTx = deployedContract.methods - .mintFromPublicToPrivate(mintAmount, secretHash) - .send({ from: receiver }); + const publicTx = deployedContract.methods.mintFromPublicToPrivate(mintAmount, secretHash).send({ from: receiver }); await publicTx.isMined(0, 0.1); const publicReceipt = await publicTx.getReceipt(); @@ -74,12 +71,11 @@ describe('e2e_public_to_private_messaging', () => { const privateTx = deployedContract.methods .mintFromPublicMessage(mintAmount, secret, pointToPublicKey(await aztecRpcServer.getAccountPublicKey(owner))) .send({ from: owner }); - - await privateTx.isMined() + + await privateTx.isMined(); const privateReceipt = await privateTx.getReceipt(); expect(privateReceipt.status).toBe(TxStatus.MINED); await expectBalance(owner, mintAmount); }, 60_000); - }); diff --git a/yarn-project/noir-contracts/src/examples/index.ts b/yarn-project/noir-contracts/src/examples/index.ts index 2dab4182e33a..b8ac0f11bd88 100644 --- a/yarn-project/noir-contracts/src/examples/index.ts +++ b/yarn-project/noir-contracts/src/examples/index.ts @@ -4,7 +4,7 @@ import ZkTokenContractJson from './zk_token_contract.json' assert { type: 'json' import ParentJson from './parent_contract.json' assert { type: 'json' }; import ChildJson from './child_contract.json' assert { type: 'json' }; import PublicTokenContractJson from './public_token_contract.json' assert { type: 'json' }; -import PublicToPrivateContractJson from "./public_private_contract.json" assert { type: "json" } +import PublicToPrivateContractJson from './public_private_contract.json' assert { type: 'json' }; import { ContractAbi } from '@aztec/foundation/abi' assert { type: 'json' }; import NonNativeTokenContractJson from './non_native_token_contract.json' assert { type: 'json' }; import AccountContractJson from './account_contract.json' assert { type: 'json' }; From 366a76154ee026d609b9e55c12de490e0d6363d0 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 13 Jun 2023 14:38:20 +0000 Subject: [PATCH 09/13] fix: tidy up noir syntax --- .../acir-simulator/src/public/index.test.ts | 9 +-- .../e2e_public_to_private_messaging.test.ts | 11 ++- .../src/contracts/noir-aztec3/src/lib.nr | 2 +- .../src/messaging/l1_to_l2_message.nr | 2 +- .../public_private_contract/src/main.nr | 63 ++-------------- .../src/transparent_note.nr | 72 +++++++++++++++++++ .../src/examples/public_private_contract.json | 2 +- 7 files changed, 91 insertions(+), 70 deletions(-) create mode 100644 yarn-project/noir-contracts/src/contracts/public_private_contract/src/transparent_note.nr diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index d13bbb9d8473..5124228fb6cd 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -231,12 +231,14 @@ describe('ACIR public execution simulator', () => { let functionData: FunctionData; let amount: Fr; let params: Fr[]; + let wasm: CircuitsWasm; - beforeEach(() => { + beforeEach(async () => { contractAddress = AztecAddress.random(); functionData = new FunctionData(Buffer.alloc(4), false, false); amount = new Fr(140); params = [amount, Fr.random()]; + wasm = await CircuitsWasm.get(); }); it('Should be able to create a commitment from the public context', async () => { @@ -261,14 +263,13 @@ describe('ACIR public execution simulator', () => { expect(result.newCommitments.length).toEqual(1); const expectedNewCommitmentValue = pedersenCompressInputs( - await CircuitsWasm.get(), + wasm, params.map(a => a.toBuffer()), ); expect(result.newCommitments[0].toBuffer()).toEqual(expectedNewCommitmentValue); }); it('Should be able to create a L2 to L1 message from the public context', async () => { - const contractAddress = AztecAddress.random(); const createL2ToL1MessagePublicAbi = PublicToPrivateContractAbi.functions.find( f => f.name === 'createL2ToL1MessagePublic', )!; @@ -292,7 +293,7 @@ describe('ACIR public execution simulator', () => { expect(result.newL2ToL1Messages.length).toEqual(1); const expectedNewMessageValue = pedersenCompressInputs( - await CircuitsWasm.get(), + wasm, params.map(a => a.toBuffer()), ); expect(result.newL2ToL1Messages[0].toBuffer()).toEqual(expectedNewMessageValue); diff --git a/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts index 4bb59040f91c..978467921984 100644 --- a/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts @@ -1,11 +1,8 @@ import { AztecNodeService } from '@aztec/aztec-node'; -import { AztecAddress, AztecRPCServer, Contract, ContractDeployer, Fr, TxStatus } from '@aztec/aztec.js'; +import { AztecAddress, AztecRPCServer, Contract, ContractDeployer, Fr, TxStatus, computeMessageSecretHash } from '@aztec/aztec.js'; import { PublicToPrivateContractAbi } from '@aztec/noir-contracts/examples'; - import { DebugLogger } from '@aztec/foundation/log'; import { pointToPublicKey, setup } from './utils.js'; -import { pedersenCompressInputs } from '@aztec/circuits.js/barretenberg'; -import { CircuitsWasm } from '@aztec/circuits.js'; describe('e2e_public_to_private_messaging', () => { let aztecNode: AztecNodeService; @@ -54,12 +51,11 @@ describe('e2e_public_to_private_messaging', () => { const deployedContract = await deployContract(); // Create a secret for the transparent message - // TODO(Maddiaa): replace this with the other secret calculation cbind. - const wasm = await CircuitsWasm.get(); const secret = Fr.random(); - const secretHash = pedersenCompressInputs(wasm, [secret.toBuffer()]); + const secretHash = await computeMessageSecretHash(secret); // Create the commitment to be spent in the private domain + logger("Creating commitment in public call"); const publicTx = deployedContract.methods.mintFromPublicToPrivate(mintAmount, secretHash).send({ from: receiver }); await publicTx.isMined(0, 0.1); @@ -68,6 +64,7 @@ describe('e2e_public_to_private_messaging', () => { expect(publicReceipt.status).toBe(TxStatus.MINED); // Create the transaction spending the commitment + logger("Spending commitment in private call"); const privateTx = deployedContract.methods .mintFromPublicMessage(mintAmount, secret, pointToPublicKey(await aztecRpcServer.getAccountPublicKey(owner))) .send({ from: owner }); diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/lib.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/lib.nr index b0de588a4b0e..4700d281bd1d 100644 --- a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/lib.nr +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/lib.nr @@ -14,7 +14,7 @@ global NoteHash = 2; global NoteStorageSlot = 3; global MappingStorageSlot = 4; global Nullifier = 5; -global L1ToL2MessageSecret = 29; +global MessageSecret = 29; global PRIVATE_DATA_TREE_HEIGHT: comptime Field = 8; global L1_TO_L2_MESSAGES_TREE_HEIGHT: comptime Field = 8; diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/l1_to_l2_message.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/l1_to_l2_message.nr index 966c9562546c..1abd42faeb89 100644 --- a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/l1_to_l2_message.nr +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/l1_to_l2_message.nr @@ -57,7 +57,7 @@ impl L1ToL2Message { } fn validate_message_secret(self: Self) { - let recomputed_hash = dep::std::hash::pedersen([crate::L1ToL2MessageSecret, self.secret])[0]; + let recomputed_hash = dep::std::hash::pedersen([crate::MessageSecret, self.secret])[0]; constrain self.secret_hash == recomputed_hash; } diff --git a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr index 40c0450ba8f8..30e5314415e1 100644 --- a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr @@ -2,9 +2,12 @@ use dep::std::hash::pedersen; contract PublicPrivate { mod balance_utils; + mod transparent_note; + + use transparent_note::TransparentNote; - use dep::aztec3::abi::PrivateContextInputs; use dep::aztec3::context::PrivateFunctionContext; + use dep::aztec3::abi::PrivateContextInputs; use dep::aztec3::abi::PublicContextInputs; // Public state @@ -17,10 +20,6 @@ contract PublicPrivate { use dep::aztec3::state_vars::set::Set; use dep::aztec3::notes::value_note::Note; - use dep::aztec3::messaging::get_commitment_getter_data::make_commitment_getter_data; - - use crate::TransparentNote; - // oracles use dep::aztec3::oracle::logs::emit_encrypted_log; use dep::aztec3::oracle::create_commitment::create_commitment; @@ -76,21 +75,9 @@ contract PublicPrivate { let mut context = PrivateFunctionContext::new(); context.args = context.args.push_array([amount, secret, owner.x, owner.y]); - let from_public_note = TransparentNote::new_from_secret(amount, secret); - - let commitment = from_public_note.get_commitment(); - - // Perform read request for the kernel. - context = context.push_read_request(commitment); - - let commitment_oracle_call = get_commitment(commitment); - let commitment_data = make_commitment_getter_data(commitment_oracle_call, 0); - - - constrain inputs.roots.private_data_tree_root == commitment_data.root; - - let nullifier = TransparentNote::compute_nullifier(secret, commitment, commitment_data.leaf_index); - context = context.push_new_nullifier(nullifier); + // Assert that the note exists within the tree + let public_note = TransparentNote::new_from_secret(amount, secret); + context = public_note.consume_in_private(context, inputs.roots.private_data_tree_root, secret); // Mint the tokens let owner_balance = balances.at(owner.x); @@ -113,39 +100,3 @@ contract PublicPrivate { balance_utils::get_balance(owner_balance.storage_slot) } } - - -struct TransparentNote { - amount: Field, - secretHash: Field, -} - -impl TransparentNote { - fn new(amount: Field, secretHash: Field) -> Self { - Self { amount, secretHash } - } - - fn new_from_secret(amount: Field, secret: Field) -> Self { - let secretHash = pedersen([secret])[0]; - TransparentNote { - amount, - secretHash, - } - } - - fn get_commitment(self) -> Field { - pedersen([self.amount, self.secretHash])[0] - } - - fn knows_secret(self, secret: Field) { - let hash = pedersen([secret])[0]; - constrain self.secretHash == hash; - } - - fn compute_nullifier(secret: Field, siloed_commitment: Field, index: Field) -> Field { - // Create a nullifier for the message based on its index in the tree - - pedersen([secret, siloed_commitment, index])[0] - } - -} \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/transparent_note.nr b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/transparent_note.nr new file mode 100644 index 000000000000..ebff1b94b71c --- /dev/null +++ b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/transparent_note.nr @@ -0,0 +1,72 @@ +use dep::std::hash::pedersen; + +// Must repeat imports so they work in both scopes ( is this a bug ?) +use dep::aztec3::context::PrivateFunctionContext; +use dep::aztec3::messaging::get_commitment_getter_data::make_commitment_getter_data; + +use dep::aztec3::oracle::logs::emit_encrypted_log; +use dep::aztec3::oracle::create_commitment::create_commitment; +use dep::aztec3::oracle::create_l2_to_l1_message::create_l2_to_l1_message; +use dep::aztec3::oracle::get_commitment::get_commitment; + + +// Transparent note represents a note that is created in the clear (public execution), +// but can only be spent by those that know the preimage of the "secretHash" +struct TransparentNote { + amount: Field, + secretHash: Field, +} + +impl TransparentNote { + fn new(amount: Field, secretHash: Field) -> Self { + Self { amount, secretHash } + } + + fn new_from_secret(amount: Field, secret: Field) -> Self { + let secretHash = TransparentNote::compute_secret_hash(secret); + TransparentNote { + amount, + secretHash, + } + } + + // Gets the value of the commitment + // TODO(maddiaa): this will need to be hashed with a slot to keep it unique, which slot to pick? + fn get_commitment(self: Self) -> Field { + pedersen([self.amount, self.secretHash])[0] + } + + fn consume_in_private(self: Self, mut context: PrivateFunctionContext, root: Field, secret: Field) -> PrivateFunctionContext { + // Get the commitment value (before silo) + let commitment = self.get_commitment(); + + // Let the kernel perform the read. + context = context.push_read_request(commitment); + + // Get the commitment data, (where it is in the db) + let commitment_oracle_call = get_commitment(commitment); + let commitment_data = make_commitment_getter_data(commitment_oracle_call, 0); + // Do we still need to do this with read requests? + constrain root == commitment_data.root; + + // Calculate the nullifier + self.emit_nullifier(context, secret, commitment, commitment_data.leaf_index) + } + + fn compute_secret_hash(secret: Field) -> Field { + pedersen([dep::aztec3::MessageSecret, secret])[0] + } + + fn knows_secret(self, secret: Field) { + let hash = TransparentNote::compute_secret_hash(secret); + constrain self.secretHash == hash; + } + + fn emit_nullifier(_self: Self, mut context: PrivateFunctionContext, secret: Field, siloed_commitment: Field, index: Field) -> PrivateFunctionContext { + // Create a nullifier for the message based on its index in the tree + + let nullifier = pedersen([secret, siloed_commitment, index])[0]; + context.push_new_nullifier(nullifier) + } + +} \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/examples/public_private_contract.json b/yarn-project/noir-contracts/src/examples/public_private_contract.json index 3bd4a472e4a9..27280af6813d 100644 --- a/yarn-project/noir-contracts/src/examples/public_private_contract.json +++ b/yarn-project/noir-contracts/src/examples/public_private_contract.json @@ -111,7 +111,7 @@ } ], "returnTypes": [], - "bytecode": "000000005a000000120000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f000000100000001100000012000000290000003100000032000000330000003400000035000000360000003700000038000000390000003a0000003b0000003c0000003d0000003e0000003f000000400000004100000042000000430000004400000045000000460000004700000048000000490000004a0000004b0000004c0000004d0000004e0000004f00000050000000510000005200000053000000540000005500000056000000570000005800000059000000480000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000300000000000000000000000000000000000000000000000000000000000000000000000105000100000010000000fe000000020000001300000014000000010500020000000f000000fe00000013000000fe000000020000001500000016000000070100000000000000000001000000000000000000000000000000000000000000000000000000000000000000000115000000000000000000000000000000000000000000000000000000000000000000000001000000010003000000170000001800000019000000960100009981a34a4d509103a454726170a453746f7081a34d6f769281a85265676973746572cd029c81a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333081a64f7261636c6595ad676574436f6d6d69746d656e749181b052656769737465724d656d496e64657881a85265676973746572cd0295909181a541727261799281a8436f6e7374616e74d94030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303330039081a34d6f769281a85265676973746572cd029c81a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333081a34d6f769281a852656769737465720081a85265676973746572cd029ca843616c6c4261636b81a9426f6f7473747261709191cd0295010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000300000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001a00000000000000000000000000000000000000000000000000000000000000000000000200001a0000001b00000000010000000100000000000000000000000000000000000000000000000000000000000000000000011a0000001b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001c000000000000000000000000000000000000000000000000000000000000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000011a0000001c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001a000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011c00000000000000000000000000000000000000000000000000000000000000000000000105000300000010000000fe00000015000000fe00000018000000fe000000020000001d0000001e00000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001f000000000000000000000000000000000000000000000000000000000000000000000400000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000200000000000000000000000000000000000000000000000000000000000000000000001010500030000001f000000fe00000020000000fe00000011000000fe000000020000002100000022000000070000000001000000000023000000740000009781a34a4d509103a454726170a453746f7081a64f7261636c6595ae67657452616e646f6d4669656c6490909181ad5265676973746572496e646578cd03649081a34d6f769281a852656769737465720081a85265676973746572cd0364a843616c6c4261636b81a9426f6f7473747261709190010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000024000000000000000000000000000000000000000000000000000000000000000000000200000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002500000000000000000000000000000000000000000000000000000000000000000000030105000700000024000000fe00000020000000fe00000025000000fe00000011000000fe00000012000000fe00000023000000fe0000000f000000fe00000002000000260000002700000007090000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012500000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012300000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010f000000000000000000000000000000000000000000000000000000000000000000000001000000000028000000a90100009781a34a4d509103a454726170a453746f7081a64f7261636c6595b16e6f74696679437265617465644e6f74659981b052656769737465724d656d496e64657881a85265676973746572cd03e781b052656769737465724d656d496e64657881a85265676973746572cd03e881b052656769737465724d656d496e64657881a85265676973746572cd03e981b052656769737465724d656d496e64657881a85265676973746572cd03ea81b052656769737465724d656d496e64657881a85265676973746572cd03eb81b052656769737465724d656d496e64657881a85265676973746572cd03ec81b052656769737465724d656d496e64657881a85265676973746572cd03ed81b052656769737465724d656d496e64657881a85265676973746572cd03ee81b052656769737465724d656d496e64657881a85265676973746572cd03ef909181ad5265676973746572496e646578cd03fb9081a34d6f769281a852656769737465720081a85265676973746572cd03fba843616c6c4261636b81a9426f6f7473747261709199cd03e7cd03e8cd03e9cd03eacd03ebcd03eccd03edcd03eecd03ef010000000000000000000000000000000000000000000000000000000000000000000000000000000102000028000000290000000001000000010000000000000000000000000000000000000000000000000000000000000000000001280000002900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002a00000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001280000002a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000028000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012a0000000000000000000000000000000000000000000000000000000000000000000000070a0000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010600000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012500000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012300000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010f00000000000000000000000000000000000000000000000000000000000000000000000100000000002b000000ca0100009781a34a4d509103a454726170a453746f7081a64f7261636c6595b0656d6974456e637279707465644c6f679a81b052656769737465724d656d496e64657881a85265676973746572cd04a281b052656769737465724d656d496e64657881a85265676973746572cd04a381b052656769737465724d656d496e64657881a85265676973746572cd04a481b052656769737465724d656d496e64657881a85265676973746572cd04a581b052656769737465724d656d496e64657881a85265676973746572cd04a681b052656769737465724d656d496e64657881a85265676973746572cd04a781b052656769737465724d656d496e64657881a85265676973746572cd04a881b052656769737465724d656d496e64657881a85265676973746572cd04a981b052656769737465724d656d496e64657881a85265676973746572cd04aa81b052656769737465724d656d496e64657881a85265676973746572cd04ab909181ad5265676973746572496e646578cd04b89081a34d6f769281a852656769737465720081a85265676973746572cd04b8a843616c6c4261636b81a9426f6f747374726170919acd04a2cd04a3cd04a4cd04a5cd04a6cd04a7cd04a8cd04a9cd04aacd04ab01000000000000000000000000000000000000000000000000000000000000000000000000000000010200002b0000002c00000000010000000100000000000000000000000000000000000000000000000000000000000000000000012b0000002c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002d000000000000000000000000000000000000000000000000000000000000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000012b0000002d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012d000000000000000000000000000000000000000000000000000000000000000000000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002e0000000000000000000000000000000000000000000000000000000000000000000000010500080000000f000000fe00000010000000fe00000011000000fe00000012000000fe0000002e000000fe0000002e000000fe0000002e000000fe0000002e000000fe000000020000002f0000003000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000031000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000032000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000033000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000034000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000035000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000036000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000037000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000038000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000039000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000041000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000042000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000043000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000044000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000045000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000046000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000047000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000048000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000049000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000051000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000052000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000053000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000054000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000055000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000056000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000057000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010800000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000058000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000590000000000000000000000000000000000000000000000000000000000000000000000", + "bytecode": "000000005b000000120000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f0000001000000011000000120000002900000032000000330000003400000035000000360000003700000038000000390000003a0000003b0000003c0000003d0000003e0000003f000000400000004100000042000000430000004400000045000000460000004700000048000000490000004a0000004b0000004c0000004d0000004e0000004f000000500000005100000052000000530000005400000055000000560000005700000058000000590000005a000000490000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000013000000000000000000000000000000000000000000000000000000000000000000001d0105000200000013000000fe00000010000000fe000000020000001400000015000000010500020000000f000000fe00000014000000fe00000002000000160000001700000007010000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011600000000000000000000000000000000000000000000000000000000000000000000000100000001000300000018000000190000001a000000960100009981a34a4d509103a454726170a453746f7081a34d6f769281a85265676973746572cd02ca81a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333881a64f7261636c6595ad676574436f6d6d69746d656e749181b052656769737465724d656d496e64657881a85265676973746572cd02c3909181a541727261799281a8436f6e7374616e74d94030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303338039081a34d6f769281a85265676973746572cd02ca81a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333881a34d6f769281a852656769737465720081a85265676973746572cd02caa843616c6c4261636b81a9426f6f7473747261709191cd02c3010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000300000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001b00000000000000000000000000000000000000000000000000000000000000000000000200001b0000001c00000000010000000100000000000000000000000000000000000000000000000000000000000000000000011b0000001c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001d000000000000000000000000000000000000000000000000000000000000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000011b0000001d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001b000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011d00000000000000000000000000000000000000000000000000000000000000000000000105000300000010000000fe00000016000000fe00000019000000fe000000020000001e0000001f00000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000020000000000000000000000000000000000000000000000000000000000000000000000400000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002100000000000000000000000000000000000000000000000000000000000000000000010105000300000020000000fe00000021000000fe00000011000000fe000000020000002200000023000000070000000001000000000024000000740000009781a34a4d509103a454726170a453746f7081a64f7261636c6595ae67657452616e646f6d4669656c6490909181ad5265676973746572496e646578cd04599081a34d6f769281a852656769737465720081a85265676973746572cd0459a843616c6c4261636b81a9426f6f7473747261709190010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000025000000000000000000000000000000000000000000000000000000000000000000000200000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002600000000000000000000000000000000000000000000000000000000000000000000030105000700000025000000fe00000021000000fe00000026000000fe00000011000000fe00000012000000fe00000024000000fe0000000f000000fe00000002000000270000002800000007090000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012600000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012400000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010f000000000000000000000000000000000000000000000000000000000000000000000001000000000029000000a90100009781a34a4d509103a454726170a453746f7081a64f7261636c6595b16e6f74696679437265617465644e6f74659981b052656769737465724d656d496e64657881a85265676973746572cd04dc81b052656769737465724d656d496e64657881a85265676973746572cd04dd81b052656769737465724d656d496e64657881a85265676973746572cd04de81b052656769737465724d656d496e64657881a85265676973746572cd04df81b052656769737465724d656d496e64657881a85265676973746572cd04e081b052656769737465724d656d496e64657881a85265676973746572cd04e181b052656769737465724d656d496e64657881a85265676973746572cd04e281b052656769737465724d656d496e64657881a85265676973746572cd04e381b052656769737465724d656d496e64657881a85265676973746572cd04e4909181ad5265676973746572496e646578cd04f09081a34d6f769281a852656769737465720081a85265676973746572cd04f0a843616c6c4261636b81a9426f6f7473747261709199cd04dccd04ddcd04decd04dfcd04e0cd04e1cd04e2cd04e3cd04e40100000000000000000000000000000000000000000000000000000000000000000000000000000001020000290000002a0000000001000000010000000000000000000000000000000000000000000000000000000000000000000001290000002a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002b00000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001290000002b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000029000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012b0000000000000000000000000000000000000000000000000000000000000000000000070a0000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010600000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012600000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000011200000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012400000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010f00000000000000000000000000000000000000000000000000000000000000000000000100000000002c000000ca0100009781a34a4d509103a454726170a453746f7081a64f7261636c6595b0656d6974456e637279707465644c6f679a81b052656769737465724d656d496e64657881a85265676973746572cd059781b052656769737465724d656d496e64657881a85265676973746572cd059881b052656769737465724d656d496e64657881a85265676973746572cd059981b052656769737465724d656d496e64657881a85265676973746572cd059a81b052656769737465724d656d496e64657881a85265676973746572cd059b81b052656769737465724d656d496e64657881a85265676973746572cd059c81b052656769737465724d656d496e64657881a85265676973746572cd059d81b052656769737465724d656d496e64657881a85265676973746572cd059e81b052656769737465724d656d496e64657881a85265676973746572cd059f81b052656769737465724d656d496e64657881a85265676973746572cd05a0909181ad5265676973746572496e646578cd05ad9081a34d6f769281a852656769737465720081a85265676973746572cd05ada843616c6c4261636b81a9426f6f747374726170919acd0597cd0598cd0599cd059acd059bcd059ccd059dcd059ecd059fcd05a001000000000000000000000000000000000000000000000000000000000000000000000000000000010200002c0000002d00000000010000000100000000000000000000000000000000000000000000000000000000000000000000012c0000002d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002e000000000000000000000000000000000000000000000000000000000000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000012c0000002e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002c000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000012e000000000000000000000000000000000000000000000000000000000000000000000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002f0000000000000000000000000000000000000000000000000000000000000000000000010500080000000f000000fe00000010000000fe00000011000000fe00000012000000fe0000002f000000fe0000002f000000fe0000002f000000fe0000002f000000fe00000002000000300000003100000000000000000200000000000000000000000000000000000000000000000000000000000000000000010400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000032000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000033000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000034000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000035000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000036000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000037000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000013000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000038000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000039000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000041000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000042000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000043000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000044000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000045000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000046000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000047000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000048000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000049000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000051000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000052000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000053000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000054000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000055000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000056000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000057000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000058000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010800000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000059000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005a0000000000000000000000000000000000000000000000000000000000000000000000", "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" }, { From 331526d785ae2de282b8be3d505fc8ee154b56fd Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 13 Jun 2023 15:09:29 +0000 Subject: [PATCH 10/13] fix: lint --- .../src/client/private_execution.test.ts | 4 ++-- .../src/e2e_public_to_private_messaging.test.ts | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index bd77f6418651..4fdd31c8a9a7 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -449,8 +449,8 @@ describe('Private Execution test suite', () => { const wasm = await CircuitsWasm.get(); const secret = new Fr(1n); - const secretHash = pedersenCompressInputs(wasm, [secret.toBuffer()]); - const commitment = Fr.fromBuffer(pedersenCompressInputs(wasm, [toBufferBE(amount, 32), secretHash])); + const secretHash = computeSecretMessageHash(wasm, secret); + const commitment = Fr.fromBuffer(pedersenCompressInputs(wasm, [toBufferBE(amount, 32), secretHash.toBuffer()])); const siloedCommitment = siloCommitment(wasm, contractAddress, commitment); const tree: AppendOnlyTree = await newTree( diff --git a/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts index 978467921984..d59c2610b57c 100644 --- a/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts @@ -1,5 +1,13 @@ import { AztecNodeService } from '@aztec/aztec-node'; -import { AztecAddress, AztecRPCServer, Contract, ContractDeployer, Fr, TxStatus, computeMessageSecretHash } from '@aztec/aztec.js'; +import { + AztecAddress, + AztecRPCServer, + Contract, + ContractDeployer, + Fr, + TxStatus, + computeMessageSecretHash, +} from '@aztec/aztec.js'; import { PublicToPrivateContractAbi } from '@aztec/noir-contracts/examples'; import { DebugLogger } from '@aztec/foundation/log'; import { pointToPublicKey, setup } from './utils.js'; @@ -55,7 +63,7 @@ describe('e2e_public_to_private_messaging', () => { const secretHash = await computeMessageSecretHash(secret); // Create the commitment to be spent in the private domain - logger("Creating commitment in public call"); + logger('Creating commitment in public call'); const publicTx = deployedContract.methods.mintFromPublicToPrivate(mintAmount, secretHash).send({ from: receiver }); await publicTx.isMined(0, 0.1); @@ -64,7 +72,7 @@ describe('e2e_public_to_private_messaging', () => { expect(publicReceipt.status).toBe(TxStatus.MINED); // Create the transaction spending the commitment - logger("Spending commitment in private call"); + logger('Spending commitment in private call'); const privateTx = deployedContract.methods .mintFromPublicMessage(mintAmount, secret, pointToPublicKey(await aztecRpcServer.getAccountPublicKey(owner))) .send({ from: owner }); From 73a119abc2fa6d9f6e0bdd2f214b2c0f5f73edf4 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:37:26 +0000 Subject: [PATCH 11/13] fix: update noir review comments --- .../src/messaging/get_commitment_getter_data.nr | 11 ++--------- .../noir-aztec3/src/oracle/get_commitment.nr | 1 - .../contracts/public_private_contract/src/main.nr | 8 +++----- .../public_private_contract/src/transparent_note.nr | 2 +- .../src/examples/public_private_contract.json | 12 ++++-------- 5 files changed, 10 insertions(+), 24 deletions(-) diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/get_commitment_getter_data.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/get_commitment_getter_data.nr index 8b5dcafefb18..5eaaa7e63e22 100644 --- a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/get_commitment_getter_data.nr +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/messaging/get_commitment_getter_data.nr @@ -1,6 +1,4 @@ -use crate::messaging::l1_to_l2_message::L1_TO_L2_MESSAGE_LEN; -use crate::messaging::l1_to_l2_message::L1ToL2Message; -use crate::utils::arr_copy_slice; +use crate::oracle::get_commitment::COMMITMENT_GETTER_LENGTH; struct CommitmentGetterData { message: Field, @@ -8,12 +6,7 @@ struct CommitmentGetterData { root: Field, } -fn commitment_message_getter_len() -> comptime Field { - 1 + 1 + 1 -} - -// TODO: 3 as const -fn make_commitment_getter_data(fields: [Field; 3], start: comptime Field) -> CommitmentGetterData { +fn make_commitment_getter_data(fields: [Field; COMMITMENT_GETTER_LENGTH], start: comptime Field) -> CommitmentGetterData { CommitmentGetterData { message: fields[start], leaf_index: fields[start + 1], diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/get_commitment.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/get_commitment.nr index 1e40cb41e88e..2793c003bf6d 100644 --- a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/get_commitment.nr +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/oracle/get_commitment.nr @@ -1,6 +1,5 @@ // Oracle function to get a commitment, its sibling path and index, without getting its preimage. - // commitment + index + root; global COMMITMENT_GETTER_LENGTH = 3; diff --git a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr index 30e5314415e1..de36ba799670 100644 --- a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/main.nr @@ -40,14 +40,13 @@ contract PublicPrivate { amount: Field, secretHash: Field, _padding: [Field; dep::aztec3::abi::MAX_ARGS - 3] - ) -> Field{ + ) { // Create a commitment to the amount let note = TransparentNote::new(amount, secretHash); // Public oracle call to emit new commitment. create_commitment(note.get_commitment()); - 0 } open fn createL2ToL1MessagePublic( @@ -55,14 +54,13 @@ contract PublicPrivate { amount: Field, secretHash: Field, _padding: [Field; dep::aztec3::abi::MAX_ARGS - 3] - ) -> Field { + ) { // Create a commitment to the amount let note = TransparentNote::new(amount, secretHash); // Public oracle call to emit new commitment. create_l2_to_l1_message(note.get_commitment()); - 0 } @@ -77,7 +75,7 @@ contract PublicPrivate { // Assert that the note exists within the tree let public_note = TransparentNote::new_from_secret(amount, secret); - context = public_note.consume_in_private(context, inputs.roots.private_data_tree_root, secret); + context = public_note.consume_in_secret(context, inputs.roots.private_data_tree_root, secret); // Mint the tokens let owner_balance = balances.at(owner.x); diff --git a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/transparent_note.nr b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/transparent_note.nr index ebff1b94b71c..36c8d86c3d42 100644 --- a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/transparent_note.nr +++ b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/transparent_note.nr @@ -36,7 +36,7 @@ impl TransparentNote { pedersen([self.amount, self.secretHash])[0] } - fn consume_in_private(self: Self, mut context: PrivateFunctionContext, root: Field, secret: Field) -> PrivateFunctionContext { + fn consume_in_secret(self: Self, mut context: PrivateFunctionContext, root: Field, secret: Field) -> PrivateFunctionContext { // Get the commitment value (before silo) let commitment = self.get_commitment(); diff --git a/yarn-project/noir-contracts/src/examples/public_private_contract.json b/yarn-project/noir-contracts/src/examples/public_private_contract.json index 27280af6813d..6d8287066be6 100644 --- a/yarn-project/noir-contracts/src/examples/public_private_contract.json +++ b/yarn-project/noir-contracts/src/examples/public_private_contract.json @@ -29,11 +29,9 @@ } ], "returnTypes": [ - { - "kind": "field" - } + null ], - "bytecode": "0000000016000000000000000100000015000000070000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000030000000000000000000000000000000000000000000000000000000000000000000000010500020000000b000000fe0000000c000000fe000000020000001200000013000000070100000000000000000001000000000000000000000000000000000000000000000000000000000000000000000112000000000000000000000000000000000000000000000000000000000000000000000000000000050100009881a34a4d509103a454726170a453746f7081a64f7261636c6595b36372656174654c32546f4c314d6573736167659181b052656769737465724d656d496e64657881a8526567697374657237909181ad5265676973746572496e6465783b9081a842696e6172794f709581a8556e7369676e6564910181a3436d70a2457181a852656769737465723b81a8436f6e7374616e74d940303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303e81a84a4d5049464e4f549281a852656769737465723e01a843616c6c4261636b81a9426f6f747374726170919137010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000150000000000000000000000000000000000000000000000000000000000000000000000", + "bytecode": "00000000140000000000000000000000050000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000030000000000000000000000000000000000000000000000000000000000000000000000010500020000000b000000fe0000000c000000fe000000020000001200000013000000070100000000000000000001000000000000000000000000000000000000000000000000000000000000000000000112000000000000000000000000000000000000000000000000000000000000000000000000000000050100009881a34a4d509103a454726170a453746f7081a64f7261636c6595b36372656174654c32546f4c314d6573736167659181b052656769737465724d656d496e64657881a8526567697374657237909181ad5265676973746572496e6465783b9081a842696e6172794f709581a8556e7369676e6564910181a3436d70a2457181a852656769737465723b81a8436f6e7374616e74d940303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303e81a84a4d5049464e4f549281a852656769737465723e01a843616c6c4261636b81a9426f6f7473747261709191370100000000000000000000000000000000000000000000000000000000000000000000000000000001", "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" }, { @@ -134,11 +132,9 @@ } ], "returnTypes": [ - { - "kind": "field" - } + null ], - "bytecode": "0000000016000000000000000100000015000000070000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000030000000000000000000000000000000000000000000000000000000000000000000000010500020000000b000000fe0000000c000000fe000000020000001200000013000000070100000000000000000001000000000000000000000000000000000000000000000000000000000000000000000112000000000000000000000000000000000000000000000000000000000000000000000000000000020100009881a34a4d509103a454726170a453746f7081a64f7261636c6595b0637265617465436f6d6d69746d656e749181b052656769737465724d656d496e64657881a8526567697374657237909181ad5265676973746572496e6465783b9081a842696e6172794f709581a8556e7369676e6564910181a3436d70a2457181a852656769737465723b81a8436f6e7374616e74d940303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303e81a84a4d5049464e4f549281a852656769737465723e01a843616c6c4261636b81a9426f6f747374726170919137010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000150000000000000000000000000000000000000000000000000000000000000000000000", + "bytecode": "00000000140000000000000000000000050000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000030000000000000000000000000000000000000000000000000000000000000000000000010500020000000b000000fe0000000c000000fe000000020000001200000013000000070100000000000000000001000000000000000000000000000000000000000000000000000000000000000000000112000000000000000000000000000000000000000000000000000000000000000000000000000000020100009881a34a4d509103a454726170a453746f7081a64f7261636c6595b0637265617465436f6d6d69746d656e749181b052656769737465724d656d496e64657881a8526567697374657237909181ad5265676973746572496e6465783b9081a842696e6172794f709581a8556e7369676e6564910181a3436d70a2457181a852656769737465723b81a8436f6e7374616e74d940303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303e81a84a4d5049464e4f549281a852656769737465723e01a843616c6c4261636b81a9426f6f7473747261709191370100000000000000000000000000000000000000000000000000000000000000000000000000000001", "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" } ] From bc9b611bec697815c6feb03be4d7d36a64264eb6 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:54:33 +0000 Subject: [PATCH 12/13] fix: update nits --- .../src/client/client_execution_context.ts | 12 +++++++++++- yarn-project/acir-simulator/src/public/executor.ts | 1 - yarn-project/circuits.js/src/abis/abis.ts | 1 + .../public_private_contract/src/transparent_note.nr | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/yarn-project/acir-simulator/src/client/client_execution_context.ts b/yarn-project/acir-simulator/src/client/client_execution_context.ts index 12f2dbea10c7..f2ab7ca4ac37 100644 --- a/yarn-project/acir-simulator/src/client/client_execution_context.ts +++ b/yarn-project/acir-simulator/src/client/client_execution_context.ts @@ -11,6 +11,16 @@ import { } from '../acvm/index.js'; import { NoteLoadOracleInputs, DBOracle } from './db_oracle.js'; +/** + * A type that wraps data with it's read request index + */ +type ACVMWithReadRequestIndex = { + /** The index of the data in the tree. */ + index: bigint; + /** The formatted data. */ + acvmData: ACVMField[]; +} + /** * The execution context for a client tx simulation. */ @@ -105,7 +115,7 @@ export class ClientTxExecutionContext { * @param commitment - The commitment. * @returns The commitment data. */ - public async getCommitment(contractAddress: AztecAddress, commitment: Fr) { + public async getCommitment(contractAddress: AztecAddress, commitment: Fr): Promise { const commitmentInputs = await this.db.getCommitmentOracle(contractAddress, commitment); return { acvmData: toAcvmCommitmentLoadOracleInputs(commitmentInputs, this.historicRoots.privateDataTreeRoot), diff --git a/yarn-project/acir-simulator/src/public/executor.ts b/yarn-project/acir-simulator/src/public/executor.ts index 1ed451071a88..b46242263281 100644 --- a/yarn-project/acir-simulator/src/public/executor.ts +++ b/yarn-project/acir-simulator/src/public/executor.ts @@ -71,7 +71,6 @@ export class PublicExecutor { viewNotesPage: notAvailable, debugLog: notAvailable, - // TODO(Maddiaa): both getL1ToL2 and getCommitment share alot of code with the private conterpart? could be refactored getL1ToL2Message: async ([msgKey]: ACVMField[]) => { const messageInputs = await this.commitmentsDb.getL1ToL2Message(fromACVMField(msgKey)); return toAcvmL1ToL2MessageLoadOracleInputs(messageInputs, this.treeRoots.l1ToL2MessagesTreeRoot); diff --git a/yarn-project/circuits.js/src/abis/abis.ts b/yarn-project/circuits.js/src/abis/abis.ts index c98a2465eb7e..0609e442d948 100644 --- a/yarn-project/circuits.js/src/abis/abis.ts +++ b/yarn-project/circuits.js/src/abis/abis.ts @@ -188,6 +188,7 @@ export function computeContractAddress( /** * Computes a siloed commitment, given the contract address and the commitment itself. + * A siloed commitment effectively namespaces a commitment to a specific contract. * @param wasm - A module providing low-level wasm access. * @param contract - The contract address * @param commitment - The commitment to silo. diff --git a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/transparent_note.nr b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/transparent_note.nr index 36c8d86c3d42..4babdce105aa 100644 --- a/yarn-project/noir-contracts/src/contracts/public_private_contract/src/transparent_note.nr +++ b/yarn-project/noir-contracts/src/contracts/public_private_contract/src/transparent_note.nr @@ -31,7 +31,7 @@ impl TransparentNote { } // Gets the value of the commitment - // TODO(maddiaa): this will need to be hashed with a slot to keep it unique, which slot to pick? + // TODO(maddiaa): this will need to be hashed with a slot to keep it unique, which slot to pick? https://github.com/AztecProtocol/aztec-packages/issues/847 fn get_commitment(self: Self) -> Field { pedersen([self.amount, self.secretHash])[0] } From 6c2310b93da9f944be6b29e6d90f08e844fea45a Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Wed, 14 Jun 2023 12:10:28 +0000 Subject: [PATCH 13/13] chore(fmt) --- .../acir-simulator/src/client/client_execution_context.ts | 2 +- .../src/examples/public_private_contract.json | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/yarn-project/acir-simulator/src/client/client_execution_context.ts b/yarn-project/acir-simulator/src/client/client_execution_context.ts index f2ab7ca4ac37..bd901e28f175 100644 --- a/yarn-project/acir-simulator/src/client/client_execution_context.ts +++ b/yarn-project/acir-simulator/src/client/client_execution_context.ts @@ -19,7 +19,7 @@ type ACVMWithReadRequestIndex = { index: bigint; /** The formatted data. */ acvmData: ACVMField[]; -} +}; /** * The execution context for a client tx simulation. diff --git a/yarn-project/noir-contracts/src/examples/public_private_contract.json b/yarn-project/noir-contracts/src/examples/public_private_contract.json index 6d8287066be6..f97e895a8bac 100644 --- a/yarn-project/noir-contracts/src/examples/public_private_contract.json +++ b/yarn-project/noir-contracts/src/examples/public_private_contract.json @@ -28,9 +28,7 @@ "visibility": "private" } ], - "returnTypes": [ - null - ], + "returnTypes": [null], "bytecode": "00000000140000000000000000000000050000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000030000000000000000000000000000000000000000000000000000000000000000000000010500020000000b000000fe0000000c000000fe000000020000001200000013000000070100000000000000000001000000000000000000000000000000000000000000000000000000000000000000000112000000000000000000000000000000000000000000000000000000000000000000000000000000050100009881a34a4d509103a454726170a453746f7081a64f7261636c6595b36372656174654c32546f4c314d6573736167659181b052656769737465724d656d496e64657881a8526567697374657237909181ad5265676973746572496e6465783b9081a842696e6172794f709581a8556e7369676e6564910181a3436d70a2457181a852656769737465723b81a8436f6e7374616e74d940303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303e81a84a4d5049464e4f549281a852656769737465723e01a843616c6c4261636b81a9426f6f7473747261709191370100000000000000000000000000000000000000000000000000000000000000000000000000000001", "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" }, @@ -131,9 +129,7 @@ "visibility": "private" } ], - "returnTypes": [ - null - ], + "returnTypes": [null], "bytecode": "00000000140000000000000000000000050000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000030000000000000000000000000000000000000000000000000000000000000000000000010500020000000b000000fe0000000c000000fe000000020000001200000013000000070100000000000000000001000000000000000000000000000000000000000000000000000000000000000000000112000000000000000000000000000000000000000000000000000000000000000000000000000000020100009881a34a4d509103a454726170a453746f7081a64f7261636c6595b0637265617465436f6d6d69746d656e749181b052656769737465724d656d496e64657881a8526567697374657237909181ad5265676973746572496e6465783b9081a842696e6172794f709581a8556e7369676e6564910181a3436d70a2457181a852656769737465723b81a8436f6e7374616e74d940303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303e81a84a4d5049464e4f549281a852656769737465723e01a843616c6c4261636b81a9426f6f7473747261709191370100000000000000000000000000000000000000000000000000000000000000000000000000000001", "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" }