diff --git a/docs/docs/dev_docs/contracts/events.md b/docs/docs/dev_docs/contracts/events.md
index 5eb174bbf479..e115cd4a2778 100644
--- a/docs/docs/dev_docs/contracts/events.md
+++ b/docs/docs/dev_docs/contracts/events.md
@@ -61,6 +61,14 @@ Emitting unencrypted events from private function is a significant privacy leak
:::
+To emit unencrypted logs first import the `emit_unencrypted_log` utility function inside your contract:
+
+#include_code unencrypted_import /yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr rust
+
+Then you can call the function:
+
+#include_code unencrypted_log /yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr rust
+
Once emitted, unencrypted events are stored in AztecNode and can be queried by anyone:
@@ -72,19 +80,11 @@ aztec-cli get-logs --from 5 --limit 1
-#include_code logs /yarn-project/end-to-end/src/e2e_public_token_contract.test.ts typescript
+#include_code get_logs /yarn-project/end-to-end/src/fixtures/utils.ts typescript
-To emit unencrypted logs first import the `emit_unencrypted_log` utility function inside your contract:
-
-#include_code unencrypted_import /yarn-project/noir-contracts/src/contracts/private_token_contract/src/main.nr rust
-
-Then you can call the function:
-
-#include_code unencrypted /yarn-project/noir-contracts/src/contracts/private_token_contract/src/main.nr rust
-
### Costs
All event data is pushed to Ethereum as calldata by the sequencer and for this reason the cost of emitting an event is non-trivial.
diff --git a/docs/docs/dev_docs/getting_started/cli.md b/docs/docs/dev_docs/getting_started/cli.md
index 6272d5f94632..c7057f122412 100644
--- a/docs/docs/dev_docs/getting_started/cli.md
+++ b/docs/docs/dev_docs/getting_started/cli.md
@@ -216,16 +216,3 @@ View result: [
"{\"type\":\"bigint\",\"data\":\"543\"}"
]
```
-
-## Logs
-
-Finally, we can use the CLI's `get-logs` command to retrieve unencrypted logs emitted by the contract:
-
-```
-% aztec-cli get-logs --from 5 --limit 1
-Logs found:
-
-Coins transferred
-```
-
-Here we asked for the logs from block 5 (the block in which our call to `transfer` was mined) and to include a total of 1 block's worth of logs. The text `Coins Transferred` is emitted during the execution of the `transfer` function on the contract.
diff --git a/docs/docs/dev_docs/getting_started/sandbox.md b/docs/docs/dev_docs/getting_started/sandbox.md
index adf2dbdfd402..b68f472c4658 100644
--- a/docs/docs/dev_docs/getting_started/sandbox.md
+++ b/docs/docs/dev_docs/getting_started/sandbox.md
@@ -56,7 +56,6 @@ With the help of Aztec.js you will be able to:
- Simulate the calling of contract functions
- Send transactions to the network
- Be notified when transactions settle
-- Retrieve and view unencrypted logs emitted by contracts
- Query chain state such as chain id, block number etc.
## I have the Sandbox running, show me how to use it!
@@ -215,14 +214,14 @@ Running `yarn start` should now output:
That might seem like a lot to digest but it can be broken down into the following steps:
-1. We create 2 `Account` objects in Typescript. This object heavily abstracts away the mechanics of configuring and deploying an account contract and setting up a 'wallet' for signing transactions. If you aren't interested in building new types of account contracts or wallets then you don't need to be too concerned with it. In this example we have constructed account contracts and corresposing wallets that sign/verify transactions using schnorr signatures.
+1. We create 2 `Account` objects in Typescript. This object heavily abstracts away the mechanics of configuring and deploying an account contract and setting up a 'wallet' for signing transactions. If you aren't interested in building new types of account contracts or wallets then you don't need to be too concerned with it. In this example we have constructed account contracts and corresponding wallets that sign/verify transactions using schnorr signatures.
2. We wait for the deployment of the 2 account contracts to complete.
3. We retrieve the expected account addresses from the `Account` objects and ensure that they are present in the set of account addresses registered on the Sandbox.
Note, we use the `getAccounts` api to verify that the addresses computed as part of the
account contract deployment have been successfully added to the Sandbox.
-If you were looking at your terminal that is running the Sandbox you should hopefully have seen a lot of activity. This is because the Sandbox will have simulated the deployment of both contracts, executed the private kernel circuit for each before submitted 2 transactions to the pool. The sequencer will have picked them up and inserted them into a rollup and executed the recursive rollup circuits before publising the rollup to Anvil. Once this has completed, the rollup is retrieved and pulled down to the internal RPC Server so that any new account state can be decrypted.
+If you were looking at your terminal that is running the Sandbox you should hopefully have seen a lot of activity. This is because the Sandbox will have simulated the deployment of both contracts, executed the private kernel circuit for each before submitted 2 transactions to the pool. The sequencer will have picked them up and inserted them into a rollup and executed the recursive rollup circuits before publishing the rollup to Anvil. Once this has completed, the rollup is retrieved and pulled down to the internal RPC Server so that any new account state can be decrypted.
## Token Contract Deployment
@@ -250,14 +249,6 @@ We can break this down as follows:
4. We use the `getContractInfo()` api on the RPC Server to retrieve information about the reported contract address.
5. The fact that this api returns a valid object tells us that the contract was successfully deployed in a prior block.
-The Private Token Contract emits an unencrypted log message during construction:
-
-#include_code constructor /yarn-project/noir-contracts/src/contracts/private_token_contract/src/main.nr rust
-
-We can retrieve this emitted log using the `getUnencryptedLogs()` api:
-
-#include_code Logs /yarn-project/end-to-end/src/e2e_sandbox_example.test.ts typescript
-
Our output will now be:
```
@@ -266,14 +257,9 @@ Our output will now be:
private-token Created Alice's account at 0x054d89d0...f17e +23s
private-token Created Bob's account at 0x0a8410a1...7c48 +1ms
private-token Deploying private token contract minting an initial 1000000 tokens to Alice... +0ms
- private-token Transaction status is mined +8s
private-token Contract successfully deployed at address 0x143e0af4...11b6 +7ms
- private-token Retrieving unencrypted logs for block 3 +4ms
- private-token Emitted logs: [ 'Balance set in constructor' ] +5ms
```
-Note how we used the `getBlockNum()` api to retrieve the number of the last mined block. This is the block for which we want to retrieve logs as it is the last mined block number.
-
## Viewing the balance of an account
A token contract wouldn't be very useful if you aren't able to query the balance of an account. As part of the deployment, tokens were minted to Alice. We can now call the contract's `getBalance()` function to retrieve the balances of the accounts.
@@ -294,8 +280,6 @@ Running now should yield output:
private-token Deploying private token contract minting an initial 1000000 tokens to Alice... +0ms
private-token Transaction status is mined +8s
private-token Contract successfully deployed at address 0x143e0af4...11b6 +7ms
- private-token Retrieving unencrypted logs for block 3 +4ms
- private-token Emitted logs: [ 'Balance set in constructor' ] +5ms
private-token Alice's balance 1000000 +4s
private-token Bob's balance 0 +3s
```
@@ -314,8 +298,6 @@ Now lets transfer some funds from Alice to Bob by calling the `transfer` functio
#include_code transfer /yarn-project/noir-contracts/src/contracts/private_token_contract/src/main.nr rust
-We will again view the unencrypted logs emitted by the function and check the balances after the transfer:
-
#include_code Transfer /yarn-project/end-to-end/src/e2e_sandbox_example.test.ts typescript
Our output should now look like this:
@@ -326,20 +308,15 @@ Our output should now look like this:
private-token Created Alice's account at 0x054d89d0...f17e +23s
private-token Created Bob's account at 0x0a8410a1...7c48 +1ms
private-token Deploying private token contract minting an initial 1000000 tokens to Alice... +0ms
- private-token Transaction status is mined +8s
private-token Contract successfully deployed at address 0x143e0af4...11b6 +7ms
- private-token Retrieving unencrypted logs for block 3 +4ms
- private-token Emitted logs: [ 'Balance set in constructor' ] +5ms
private-token Alice's balance 1000000 +4s
private-token Bob's balance 0 +3s
private-token Transferring 543 tokens from Alice to Bob... +0ms
- private-token Retrieving unencrypted logs for block 4 +20s
- private-token Emitted logs: [ 'Coins transferred' ] +13ms
private-token Alice's balance 999457 +4s
private-token Bob's balance 543 +3s
```
-Here, we used the same contract abstraction as was previously used for reading Alice's balance. But this time we called `send()` generating and sending a transaction to the network. After waiting for the transaction to settle we were able to retrieve the newly emitted unencrypted logs and check the new balance values.
+Here, we used the same contract abstraction as was previously used for reading Alice's balance. But this time we called `send()` generating and sending a transaction to the network. After waiting for the transaction to settle we were able to check the new balance values.
Finally, the contract has a `mint` function that can be used to generate new tokens for an account. This takes 2 arguments:
@@ -360,20 +337,13 @@ Our complete output should now be:
private-token Created Alice's account at 0x054d89d0...f17e +23s
private-token Created Bob's account at 0x0a8410a1...7c48 +1ms
private-token Deploying private token contract minting an initial 1000000 tokens to Alice... +0ms
- private-token Transaction status is mined +8s
private-token Contract successfully deployed at address 0x143e0af4...11b6 +7ms
- private-token Retrieving unencrypted logs for block 3 +4ms
- private-token Emitted logs: [ 'Balance set in constructor' ] +5ms
private-token Alice's balance 1000000 +4s
private-token Bob's balance 0 +3s
private-token Transferring 543 tokens from Alice to Bob... +0ms
- private-token Retrieving unencrypted logs for block 4 +20s
- private-token Emitted logs: [ 'Coins transferred' ] +13ms
private-token Alice's balance 999457 +4s
private-token Bob's balance 543 +3s
private-token Minting 10000 tokens to Bob... +1ms
- private-token Retrieving unencrypted logs for block 5 +13s
- private-token Emitted logs: [ 'Coins minted' ] +13ms
private-token Alice's balance 999457 +4s
private-token Bob's balance 10543 +4s
```
diff --git a/yarn-project/aztec.js/src/abis/ecdsa_account_contract.json b/yarn-project/aztec.js/src/abis/ecdsa_account_contract.json
index fbf73e265e25..988773307d4c 100644
--- a/yarn-project/aztec.js/src/abis/ecdsa_account_contract.json
+++ b/yarn-project/aztec.js/src/abis/ecdsa_account_contract.json
@@ -166,7 +166,7 @@
"fileMap": {
"0": {
"source": "mod storage;\nmod ecdsa_public_key_note;\n\n// Account contract that uses ECDSA signatures for authentication on the same curve as Ethereum.\n// The signing key is stored in an immutable private note and should be different from the signing key.\ncontract EcdsaAccount {\n use dep::std;\n use dep::aztec::entrypoint;\n use dep::aztec::entrypoint::EntrypointPayload;\n use dep::aztec::abi;\n use dep::aztec::abi::PrivateContextInputs;\n use dep::aztec::abi::CallContext;\n use dep::aztec::context::PrivateContext;\n use dep::aztec::log::emit_encrypted_log;\n use dep::aztec::oracle::get_public_key::get_public_key;\n use dep::aztec::types::vec::BoundedVec;\n use dep::aztec::types::point::Point;\n use dep::aztec::constants_gen::GENERATOR_INDEX__SIGNATURE_PAYLOAD;\n\n use dep::aztec::constants_gen::MAX_NOTE_FIELDS_LENGTH;\n use dep::aztec::note::{\n note_header::{NoteHeader},\n utils as note_utils,\n };\n\n use crate::storage::Storage;\n use crate::ecdsa_public_key_note::EcdsaPublicKeyNote;\n use crate::ecdsa_public_key_note::EcdsaPublicKeyNoteInterface;\n use crate::ecdsa_public_key_note::ECDSA_PUBLIC_KEY_NOTE_LEN;\n\n // All calls made by this account will be routed through this entrypoint\n fn entrypoint( \n inputs: pub PrivateContextInputs,\n payload: pub EntrypointPayload, // contains a set of arguments, selectors, targets and a nonce\n signature: pub [u8;64],\n ) -> distinct pub abi::PrivateCircuitPublicInputs {\n \n // Initialise context\n // ENTRYPOINT_PAYLOAD_SIZE(13) + 64\n let mut args: BoundedVec = BoundedVec::new(0);\n args.push_array(payload.serialize());\n for byte in signature { args.push(byte as Field); }\n let mut context = PrivateContext::new(inputs, abi::hash_args(args.storage));\n\n // Load public key from storage\n let storage = Storage::init();\n let public_key = storage.public_key.get_note(&mut context);\n\n // Verify payload signature using Ethereum's signing scheme\n // Note that noir expects the hash of the message/challenge as input to the ECDSA verification.\n let payload_fields: [Field; entrypoint::ENTRYPOINT_PAYLOAD_SIZE] = payload.serialize();\n let message_field: Field = std::hash::pedersen_with_separator(payload_fields, GENERATOR_INDEX__SIGNATURE_PAYLOAD)[0];\n let message_bytes = message_field.to_be_bytes(32);\n let hashed_message: [u8; 32] = std::hash::sha256(message_bytes);\n let verification = std::ecdsa_secp256k1::verify_signature(public_key.x, public_key.y, signature, hashed_message);\n assert(verification == true);\n\n payload.execute_calls(&mut context);\n\n context.finish()\n }\n\n // Creates a new account out of an ECDSA public key to use for signature verification\n fn constructor(\n inputs: pub PrivateContextInputs,\n signing_pub_key_x: pub [u8;32],\n signing_pub_key_y: pub [u8;32],\n ) -> distinct pub abi::PrivateCircuitPublicInputs {\n let storage = Storage::init();\n \n let mut args: BoundedVec = BoundedVec::new(0);\n for byte in signing_pub_key_x { args.push(byte as Field); }\n for byte in signing_pub_key_y { args.push(byte as Field); }\n let mut context = PrivateContext::new(inputs, abi::hash_args(args.storage));\n \n let this = context.this_address();\n let mut pub_key_note = EcdsaPublicKeyNote::new(signing_pub_key_x, signing_pub_key_y, this);\n storage.public_key.initialise(&mut context, &mut pub_key_note);\n \n emit_encrypted_log(\n &mut context,\n this,\n storage.public_key.storage_slot,\n get_public_key(this),\n pub_key_note.serialise(),\n );\n\n context.finish()\n }\n\n // Computes note hash and nullifier.\n // Note 1: Needs to be defined by every contract producing logs.\n // Note 2: Having it in all the contracts gives us the ability to compute the note hash and nullifier differently for different kind of notes.\n unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: Field, storage_slot: Field, preimage: [Field; ECDSA_PUBLIC_KEY_NOTE_LEN]) -> [Field; 4] {\n assert(storage_slot == 1);\n let note_header = NoteHeader { contract_address, nonce, storage_slot };\n note_utils::compute_note_hash_and_nullifier(EcdsaPublicKeyNoteInterface, note_header, preimage)\n }\n}\n",
- "path": "/mnt/user-data/lasse/aztec3-packages/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/main"
+ "path": "/mnt/user-data/jan/aztec-packages/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/main"
},
"3": {
"source": "mod poseidon;\n\n#[foreign(sha256)]\nfn sha256(_input : [u8; N]) -> [u8; 32] {}\n\n#[foreign(blake2s)]\nfn blake2s(_input : [u8; N]) -> [u8; 32] {}\n\nfn pedersen(input : [Field; N]) -> [Field; 2] {\n pedersen_with_separator(input, 0)\n}\n\n#[foreign(pedersen)]\nfn pedersen_with_separator(_input : [Field; N], _separator : u32) -> [Field; 2] {}\n\n#[foreign(hash_to_field_128_security)]\nfn hash_to_field(_input : [Field; N]) -> Field {}\n\n#[foreign(keccak256)]\nfn keccak256(_input : [u8; N], _message_size: u32) -> [u8; 32] {}\n\n// mimc-p/p implementation\n// constants are (publicly generated) random numbers, for instance using keccak as a ROM.\n// You must use constants generated for the native field\n// Rounds number should be ~ log(p)/log(exp)\n// For 254 bit primes, exponent 7 and 91 rounds seems to be recommended\nfn mimc(x: Field, k: Field, constants: [Field; N], exp : Field) -> Field {\n //round 0\n let mut t = x + k;\n let mut h = t.pow_32(exp);\n //next rounds\n for i in 1 .. constants.len() {\n t = h + k + constants[i];\n h = t.pow_32(exp);\n };\n h + k\n}\n\nglobal MIMC_BN254_ROUNDS = 91;\n\n//mimc implementation with hardcoded parameters for BN254 curve.\nfn mimc_bn254(array: [Field; N]) -> Field {\n //mimc parameters\n let exponent = 7;\n //generated from seed \"mimc\" using keccak256 \n let constants: [Field; MIMC_BN254_ROUNDS] = [\n 0, \n 20888961410941983456478427210666206549300505294776164667214940546594746570981,\n 15265126113435022738560151911929040668591755459209400716467504685752745317193,\n 8334177627492981984476504167502758309043212251641796197711684499645635709656,\n 1374324219480165500871639364801692115397519265181803854177629327624133579404,\n 11442588683664344394633565859260176446561886575962616332903193988751292992472,\n 2558901189096558760448896669327086721003508630712968559048179091037845349145,\n 11189978595292752354820141775598510151189959177917284797737745690127318076389,\n 3262966573163560839685415914157855077211340576201936620532175028036746741754,\n 17029914891543225301403832095880481731551830725367286980611178737703889171730,\n 4614037031668406927330683909387957156531244689520944789503628527855167665518,\n 19647356996769918391113967168615123299113119185942498194367262335168397100658,\n 5040699236106090655289931820723926657076483236860546282406111821875672148900,\n 2632385916954580941368956176626336146806721642583847728103570779270161510514,\n 17691411851977575435597871505860208507285462834710151833948561098560743654671,\n 11482807709115676646560379017491661435505951727793345550942389701970904563183,\n 8360838254132998143349158726141014535383109403565779450210746881879715734773,\n 12663821244032248511491386323242575231591777785787269938928497649288048289525,\n 3067001377342968891237590775929219083706800062321980129409398033259904188058,\n 8536471869378957766675292398190944925664113548202769136103887479787957959589,\n 19825444354178182240559170937204690272111734703605805530888940813160705385792,\n 16703465144013840124940690347975638755097486902749048533167980887413919317592,\n 13061236261277650370863439564453267964462486225679643020432589226741411380501,\n 10864774797625152707517901967943775867717907803542223029967000416969007792571,\n 10035653564014594269791753415727486340557376923045841607746250017541686319774,\n 3446968588058668564420958894889124905706353937375068998436129414772610003289,\n 4653317306466493184743870159523234588955994456998076243468148492375236846006,\n 8486711143589723036499933521576871883500223198263343024003617825616410932026,\n 250710584458582618659378487568129931785810765264752039738223488321597070280,\n 2104159799604932521291371026105311735948154964200596636974609406977292675173,\n 16313562605837709339799839901240652934758303521543693857533755376563489378839,\n 6032365105133504724925793806318578936233045029919447519826248813478479197288,\n 14025118133847866722315446277964222215118620050302054655768867040006542798474,\n 7400123822125662712777833064081316757896757785777291653271747396958201309118,\n 1744432620323851751204287974553233986555641872755053103823939564833813704825,\n 8316378125659383262515151597439205374263247719876250938893842106722210729522,\n 6739722627047123650704294650168547689199576889424317598327664349670094847386,\n 21211457866117465531949733809706514799713333930924902519246949506964470524162,\n 13718112532745211817410303291774369209520657938741992779396229864894885156527,\n 5264534817993325015357427094323255342713527811596856940387954546330728068658,\n 18884137497114307927425084003812022333609937761793387700010402412840002189451,\n 5148596049900083984813839872929010525572543381981952060869301611018636120248,\n 19799686398774806587970184652860783461860993790013219899147141137827718662674,\n 19240878651604412704364448729659032944342952609050243268894572835672205984837,\n 10546185249390392695582524554167530669949955276893453512788278945742408153192,\n 5507959600969845538113649209272736011390582494851145043668969080335346810411,\n 18177751737739153338153217698774510185696788019377850245260475034576050820091,\n 19603444733183990109492724100282114612026332366576932662794133334264283907557,\n 10548274686824425401349248282213580046351514091431715597441736281987273193140,\n 1823201861560942974198127384034483127920205835821334101215923769688644479957,\n 11867589662193422187545516240823411225342068709600734253659804646934346124945,\n 18718569356736340558616379408444812528964066420519677106145092918482774343613,\n 10530777752259630125564678480897857853807637120039176813174150229243735996839,\n 20486583726592018813337145844457018474256372770211860618687961310422228379031,\n 12690713110714036569415168795200156516217175005650145422920562694422306200486,\n 17386427286863519095301372413760745749282643730629659997153085139065756667205,\n 2216432659854733047132347621569505613620980842043977268828076165669557467682,\n 6309765381643925252238633914530877025934201680691496500372265330505506717193,\n 20806323192073945401862788605803131761175139076694468214027227878952047793390,\n 4037040458505567977365391535756875199663510397600316887746139396052445718861,\n 19948974083684238245321361840704327952464170097132407924861169241740046562673,\n 845322671528508199439318170916419179535949348988022948153107378280175750024,\n 16222384601744433420585982239113457177459602187868460608565289920306145389382,\n 10232118865851112229330353999139005145127746617219324244541194256766741433339,\n 6699067738555349409504843460654299019000594109597429103342076743347235369120,\n 6220784880752427143725783746407285094967584864656399181815603544365010379208,\n 6129250029437675212264306655559561251995722990149771051304736001195288083309,\n 10773245783118750721454994239248013870822765715268323522295722350908043393604,\n 4490242021765793917495398271905043433053432245571325177153467194570741607167,\n 19596995117319480189066041930051006586888908165330319666010398892494684778526,\n 837850695495734270707668553360118467905109360511302468085569220634750561083,\n 11803922811376367215191737026157445294481406304781326649717082177394185903907,\n 10201298324909697255105265958780781450978049256931478989759448189112393506592,\n 13564695482314888817576351063608519127702411536552857463682060761575100923924,\n 9262808208636973454201420823766139682381973240743541030659775288508921362724,\n 173271062536305557219323722062711383294158572562695717740068656098441040230,\n 18120430890549410286417591505529104700901943324772175772035648111937818237369,\n 20484495168135072493552514219686101965206843697794133766912991150184337935627,\n 19155651295705203459475805213866664350848604323501251939850063308319753686505,\n 11971299749478202793661982361798418342615500543489781306376058267926437157297,\n 18285310723116790056148596536349375622245669010373674803854111592441823052978,\n 7069216248902547653615508023941692395371990416048967468982099270925308100727,\n 6465151453746412132599596984628739550147379072443683076388208843341824127379,\n 16143532858389170960690347742477978826830511669766530042104134302796355145785,\n 19362583304414853660976404410208489566967618125972377176980367224623492419647,\n 1702213613534733786921602839210290505213503664731919006932367875629005980493,\n 10781825404476535814285389902565833897646945212027592373510689209734812292327,\n 4212716923652881254737947578600828255798948993302968210248673545442808456151,\n 7594017890037021425366623750593200398174488805473151513558919864633711506220,\n 18979889247746272055963929241596362599320706910852082477600815822482192194401,\n 13602139229813231349386885113156901793661719180900395818909719758150455500533,\n ];\n\n let mut r = 0;\n for elem in array {\n let h = mimc(elem, r, constants, exponent);\n r = r + elem + h;\n }\n r\n}\n",
@@ -178,47 +178,47 @@
},
"31": {
"source": "use crate::constants_gen::{\n RETURN_VALUES_LENGTH,\n MAX_READ_REQUESTS_PER_CALL,\n MAX_NEW_COMMITMENTS_PER_CALL,\n MAX_NEW_NULLIFIERS_PER_CALL,\n MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL,\n MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL,\n MAX_NEW_L2_TO_L1_MSGS_PER_CALL,\n NUM_FIELDS_PER_SHA256,\n MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,\n MAX_PUBLIC_DATA_READS_PER_CALL,\n GENERATOR_INDEX__FUNCTION_ARGS,\n HISTORIC_BLOCK_DATA_LENGTH,\n CONTRACT_DEPLOYMENT_DATA_LENGTH,\n CALL_CONTEXT_LENGTH,\n PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH,\n PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH,\n CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH,\n CONTRACT_STORAGE_READ_LENGTH,\n PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH,\n PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH,\n GENERATOR_INDEX__PUBLIC_CIRCUIT_PUBLIC_INPUTS,\n GENERATOR_INDEX__FUNCTION_DATA,\n GENERATOR_INDEX__PUBLIC_DATA_READ,\n GENERATOR_INDEX__PUBLIC_DATA_UPDATE_REQUEST,\n GENERATOR_INDEX__CALL_CONTEXT,\n GENERATOR_INDEX__PRIVATE_CIRCUIT_PUBLIC_INPUTS,\n GENERATOR_INDEX__CONTRACT_DEPLOYMENT_DATA,\n};\n\nuse crate::oracle::debug_log;\nuse crate::types::vec::BoundedVec;\nuse crate::types::point::Point;\n\nstruct PrivateGlobalVariables {\n chain_id: Field,\n version: Field,\n}\n\nimpl PrivateGlobalVariables {\n fn serialize(self) -> [Field; 2] {\n [self.chain_id, self.version]\n }\n}\n\nstruct PublicGlobalVariables {\n chain_id: Field,\n version: Field,\n block_number: Field,\n timestamp: Field,\n}\n\nimpl PublicGlobalVariables {\n fn serialize(self) -> [Field; 4] {\n [self.chain_id, self.version, self.block_number, self.timestamp]\n }\n}\n\nstruct ContractDeploymentData {\n deployer_public_key: Point,\n constructor_vk_hash : Field,\n function_tree_root : Field,\n contract_address_salt : Field,\n portal_contract_address : Field,\n}\n\nimpl ContractDeploymentData {\n fn serialize(self) -> [Field; CONTRACT_DEPLOYMENT_DATA_LENGTH] {\n [\n self.deployer_public_key.x,\n self.deployer_public_key.y,\n self.constructor_vk_hash,\n self.function_tree_root,\n self.contract_address_salt,\n self.portal_contract_address,\n ]\n }\n\n fn hash(self) -> Field {\n dep::std::hash::pedersen_with_separator(self.serialize(), GENERATOR_INDEX__CONTRACT_DEPLOYMENT_DATA)[0]\n }\n}\n\n// PrivateContextInputs are expected to be provided to each private function\nstruct PrivateContextInputs {\n call_context : CallContext,\n block_data: HistoricBlockData,\n\n contract_deployment_data: ContractDeploymentData,\n\n private_global_variables: PrivateGlobalVariables,\n}\n\n// PublicContextInputs are expected to be provided to each public function\nstruct PublicContextInputs {\n call_context: CallContext,\n block_data: HistoricBlockData,\n\n public_global_variables: PublicGlobalVariables,\n}\n\nstruct CallContext {\n msg_sender : Field,\n storage_contract_address : Field,\n portal_contract_address : Field,\n\n is_delegate_call : bool,\n is_static_call : bool,\n is_contract_deployment: bool,\n}\n\nimpl CallContext {\n fn serialize(self) -> [Field; CALL_CONTEXT_LENGTH] {\n [\n self.msg_sender,\n self.storage_contract_address,\n self.portal_contract_address,\n self.is_delegate_call as Field,\n self.is_static_call as Field,\n self.is_contract_deployment as Field,\n ]\n }\n\n fn hash(self) -> Field {\n dep::std::hash::pedersen_with_separator(self.serialize(), GENERATOR_INDEX__CALL_CONTEXT)[0]\n }\n}\n\nstruct HistoricBlockData {\n private_data_tree_root : Field,\n nullifier_tree_root : Field,\n contract_tree_root : Field,\n l1_to_l2_messages_tree_root : Field,\n blocks_tree_root: Field,\n public_data_tree_root: Field,\n global_variables_hash: Field,\n}\n\nimpl HistoricBlockData {\n // NOTE: this order must match the order in `private_circuit_public_inputs.hpp`\n fn serialize(self) -> [Field; HISTORIC_BLOCK_DATA_LENGTH] {\n [\n self.private_data_tree_root,\n self.nullifier_tree_root,\n self.contract_tree_root,\n self.l1_to_l2_messages_tree_root,\n self.blocks_tree_root,\n self.public_data_tree_root,\n self.global_variables_hash,\n ]\n }\n\n fn empty() -> Self {\n Self { private_data_tree_root: 0, nullifier_tree_root: 0, contract_tree_root: 0, l1_to_l2_messages_tree_root: 0, blocks_tree_root: 0, public_data_tree_root: 0, global_variables_hash: 0 }\n }\n}\n\nstruct FunctionData {\n function_selector: Field,\n is_internal: bool,\n is_private: bool,\n is_constructor: bool,\n}\n\nimpl FunctionData {\n fn hash(self) -> Field {\n dep::std::hash::pedersen_with_separator([\n self.function_selector,\n self.is_internal as Field,\n self.is_private as Field,\n self.is_constructor as Field,\n ], GENERATOR_INDEX__FUNCTION_DATA)[0]\n }\n}\n\nstruct PrivateCircuitPublicInputs {\n call_context: CallContext,\n args_hash: Field,\n return_values: [Field; RETURN_VALUES_LENGTH],\n read_requests: [Field; crate::abi::MAX_READ_REQUESTS_PER_CALL],\n new_commitments: [Field; MAX_NEW_COMMITMENTS_PER_CALL],\n new_nullifiers: [Field; MAX_NEW_NULLIFIERS_PER_CALL],\n nullified_commitments: [Field; MAX_NEW_NULLIFIERS_PER_CALL],\n private_call_stack: [Field; MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL],\n public_call_stack: [Field; MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL],\n new_l2_to_l1_msgs: [Field; MAX_NEW_L2_TO_L1_MSGS_PER_CALL],\n // Explore introducing a new type like uint256 (similar to Point), so it's more explicit that\n // we're talking about a single number backed by two field elements.\n encrypted_logs_hash: [Field; NUM_FIELDS_PER_SHA256],\n unencrypted_logs_hash: [Field; NUM_FIELDS_PER_SHA256],\n encrypted_log_preimages_length: Field,\n unencrypted_log_preimages_length: Field,\n block_data: HistoricBlockData,\n contract_deployment_data: ContractDeploymentData,\n chain_id: Field,\n version: Field,\n}\n\nimpl PrivateCircuitPublicInputs {\n fn hash(self) -> Field {\n let mut fields: BoundedVec = BoundedVec::new(0); \n fields.push(self.call_context.hash());\n fields.push(self.args_hash);\n fields.push_array(self.return_values);\n fields.push_array(self.read_requests);\n fields.push_array(self.new_commitments);\n fields.push_array(self.new_nullifiers);\n fields.push_array(self.nullified_commitments);\n fields.push_array(self.private_call_stack);\n fields.push_array(self.public_call_stack);\n fields.push_array(self.new_l2_to_l1_msgs);\n fields.push_array(self.encrypted_logs_hash);\n fields.push_array(self.unencrypted_logs_hash);\n fields.push(self.encrypted_log_preimages_length);\n fields.push(self.unencrypted_log_preimages_length);\n fields.push_array(self.block_data.serialize());\n fields.push(self.contract_deployment_data.hash());\n fields.push(self.chain_id);\n fields.push(self.version);\n\n dep::std::hash::pedersen_with_separator(fields.storage, GENERATOR_INDEX__PRIVATE_CIRCUIT_PUBLIC_INPUTS)[0]\n }\n\n fn serialize(self) -> [Field; PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH] {\n let mut fields: BoundedVec = BoundedVec::new(0); \n fields.push_array(self.call_context.serialize());\n fields.push(self.args_hash);\n fields.push_array(self.return_values);\n fields.push_array(self.read_requests);\n fields.push_array(self.new_commitments);\n fields.push_array(self.new_nullifiers);\n fields.push_array(self.private_call_stack);\n fields.push_array(self.public_call_stack);\n fields.push_array(self.new_l2_to_l1_msgs);\n fields.push_array(self.encrypted_logs_hash);\n fields.push_array(self.unencrypted_logs_hash);\n fields.push(self.encrypted_log_preimages_length);\n fields.push(self.unencrypted_log_preimages_length);\n fields.push_array(self.block_data.serialize());\n fields.push_array(self.contract_deployment_data.serialize());\n fields.push(self.chain_id);\n fields.push(self.version);\n fields.storage\n }\n}\n\nstruct ContractStorageRead {\n storage_slot: Field,\n value: Field,\n}\n\nimpl ContractStorageRead {\n fn serialize(self) -> [Field; CONTRACT_STORAGE_READ_LENGTH] {\n [self.storage_slot, self.value]\n }\n\n fn hash(self) -> Field {\n dep::std::hash::pedersen_with_separator(self.serialize(), GENERATOR_INDEX__PUBLIC_DATA_READ)[0]\n }\n\n fn empty() -> Self {\n Self { storage_slot: 0, value: 0 }\n }\n}\n\nstruct ContractStorageUpdateRequest {\n storage_slot: Field,\n old_value: Field,\n new_value: Field,\n}\n\nimpl ContractStorageUpdateRequest {\n fn serialize(self) -> [Field; CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH] {\n [self.storage_slot, self.old_value, self.new_value]\n }\n\n fn hash(self) -> Field {\n dep::std::hash::pedersen_with_separator(self.serialize(), GENERATOR_INDEX__PUBLIC_DATA_UPDATE_REQUEST)[0]\n }\n\n fn empty() -> Self {\n Self { storage_slot: 0, old_value: 0, new_value: 0 }\n }\n}\n\n\nstruct PublicCircuitPublicInputs {\n call_context: CallContext,\n args_hash: Field,\n return_values: [Field; RETURN_VALUES_LENGTH],\n contract_storage_update_requests: [ContractStorageUpdateRequest; MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL],\n contract_storage_read: [ContractStorageRead; MAX_PUBLIC_DATA_READS_PER_CALL],\n public_call_stack: [Field; MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL],\n new_commitments: [Field; MAX_NEW_COMMITMENTS_PER_CALL],\n new_nullifiers: [Field; crate::abi::MAX_NEW_NULLIFIERS_PER_CALL],\n new_l2_to_l1_msgs: [Field; crate::abi::MAX_NEW_L2_TO_L1_MSGS_PER_CALL],\n unencrypted_logs_hash: [Field; NUM_FIELDS_PER_SHA256],\n unencrypted_log_preimages_length: Field,\n block_data: HistoricBlockData,\n prover_address: Field,\n\n // TODO: include globals in here and check them elsewhere\n // https://github.com/AztecProtocol/aztec-packages/issues/1567\n}\n\nimpl PublicCircuitPublicInputs {\n \n fn hash(self) -> Field {\n let mut inputs: BoundedVec = BoundedVec::new(0);\n inputs.push(self.call_context.hash());\n inputs.push(self.args_hash);\n inputs.push_array(self.return_values);\n for i in 0..MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL {\n inputs.push(self.contract_storage_update_requests[i].hash());\n }\n for i in 0..MAX_PUBLIC_DATA_READS_PER_CALL {\n inputs.push(self.contract_storage_read[i].hash());\n }\n inputs.push_array(self.public_call_stack);\n inputs.push_array(self.new_commitments);\n inputs.push_array(self.new_nullifiers);\n inputs.push_array(self.new_l2_to_l1_msgs);\n\n // We do not include block_data since it's not in the cpp hash\n\n inputs.push_array(self.unencrypted_logs_hash);\n inputs.push(self.unencrypted_log_preimages_length);\n inputs.push_array(self.block_data.serialize()); // see https://github.com/AztecProtocol/aztec-packages/issues/1473\n inputs.push(self.prover_address);\n\n dep::std::hash::pedersen_with_separator(inputs.storage, GENERATOR_INDEX__PUBLIC_CIRCUIT_PUBLIC_INPUTS)[0]\n }\n\n fn serialize(self) -> [Field; PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH] {\n let mut fields: BoundedVec = BoundedVec::new(0); \n fields.push_array(self.call_context.serialize()); \n fields.push(self.args_hash);\n fields.push_array(self.return_values);\n for i in 0..MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL {\n fields.push_array(self.contract_storage_update_requests[i].serialize());\n }\n for i in 0..MAX_PUBLIC_DATA_READS_PER_CALL {\n fields.push_array(self.contract_storage_read[i].serialize());\n }\n fields.push_array(self.public_call_stack);\n fields.push_array(self.new_commitments);\n fields.push_array(self.new_nullifiers);\n fields.push_array(self.new_l2_to_l1_msgs);\n fields.push_array(self.unencrypted_logs_hash);\n fields.push(self.unencrypted_log_preimages_length);\n fields.push_array(self.block_data.serialize());\n fields.push(self.prover_address);\n fields.storage\n }\n}\n\nglobal ARGS_HASH_CHUNK_LENGTH: u32 = 32;\nglobal ARGS_HASH_CHUNK_COUNT: u32 = 16;\n\nfn hash_args(args: [Field; N]) -> Field {\n if args.len() == 0 {\n 0\n } else {\n let mut chunks_hashes = [0; ARGS_HASH_CHUNK_COUNT];\n for i in 0..ARGS_HASH_CHUNK_COUNT {\n let mut chunk_hash = 0;\n let start_chunk_index = i * ARGS_HASH_CHUNK_LENGTH;\n if start_chunk_index < (args.len() as u32) {\n let mut chunk_args = [0; ARGS_HASH_CHUNK_LENGTH];\n for j in 0..ARGS_HASH_CHUNK_LENGTH {\n let item_index = i * ARGS_HASH_CHUNK_LENGTH + j;\n if item_index < (args.len() as u32) {\n chunk_args[j] = args[item_index];\n }\n }\n chunk_hash = dep::std::hash::pedersen_with_separator(chunk_args, GENERATOR_INDEX__FUNCTION_ARGS)[0];\n }\n chunks_hashes[i] = chunk_hash;\n }\n dep::std::hash::pedersen_with_separator(chunks_hashes, GENERATOR_INDEX__FUNCTION_ARGS)[0]\n }\n}\n",
- "path": "/mnt/user-data/lasse/aztec3-packages/yarn-project/noir-libs/noir-aztec/src/abi"
+ "path": "/mnt/user-data/jan/aztec-packages/yarn-project/noir-libs/noir-aztec/src/abi"
},
"32": {
"source": "use crate::constants_gen::{\n EMPTY_NULLIFIED_COMMITMENT,\n MAX_NEW_COMMITMENTS_PER_CALL,\n MAX_NEW_L2_TO_L1_MSGS_PER_CALL,\n MAX_NEW_NULLIFIERS_PER_CALL,\n MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL,\n MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL,\n MAX_PUBLIC_DATA_READS_PER_CALL,\n MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,\n MAX_READ_REQUESTS_PER_CALL,\n NUM_FIELDS_PER_SHA256,\n RETURN_VALUES_LENGTH,\n};\n\nuse crate::abi;\n\nuse crate::abi::{\n hash_args,\n CallContext,\n ContractDeploymentData,\n HistoricBlockData,\n FunctionData,\n PrivateCircuitPublicInputs,\n PublicCircuitPublicInputs,\n};\n\n// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)\n// use dep::std::collections::vec::Vec;\n\n// l1 to l2 messaging\nuse crate::messaging::process_l1_to_l2_message;\nuse crate::private_call_stack_item::PrivateCallStackItem;\nuse crate::public_call_stack_item::PublicCallStackItem;\n\nuse crate::types::{\n vec::BoundedVec,\n point::Point,\n};\n\nuse crate::utils::arr_copy_slice;\n\nuse crate::oracle::{\n arguments,\n call_private_function::call_private_function_internal,\n public_call::call_public_function_internal,\n enqueue_public_function_call::enqueue_public_function_call_internal,\n context::get_portal_address,\n};\n\n\n// When finished, one can call .finish() to convert back to the abi\nstruct PrivateContext {\n inputs: abi::PrivateContextInputs,\n\n args_hash : Field,\n return_values : BoundedVec,\n\n read_requests: BoundedVec,\n\n new_commitments: BoundedVec,\n new_nullifiers: BoundedVec,\n nullified_commitments: BoundedVec,\n\n private_call_stack : BoundedVec,\n public_call_stack : BoundedVec,\n new_l2_to_l1_msgs : BoundedVec,\n\n block_data: HistoricBlockData,\n\n // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)\n // encrypted_logs_preimages: Vec,\n // unencrypted_logs_preimages: Vec,\n}\n\nimpl PrivateContext {\n fn new(inputs: abi::PrivateContextInputs, args_hash: Field) -> PrivateContext {\n PrivateContext {\n inputs: inputs,\n\n args_hash: args_hash,\n return_values: BoundedVec::new(0),\n\n read_requests: BoundedVec::new(0),\n\n new_commitments: BoundedVec::new(0),\n new_nullifiers: BoundedVec::new(0),\n nullified_commitments: BoundedVec::new(0),\n\n block_data: inputs.block_data,\n\n private_call_stack: BoundedVec::new(0),\n public_call_stack: BoundedVec::new(0),\n new_l2_to_l1_msgs: BoundedVec::new(0),\n\n // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)\n // encrypted_logs_preimages: Vec::new(),\n // unencrypted_logs_preimages: Vec::new(),\n }\n }\n\n fn msg_sender(self) -> Field {\n self.inputs.call_context.msg_sender\n }\n\n fn this_address(self) -> Field {\n self.inputs.call_context.storage_contract_address\n }\n\n fn this_portal_address(self) -> Field {\n self.inputs.call_context.portal_contract_address\n }\n\n fn chain_id(self) -> Field {\n self.inputs.private_global_variables.chain_id\n }\n\n fn version(self) -> Field {\n self.inputs.private_global_variables.version\n }\n\n fn finish(self) -> abi::PrivateCircuitPublicInputs {\n // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)\n let encrypted_logs_hash = [0; NUM_FIELDS_PER_SHA256];\n let unencrypted_logs_hash = [0; NUM_FIELDS_PER_SHA256];\n let encrypted_log_preimages_length = 0;\n let unencrypted_log_preimages_length = 0;\n\n let priv_circuit_pub_inputs = abi::PrivateCircuitPublicInputs {\n call_context: self.inputs.call_context,\n args_hash: self.args_hash,\n return_values: self.return_values.storage,\n read_requests: self.read_requests.storage,\n new_commitments: self.new_commitments.storage,\n new_nullifiers: self.new_nullifiers.storage,\n nullified_commitments: self.nullified_commitments.storage,\n private_call_stack: self.private_call_stack.storage,\n public_call_stack: self.public_call_stack.storage,\n new_l2_to_l1_msgs: self.new_l2_to_l1_msgs.storage,\n encrypted_logs_hash: encrypted_logs_hash,\n unencrypted_logs_hash: unencrypted_logs_hash,\n encrypted_log_preimages_length: encrypted_log_preimages_length,\n unencrypted_log_preimages_length: unencrypted_log_preimages_length,\n block_data: self.block_data,\n contract_deployment_data: self.inputs.contract_deployment_data,\n chain_id: self.inputs.private_global_variables.chain_id,\n version: self.inputs.private_global_variables.version,\n };\n priv_circuit_pub_inputs\n }\n\n fn push_read_request(&mut self, read_request: Field) {\n self.read_requests.push(read_request);\n }\n\n fn push_new_note_hash(&mut self, note_hash: Field) {\n self.new_commitments.push(note_hash);\n }\n\n fn push_new_nullifier(&mut self, nullifier: Field, nullified_commitment: Field) {\n self.new_nullifiers.push(nullifier);\n self.nullified_commitments.push(nullified_commitment);\n }\n\n fn message_portal(&mut self, content: Field) {\n self.new_l2_to_l1_msgs.push(content);\n }\n\n // PrivateContextInputs must be temporarily passed in to prevent too many unknowns\n // Note this returns self to get around an issue where mutable structs do not maintain mutations unless reassigned\n fn consume_l1_to_l2_message(&mut self, inputs: abi::PrivateContextInputs, msg_key: Field, content: Field, secret: Field) {\n let nullifier = process_l1_to_l2_message(inputs.block_data.l1_to_l2_messages_tree_root, inputs.call_context.storage_contract_address, msg_key, content, secret);\n\n // Push nullifier (and the \"commitment\" corresponding to this can be \"empty\")\n self.push_new_nullifier(nullifier, EMPTY_NULLIFIED_COMMITMENT)\n }\n\n fn accumulate_encrypted_logs(&mut self, log: [Field; N]) {\n let _void1 = self.inputs;\n let _void2 = log;\n // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)\n }\n\n fn accumulate_unencrypted_logs(&mut self, log: T) {\n let _void1 = self.inputs;\n let _void2 = log;\n // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)\n }\n\n fn call_private_function(\n &mut self,\n contract_address: Field, \n function_selector: Field, \n args: [Field; ARGS_COUNT]\n ) -> [Field; RETURN_VALUES_LENGTH] {\n let args_hash = hash_args(args);\n assert(args_hash == arguments::pack_arguments(args));\n self.call_private_function_with_packed_args(contract_address, function_selector, args_hash)\n }\n\n fn call_private_function_no_args(\n &mut self,\n contract_address: Field, \n function_selector: Field, \n ) -> [Field; RETURN_VALUES_LENGTH] {\n self.call_private_function_with_packed_args(contract_address, function_selector, 0)\n }\n\n fn call_private_function_with_packed_args(\n &mut self,\n contract_address: Field,\n function_selector: Field,\n args_hash: Field\n ) -> [Field; RETURN_VALUES_LENGTH] {\n let fields = call_private_function_internal(\n contract_address, \n function_selector, \n args_hash\n );\n let item = PrivateCallStackItem {\n contract_address: fields[0],\n function_data: FunctionData {\n function_selector: fields[1],\n is_internal: fields[2] as bool,\n is_private: fields[3] as bool,\n is_constructor: fields[4] as bool,\n },\n public_inputs: PrivateCircuitPublicInputs {\n call_context: CallContext {\n msg_sender : fields[5],\n storage_contract_address : fields[6],\n portal_contract_address : fields[7],\n \n is_delegate_call : fields[8] as bool,\n is_static_call : fields[9] as bool,\n is_contract_deployment: fields[10] as bool,\n },\n // TODO handle the offsets as a variable incremented during extraction?\n args_hash: fields[11],\n return_values: arr_copy_slice(fields, [0; RETURN_VALUES_LENGTH], 12),\n read_requests: arr_copy_slice(fields, [0; MAX_READ_REQUESTS_PER_CALL], 16),\n new_commitments: arr_copy_slice(fields, [0; MAX_NEW_COMMITMENTS_PER_CALL], 20),\n new_nullifiers: arr_copy_slice(fields, [0; MAX_NEW_NULLIFIERS_PER_CALL], 24),\n nullified_commitments: arr_copy_slice(fields, [0; MAX_NEW_NULLIFIERS_PER_CALL], 28),\n private_call_stack: arr_copy_slice(fields, [0; MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL], 32),\n public_call_stack: arr_copy_slice(fields, [0; MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL], 36),\n new_l2_to_l1_msgs: arr_copy_slice(fields, [0; MAX_NEW_L2_TO_L1_MSGS_PER_CALL], 40),\n encrypted_logs_hash: arr_copy_slice(fields, [0; NUM_FIELDS_PER_SHA256], 42),\n unencrypted_logs_hash: arr_copy_slice(fields, [0; NUM_FIELDS_PER_SHA256], 44),\n encrypted_log_preimages_length: fields[46],\n unencrypted_log_preimages_length: fields[47],\n block_data: HistoricBlockData {\n // Must match order in `private_circuit_public_inputs.hpp`\n private_data_tree_root : fields[48],\n nullifier_tree_root : fields[49],\n contract_tree_root : fields[50],\n l1_to_l2_messages_tree_root : fields[51],\n blocks_tree_root : fields[52],\n public_data_tree_root: fields[53],\n global_variables_hash: fields[54],\n },\n contract_deployment_data: ContractDeploymentData {\n deployer_public_key: Point::new(fields[55], fields[56]),\n constructor_vk_hash : fields[57],\n function_tree_root : fields[58],\n contract_address_salt : fields[59],\n portal_contract_address : fields[60],\n },\n chain_id: fields[61],\n version: fields[62],\n },\n is_execution_request: fields[63] as bool,\n };\n assert(contract_address == item.contract_address);\n assert(function_selector == item.function_data.function_selector);\n\n assert(args_hash == item.public_inputs.args_hash);\n\n assert(item.is_execution_request == false);\n\n // Assert that the call context of the enqueued call generated by the oracle matches our request.\n // We are issuing a regular call which is not delegate, static, or deployment. We also constrain\n // the msg_sender in the nested call to be equal to our address, and the execution context address\n // for the nested call to be equal to the address we actually called.\n assert(item.public_inputs.call_context.is_delegate_call == false);\n assert(item.public_inputs.call_context.is_static_call == false);\n assert(item.public_inputs.call_context.is_contract_deployment == false);\n assert(item.public_inputs.call_context.msg_sender == self.inputs.call_context.storage_contract_address);\n assert(item.public_inputs.call_context.storage_contract_address == contract_address);\n\n self.private_call_stack.push(item.hash());\n\n item.public_inputs.return_values\n }\n\n fn call_public_function(\n &mut self,\n contract_address: Field, \n function_selector: Field, \n args: [Field; ARGS_COUNT]\n ) {\n let args_hash = hash_args(args);\n assert(args_hash == arguments::pack_arguments(args));\n self.call_public_function_with_packed_args(contract_address, function_selector, args_hash)\n }\n\n fn call_public_function_no_args(\n &mut self,\n contract_address: Field, \n function_selector: Field,\n ) {\n self.call_public_function_with_packed_args(contract_address, function_selector, 0)\n }\n\n fn call_public_function_with_packed_args(\n &mut self,\n contract_address: Field,\n function_selector: Field,\n args_hash: Field\n ) {\n let fields = enqueue_public_function_call_internal(\n contract_address, \n function_selector, \n args_hash\n );\n let item = PublicCallStackItem {\n contract_address: fields[0],\n function_data: FunctionData {\n function_selector: fields[1],\n is_internal: fields[2] as bool,\n is_private: fields[3] as bool,\n is_constructor: fields[4] as bool,\n },\n public_inputs: PublicCircuitPublicInputs {\n call_context: CallContext {\n msg_sender : fields[5],\n storage_contract_address : fields[6],\n portal_contract_address : fields[7],\n \n is_delegate_call : fields[8] as bool,\n is_static_call : fields[9] as bool,\n is_contract_deployment: fields[10] as bool,\n },\n args_hash: fields[11],\n return_values: [0; RETURN_VALUES_LENGTH],\n contract_storage_update_requests: [ContractStorageUpdateRequest::empty(); MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL],\n contract_storage_read: [ContractStorageRead::empty(); MAX_PUBLIC_DATA_READS_PER_CALL],\n public_call_stack: [0; MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL],\n new_commitments: [0; MAX_NEW_COMMITMENTS_PER_CALL],\n new_nullifiers: [0; MAX_NEW_NULLIFIERS_PER_CALL],\n new_l2_to_l1_msgs:[0; MAX_NEW_L2_TO_L1_MSGS_PER_CALL],\n unencrypted_logs_hash:[0; NUM_FIELDS_PER_SHA256],\n unencrypted_log_preimages_length: 0,\n block_data: HistoricBlockData::empty(),\n prover_address: 0,\n },\n is_execution_request: true,\n };\n\n assert(contract_address == item.contract_address);\n assert(function_selector == item.function_data.function_selector);\n \n assert(args_hash == item.public_inputs.args_hash);\n\n // Assert that the call context of the enqueued call generated by the oracle matches our request.\n // We are issuing a regular call which is not delegate, static, or deployment. We also constrain\n // the msg_sender in the nested call to be equal to our address, and the execution context address\n // for the nested call to be equal to the address we actually called.\n assert(item.public_inputs.call_context.is_delegate_call == false);\n assert(item.public_inputs.call_context.is_static_call == false);\n assert(item.public_inputs.call_context.is_contract_deployment == false);\n assert(item.public_inputs.call_context.msg_sender == self.inputs.call_context.storage_contract_address);\n assert(item.public_inputs.call_context.storage_contract_address == contract_address);\n\n self.public_call_stack.push(item.hash());\n }\n}\n\nuse crate::abi::{\n ContractStorageRead,\n ContractStorageUpdateRequest\n};\n\nstruct PublicContext {\n inputs: abi::PublicContextInputs,\n\n args_hash : Field,\n return_values : BoundedVec,\n\n contract_storage_update_requests: BoundedVec,\n contract_storage_read: BoundedVec,\n public_call_stack: BoundedVec,\n\n new_commitments: BoundedVec,\n new_nullifiers: BoundedVec,\n\n new_l2_to_l1_msgs: BoundedVec,\n\n unencrypted_logs_hash: BoundedVec,\n unencrypted_logs_preimages_length: Field,\n\n block_data: HistoricBlockData,\n prover_address: Field,\n}\n\nimpl PublicContext {\n fn new(inputs: abi::PublicContextInputs, args_hash: Field) -> PublicContext {\n let empty_storage_read = ContractStorageRead::empty();\n let empty_storage_update = ContractStorageUpdateRequest::empty();\n PublicContext {\n inputs: inputs,\n\n args_hash: args_hash,\n return_values: BoundedVec::new(0),\n\n contract_storage_update_requests: BoundedVec::new(empty_storage_update),\n contract_storage_read: BoundedVec::new(empty_storage_read),\n public_call_stack: BoundedVec::new(0),\n\n new_commitments: BoundedVec::new(0),\n new_nullifiers: BoundedVec::new(0),\n\n new_l2_to_l1_msgs: BoundedVec::new(0),\n\n \n unencrypted_logs_hash: BoundedVec::new(0),\n unencrypted_logs_preimages_length: 0,\n\n block_data: inputs.block_data,\n prover_address: 0,\n\n // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)\n // encrypted_logs_preimages: Vec::new(),\n // unencrypted_logs_preimages: Vec::new(),\n }\n }\n\n fn msg_sender(self) -> Field {\n self.inputs.call_context.msg_sender\n }\n\n fn this_address(self) -> Field {\n self.inputs.call_context.storage_contract_address\n }\n\n fn this_portal_address(self) -> Field {\n self.inputs.call_context.portal_contract_address\n }\n\n fn chain_id(self) -> Field {\n self.inputs.public_global_variables.chain_id\n }\n\n fn version(self) -> Field {\n self.inputs.public_global_variables.version\n }\n\n fn block_number(self) -> Field {\n self.inputs.public_global_variables.block_number\n }\n\n fn timestamp(self) -> Field {\n self.inputs.public_global_variables.timestamp\n }\n\n fn finish(self) -> abi::PublicCircuitPublicInputs {\n // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)\n let unencrypted_logs_hash = [0; NUM_FIELDS_PER_SHA256];\n let unencrypted_log_preimages_length = 0;\n\n\n // Compute the public call stack hashes\n let pub_circuit_pub_inputs = abi::PublicCircuitPublicInputs {\n call_context: self.inputs.call_context, // Done\n args_hash: self.args_hash, // Done\n contract_storage_update_requests: self.contract_storage_update_requests.storage,\n contract_storage_read: self.contract_storage_read.storage,\n return_values: self.return_values.storage,\n new_commitments: self.new_commitments.storage,\n new_nullifiers: self.new_nullifiers.storage,\n public_call_stack: self.public_call_stack.storage,\n new_l2_to_l1_msgs: self.new_l2_to_l1_msgs.storage,\n unencrypted_logs_hash: unencrypted_logs_hash,\n unencrypted_log_preimages_length: unencrypted_log_preimages_length,\n block_data: self.inputs.block_data,\n prover_address: self.prover_address,\n };\n pub_circuit_pub_inputs\n }\n\n fn push_new_note_hash(&mut self, note_hash: Field) {\n self.new_commitments.push(note_hash);\n }\n\n fn push_new_nullifier(&mut self, nullifier: Field, _nullified_commitment: Field) {\n self.new_nullifiers.push(nullifier);\n }\n\n fn message_portal(&mut self, content: Field) {\n self.new_l2_to_l1_msgs.push(content);\n }\n\n // PrivateContextInputs must be temporarily passed in to prevent too many unknowns\n // Note this returns self to get around an issue where mutable structs do not maintain mutations unless reassigned\n fn consume_l1_to_l2_message(&mut self, msg_key: Field, content: Field, secret: Field) {\n let this = (*self).this_address();\n let nullifier = process_l1_to_l2_message(self.block_data.l1_to_l2_messages_tree_root, this, msg_key, content, secret);\n\n // Push nullifier (and the \"commitment\" corresponding to this can be \"empty\")\n self.push_new_nullifier(nullifier, EMPTY_NULLIFIED_COMMITMENT)\n }\n\n fn accumulate_encrypted_logs(&mut self, log: [Field; N]) {\n let _void1 = self;\n let _void2 = log;\n // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)\n }\n\n fn accumulate_unencrypted_logs(&mut self, log: T) {\n let _void1 = self;\n let _void2 = log;\n // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)\n }\n\n fn call_public_function(\n _self: Self,\n contract_address: Field, \n function_selector: Field,\n args: [Field; ARGS_COUNT],\n ) -> [Field; RETURN_VALUES_LENGTH] {\n let args_hash = abi::hash_args(args);\n assert(args_hash == arguments::pack_arguments(args));\n call_public_function_internal(\n contract_address, \n function_selector, \n args_hash,\n )\n }\n\n fn call_public_function_no_args(\n _self: Self,\n contract_address: Field, \n function_selector: Field,\n ) -> [Field; RETURN_VALUES_LENGTH] {\n call_public_function_internal(\n contract_address, \n function_selector, \n 0,\n )\n }\n\n}",
- "path": "/mnt/user-data/lasse/aztec3-packages/yarn-project/noir-libs/noir-aztec/src/context"
+ "path": "/mnt/user-data/jan/aztec-packages/yarn-project/noir-libs/noir-aztec/src/context"
},
"33": {
"source": "use crate::context::PrivateContext;\nuse crate::oracle;\nuse crate::types::point::Point;\n\nfn emit_encrypted_log(\n context: &mut PrivateContext,\n contract_address: Field,\n storage_slot: Field,\n encryption_pub_key: Point,\n log: [Field; N],\n) {\n let _ = oracle::logs::emit_encrypted_log(contract_address, storage_slot, encryption_pub_key, log);\n context.accumulate_encrypted_logs(log);\n}\n\nfn emit_unencrypted_log(\n context: &mut PrivateContext,\n log: T,\n) {\n let _ = oracle::logs::emit_unencrypted_log(log);\n context.accumulate_unencrypted_logs(log);\n}\n",
- "path": "/mnt/user-data/lasse/aztec3-packages/yarn-project/noir-libs/noir-aztec/src/log"
+ "path": "/mnt/user-data/jan/aztec-packages/yarn-project/noir-libs/noir-aztec/src/log"
},
"39": {
"source": "use dep::std::option::Option;\nuse crate::abi::PublicContextInputs;\nuse crate::context::{\n PrivateContext,\n PublicContext,\n};\nuse crate::note::{\n note_header::NoteHeader,\n note_interface::NoteInterface,\n utils::compute_inner_note_hash,\n};\nuse crate::oracle::notes::{notify_created_note, notify_nullified_note};\nuse crate::constants_gen::EMPTY_NULLIFIED_COMMITMENT;\n\nfn create_note(\n context: &mut PrivateContext,\n storage_slot: Field,\n note: &mut Note,\n note_interface: NoteInterface,\n) {\n let contract_address = (*context).this_address();\n\n let header = NoteHeader { contract_address, storage_slot, nonce: 0 };\n let set_header = note_interface.set_header;\n set_header(note, header);\n let inner_note_hash = compute_inner_note_hash(note_interface, *note);\n\n let serialise = note_interface.serialise;\n let preimage = serialise(*note);\n assert(notify_created_note(storage_slot, preimage, inner_note_hash) == 0);\n\n context.push_new_note_hash(inner_note_hash);\n}\n\nfn create_note_hash_from_public(\n context: &mut PublicContext,\n storage_slot: Field,\n note: &mut Note,\n note_interface: NoteInterface,\n) {\n let contract_address = (*context).this_address();\n\n let header = NoteHeader { contract_address, storage_slot, nonce: 0 };\n let set_header = note_interface.set_header;\n set_header(note, header);\n let inner_note_hash = compute_inner_note_hash(note_interface, *note);\n\n context.push_new_note_hash(inner_note_hash);\n}\n\nfn destroy_note(\n context: &mut PrivateContext,\n storage_slot: Field,\n note: Note,\n note_interface: NoteInterface,\n) {\n let mut nullifier = 0;\n let mut nullified_commitment: Field = EMPTY_NULLIFIED_COMMITMENT;\n let compute_nullifier = note_interface.compute_nullifier;\n nullifier = compute_nullifier(note);\n\n let serialise = note_interface.serialise;\n let preimage = serialise(note);\n\n // We also need the note commitment corresponding to the \"nullifier\"\n let get_header = note_interface.get_header;\n let header = get_header(note);\n // 0 nonce implies \"transient\" nullifier (must nullify a commitment in this TX).\n // `nullified_commitment` is used to inform the kernel which pending commitment\n // the nullifier corresponds to so they can be matched and both squashed/deleted.\n // nonzero nonce implies \"persistable\" nullifier (nullifies a persistent/in-tree\n // commitment) in which case `nullified_commitment` is not used since the kernel\n // just siloes and forwards the nullier to its output.\n if (header.nonce == 0) {\n // TODO(suyash): Can we reuse the note commitment computed in `compute_nullifier`?\n nullified_commitment = compute_inner_note_hash(note_interface, note);\n }\n assert(notify_nullified_note(storage_slot, nullifier, preimage, nullified_commitment) == 0);\n\n context.push_new_nullifier(nullifier, nullified_commitment)\n}",
- "path": "/mnt/user-data/lasse/aztec3-packages/yarn-project/noir-libs/noir-aztec/src/note/lifecycle"
+ "path": "/mnt/user-data/jan/aztec-packages/yarn-project/noir-libs/noir-aztec/src/note/lifecycle"
},
"40": {
"source": "use dep::std::option::Option;\nuse crate::constants_gen::{\n MAX_READ_REQUESTS_PER_CALL,\n GET_NOTE_ORACLE_RETURN_LENGTH,\n GET_NOTES_ORACLE_RETURN_LENGTH,\n MAX_NOTES_PER_PAGE,\n VIEW_NOTE_ORACLE_RETURN_LENGTH,\n};\nuse crate::context::PrivateContext;\nuse crate::note::{\n note_getter_options::{NoteGetterOptions, Select, Sort},\n note_interface::NoteInterface,\n note_header::NoteHeader,\n note_viewer_options::NoteViewerOptions,\n utils::compute_note_hash_for_read_or_nullify,\n utils::compute_unique_siloed_note_hash,\n utils::compute_inner_note_hash,\n utils::compute_siloed_note_hash,\n};\nuse crate::messaging::get_commitment_getter_data::make_commitment_getter_data;\nuse crate::oracle;\nuse crate::types::vec::BoundedVec;\n\nfn check_note_header(\n context: PrivateContext,\n storage_slot: Field,\n note_interface: NoteInterface,\n note: Note,\n) {\n let get_header = note_interface.get_header;\n let header = get_header(note);\n let contract_address = context.this_address();\n assert(header.contract_address == contract_address);\n assert(header.storage_slot == storage_slot);\n}\n\nfn ensure_note_exists(\n context: &mut PrivateContext,\n storage_slot: Field,\n note_interface: NoteInterface,\n note: &mut Note,\n) {\n let saved_note = get_note_internal(storage_slot, note_interface);\n\n // Only copy over the header to the original note to make sure the preimage is the same.\n let get_header = note_interface.get_header;\n let set_header = note_interface.set_header;\n let note_header = get_header(saved_note);\n set_header(note, note_header);\n\n check_note_header(*context, storage_slot, note_interface, *note);\n\n let note_hash_for_read_request = compute_note_hash_for_read_or_nullify(note_interface, *note);\n context.push_read_request(note_hash_for_read_request);\n}\n\n// Ensure a note's hash exists in the tree without retrieving the entire\n// notes via the oracle.\n// Modifies the note by populating it with header info.\nfn ensure_note_hash_exists(\n context: &mut PrivateContext,\n storage_slot: Field,\n note_interface: NoteInterface,\n note: &mut Note,\n) {\n // Initialize header of note. Must be done before computing note hashes as it initializes the:\n // - storage slot (used in inner note hash)\n // - the contract address (used in siloed note hash)\n // - and the nonce (used in the unique siloed note hash)\n let set_header = note_interface.set_header;\n let note_header = NoteHeader {\n contract_address: (*context).this_address(),\n // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1386): should be\n // real nonce (once public kernel applies nonces).\n nonce: 0,\n storage_slot\n };\n set_header(note, note_header);\n\n // Get a note from oracle and early out if it doesn't exist.\n let inner_note_hash = compute_inner_note_hash(note_interface, *note);\n\n let raw_oracle_ret = oracle::get_commitment::get_commitment(inner_note_hash);\n let deserialized_oracle_ret = make_commitment_getter_data(raw_oracle_ret, 0);\n // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1386): should be\n // unique_siloed_note_hash once public kernel applies nonces\n let saved_siloed_note_hash = deserialized_oracle_ret.message;\n\n assert(saved_siloed_note_hash != 0); // TODO(dbanks12): necessary?\n\n check_note_header(*context, storage_slot, note_interface, *note);\n\n // Ensure that the note hash retrieved from oracle matches the one computed from note.\n let computed_siloed_note_hash = compute_siloed_note_hash(note_interface, *note);\n // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1386): should be\n // compute_note_hash_for_read_or_nullify once public kernel applies nonces\n assert(computed_siloed_note_hash == saved_siloed_note_hash);\n\n context.push_read_request(computed_siloed_note_hash);\n}\n\nfn get_note(\n context: &mut PrivateContext,\n storage_slot: Field,\n note_interface: NoteInterface,\n) -> Note {\n let note = get_note_internal(storage_slot, note_interface);\n\n check_note_header(*context, storage_slot, note_interface, note);\n\n let note_hash_for_read_request = compute_note_hash_for_read_or_nullify(note_interface, note);\n\n context.push_read_request(note_hash_for_read_request);\n note\n}\n\nfn get_notes(\n context: &mut PrivateContext,\n storage_slot: Field,\n note_interface: NoteInterface,\n options: NoteGetterOptions,\n) -> [Option; MAX_READ_REQUESTS_PER_CALL] {\n let opt_notes = get_notes_internal(storage_slot, note_interface, options);\n for i in 0..opt_notes.len() {\n let opt_note = opt_notes[i];\n let mut note_hash_for_read_request = 0;\n if opt_note.is_some() {\n let note = opt_note.unwrap_unchecked();\n check_note_header(*context, storage_slot, note_interface, note);\n note_hash_for_read_request = compute_note_hash_for_read_or_nullify(note_interface, note);\n };\n // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1410): test to ensure\n // failure if malicious oracle injects 0 nonce here for a \"pre-existing\" note.\n context.push_read_request(note_hash_for_read_request);\n };\n\n // TODO(#1660)\n // Move it back to get_notes_internal and only make read request for selected notes.\n let filter = options.filter;\n let filter_args = options.filter_args;\n filter(opt_notes, filter_args)\n}\n\nunconstrained fn get_note_internal(\n storage_slot: Field,\n note_interface: NoteInterface,\n) -> Note {\n let placeholder_note = [Option::none()];\n let placeholder_fields = [0; GET_NOTE_ORACLE_RETURN_LENGTH];\n oracle::notes::get_notes(\n storage_slot,\n note_interface,\n 0,\n [],\n [],\n [],\n [],\n 1, // limit\n 0, // offset\n placeholder_note,\n placeholder_fields,\n )[0].unwrap() // Notice: we don't allow dummies to be returned from get_note (singular).\n}\n\nunconstrained fn get_notes_internal(\n storage_slot: Field,\n note_interface: NoteInterface,\n options: NoteGetterOptions,\n) -> [Option; MAX_READ_REQUESTS_PER_CALL] {\n let (num_selects, select_by, select_values, sort_by, sort_order) = flatten_options(options.selects, options.sorts);\n let placeholder_opt_notes = [Option::none(); MAX_READ_REQUESTS_PER_CALL];\n let placeholder_fields = [0; GET_NOTES_ORACLE_RETURN_LENGTH];\n oracle::notes::get_notes(\n storage_slot,\n note_interface,\n num_selects,\n select_by,\n select_values,\n sort_by,\n sort_order,\n options.limit,\n options.offset,\n placeholder_opt_notes,\n placeholder_fields,\n )\n}\n\nunconstrained fn view_notes(\n storage_slot: Field,\n note_interface: NoteInterface,\n options: NoteViewerOptions,\n) -> [Option; MAX_NOTES_PER_PAGE] {\n let (num_selects, select_by, select_values, sort_by, sort_order) = flatten_options(options.selects, options.sorts);\n let placeholder_opt_notes = [Option::none(); MAX_NOTES_PER_PAGE];\n let placeholder_fields = [0; VIEW_NOTE_ORACLE_RETURN_LENGTH];\n oracle::notes::get_notes(\n storage_slot,\n note_interface,\n num_selects,\n select_by,\n select_values,\n sort_by,\n sort_order,\n options.limit,\n options.offset,\n placeholder_opt_notes,\n placeholder_fields,\n )\n}\n\nunconstrained fn flatten_options(\n selects: BoundedVec