Skip to content

Commit

Permalink
Merge 50a5069 into b70a728
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanks12 authored Sep 30, 2024
2 parents b70a728 + 50a5069 commit c02268f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{hash::pedersen_hash, traits::ToField};
use crate::{hash::poseidon2_hash, traits::ToField};

pub fn derive_storage_slot_in_map<K>(storage_slot: Field, key: K) -> Field where K: ToField {
pedersen_hash([storage_slot, key.to_field()], 0)
poseidon2_hash([storage_slot, key.to_field()])
}

mod test {
Expand All @@ -15,7 +15,7 @@ mod test {
let slot = derive_storage_slot_in_map(map_slot, key);

// The following value was generated by `map_slot.test.ts`
let slot_from_typescript = 0x2499880e2b1b831785c17286f99a0d5122fee784ce7b1c04e380c4a991da819a;
let slot_from_typescript = 0x15b9fe39449affd8b377461263e9d2b610b9ad40580553500b4e41d9cbd887ac;

assert_eq(slot, slot_from_typescript);
}
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/hash/map_slot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Map slot', () => {
const slot = deriveStorageSlotInMap(mapSlot, key);

expect(slot.toString()).toMatchInlineSnapshot(
`"0x2499880e2b1b831785c17286f99a0d5122fee784ce7b1c04e380c4a991da819a"`,
`"0x15b9fe39449affd8b377461263e9d2b610b9ad40580553500b4e41d9cbd887ac"`,
);

// Run with AZTEC_GENERATE_TEST_DATA=1 to update noir test data
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/circuits.js/src/hash/map_slot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pedersenHash } from '@aztec/foundation/crypto';
import { poseidon2Hash } from '@aztec/foundation/crypto';
import { type Fr } from '@aztec/foundation/fields';

/**
Expand All @@ -14,5 +14,5 @@ export function deriveStorageSlotInMap(
toField: () => Fr;
},
): Fr {
return pedersenHash([mapSlot, key.toField()]);
return poseidon2Hash([mapSlot, key.toField()]);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Tx, mockTx } from '@aztec/circuit-types';
import { AztecAddress, Fr, FunctionSelector, GasSettings } from '@aztec/circuits.js';
import { pedersenHash } from '@aztec/foundation/crypto';
import { poseidon2Hash } from '@aztec/foundation/crypto';
import { FeeJuiceContract } from '@aztec/noir-contracts.js';
import { FeeJuiceAddress } from '@aztec/protocol-contracts/fee-juice';

Expand Down Expand Up @@ -37,7 +37,7 @@ describe('GasTxValidator', () => {
inclusionFee: new Fr(TX_FEE),
});
payer = tx.data.feePayer;
expectedBalanceSlot = pedersenHash([FeeJuiceContract.storage.balances.slot, payer]);
expectedBalanceSlot = poseidon2Hash([FeeJuiceContract.storage.balances.slot, payer]);

expect(tx.data.constants.txContext.gasSettings.getFeeLimit()).toEqual(new Fr(TX_FEE));
});
Expand Down

0 comments on commit c02268f

Please sign in to comment.