Skip to content
Merged
2 changes: 2 additions & 0 deletions yarn-project/circuits.js/src/structs/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ export const ROLLUP_VK_TREE_HEIGHT = 8;

export const FUNCTION_SELECTOR_NUM_BYTES = 4;

export const MAPPING_SLOT_PEDERSEN_SEPARATOR = 4;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a place perhaps from cpp/bberg from where we are getting this value from? Maybe add a link to that there if in future we change this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is from the constants.hpp file that this file already shadows


// sha256 hash is stored in two fields to accommodate all 256-bits of the hash
export const NUM_FIELDS_PER_SHA256 = 2;
7 changes: 4 additions & 3 deletions yarn-project/end-to-end/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
import { DebugLogger, Logger, createDebugLogger } from '@aztec/foundation/log';
import { Fr } from '@aztec/foundation/fields';
import { MAPPING_SLOT_PEDERSEN_SEPARATOR } from '@aztec/circuits.js';

import {
AztecAddress,
Expand Down Expand Up @@ -244,15 +245,15 @@ export function delay(ms: number): Promise<void> {
*/
export async function calculateStorageSlot(slot: bigint, key: Fr): Promise<Fr> {
const wasm = await CircuitsWasm.get();
const balancesStorageSlot = new Fr(slot); // this value is manually set in the Noir contract
const mappingStorageSlot = new Fr(4n); // The pedersen domain separator for storage slot calculations.
const mappingStorageSlot = new Fr(slot); // this value is manually set in the Noir contract
const mappingStorageSlotSeparator = new Fr(BigInt(MAPPING_SLOT_PEDERSEN_SEPARATOR)); // The pedersen domain separator for storage slot calculations.

// Based on `at` function in
// aztec3-packages/yarn-project/noir-contracts/src/contracts/noir-aztec/src/state_vars/map.nr
const storageSlot = Fr.fromBuffer(
pedersenPlookupCommitInputs(
wasm,
[mappingStorageSlot, balancesStorageSlot, key].map(f => f.toBuffer()),
[mappingStorageSlotSeparator, mappingStorageSlot, key].map(f => f.toBuffer()),
),
);

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/noir-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ This package contains the source code and the Aztec ABIs for the example contrac
compiler_version = "0.7.1"

[dependencies]
aztec = { path = "../noir-aztec" }
aztec = { path = "../../libs/noir-aztec" }
```

4. Replace the content of the generated `example_contract/src/main.nr` file with your contract code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ authors = [""]
compiler_version = "0.1"

[dependencies]
aztec = { path = "../noir-aztec" }
aztec = { path = "../../libs/noir-aztec" }
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ authors = [""]
compiler_version = "0.1"

[dependencies]
aztec = { path = "../noir-aztec" }
aztec = { path = "../../libs/noir-aztec" }
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ authors = [""]
compiler_version = "0.1"

[dependencies]
aztec = { path = "../noir-aztec" }
aztec = { path = "../../libs/noir-aztec" }
Loading