Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Apr 12, 2024
1 parent 8f97144 commit a83c8d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
5 changes: 2 additions & 3 deletions yarn-project/foundation/src/crypto/poseidon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import { type Fieldable, serializeToFields } from '../../serialize/serialize.js'
/**
* Create a poseidon hash (field) from an array of input fields.
* @param input - The input fields to hash.
* @param index - The separator index to use for the hash.
* @returns The poseidon hash.
*/
export function poseidon2Hash(input: Fieldable[], index = 0): Fr {
const inputFields = serializeToFields([input, index]);
export function poseidon2Hash(input: Fieldable[]): Fr {
const inputFields = serializeToFields(input);
return Fr.fromBuffer(
Buffer.from(
BarretenbergSync.getSingleton()
Expand Down
16 changes: 7 additions & 9 deletions yarn-project/key-store/src/new_test_key_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,18 @@ export class NewTestKeyStore implements NewKeyStore {
const masterTaggingPublicKey = this.curve.mul(this.curve.generator(), masterTaggingSecretKey);

// We hash the public keys to get the public keys hash
const publicKeysHash = poseidon2Hash(
[
masterNullifierPublicKey,
masterIncomingViewingPublicKey,
masterOutgoingViewingPublicKey,
masterTaggingPublicKey,
],
const publicKeysHash = poseidon2Hash([
masterNullifierPublicKey,
masterIncomingViewingPublicKey,
masterOutgoingViewingPublicKey,
masterTaggingPublicKey,
GeneratorIndex.PUBLIC_KEYS_HASH,
);
]);

// We hash the partial address and the public keys hash to get the account address
// TODO(#5726): Should GeneratorIndex.CONTRACT_ADDRESS be removed given that we introduced CONTRACT_ADDRESS_V1?
// TODO(#5726): Move the following line to AztecAddress class?
const accountAddressFr = poseidon2Hash([partialAddress, publicKeysHash], GeneratorIndex.CONTRACT_ADDRESS_V1);
const accountAddressFr = poseidon2Hash([partialAddress, publicKeysHash, GeneratorIndex.CONTRACT_ADDRESS_V1]);
const accountAddress = AztecAddress.fromField(accountAddressFr);

// We store the keys in the database
Expand Down

0 comments on commit a83c8d0

Please sign in to comment.