diff --git a/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr b/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr index a25b24cd650a..9b01e250deae 100644 --- a/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr +++ b/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr @@ -14,12 +14,18 @@ pub fn get_mint_to_public_content_hash(owner: AztecAddress, amount: Field) -> Fi hash_bytes[i + 36] = amount_bytes[i]; } - let selector = comptime { std::hash::keccak256("mint_to_public(bytes32,uint256)".as_bytes(), 24) }; + // Function selector: 0xbc6a9bd3 keccak256('mint_to_public(bytes32,uint256)') + hash_bytes[0] = 0xbc; + hash_bytes[1] = 0x6a; + hash_bytes[2] = 0x9b; + hash_bytes[3] = 0xd3; - hash_bytes[0] = selector[0]; - hash_bytes[1] = selector[1]; - hash_bytes[2] = selector[2]; - hash_bytes[3] = selector[3]; + // let selector = comptime { std::hash::keccak256("mint_to_public(bytes32,uint256)".as_bytes(), 24) }; + + // hash_bytes[0] = selector[0]; + // hash_bytes[1] = selector[1]; + // hash_bytes[2] = selector[2]; + // hash_bytes[3] = selector[3]; let content_hash = sha256_to_field(hash_bytes); content_hash @@ -39,12 +45,25 @@ pub fn get_mint_to_private_content_hash( hash_bytes[i + 4] = amount_bytes[i]; } + // Function selector: 0x8b3af5e8 keccak256('mint_to_private(uint256)') + hash_bytes[0] = 0x8b; + hash_bytes[1] = 0x3a; + hash_bytes[2] = 0xf5; + hash_bytes[3] = 0xe8; + let selector = comptime { std::hash::keccak256("mint_to_private(uint256)".as_bytes(), 24) }; - hash_bytes[0] = selector[0]; - hash_bytes[1] = selector[1]; - hash_bytes[2] = selector[2]; - hash_bytes[3] = selector[3]; + dep::aztec::oracle::debug_log::debug_log_format("snek: {0}, {1}, {2}, {3}", [selector[0] as Field, selector[1] as Field, selector[2] as Field, selector[3] as Field]); + + // assert(selector[0] == hash_bytes[0]); + // assert(selector[1] == hash_bytes[1]); + // assert(selector[2] == hash_bytes[2]); + // assert(selector[3] == hash_bytes[3]); + + // hash_bytes[0] = selector[0]; + // hash_bytes[1] = selector[1]; + // hash_bytes[2] = selector[2]; + // hash_bytes[3] = selector[3]; let content_hash = sha256_to_field(hash_bytes); content_hash @@ -63,12 +82,18 @@ pub fn get_withdraw_content_hash(recipient: EthAddress, amount: Field, caller_on let amount_bytes: [u8; 32] = amount.to_be_bytes(); let caller_on_l1_bytes: [u8; 32] = caller_on_l1.to_field().to_be_bytes(); - let selector = comptime { std::hash::keccak256("withdraw(address,uint256,address)".as_bytes(), 24) }; + // 0x69328dec, selector for "withdraw(address,uint256,address)" + hash_bytes[0] = 0x69; + hash_bytes[1] = 0x32; + hash_bytes[2] = 0x8d; + hash_bytes[3] = 0xec; + + // let selector = comptime { std::hash::keccak256("withdraw(address,uint256,address)".as_bytes(), 24) }; - hash_bytes[0] = selector[0]; - hash_bytes[1] = selector[1]; - hash_bytes[2] = selector[2]; - hash_bytes[3] = selector[3]; + // hash_bytes[0] = selector[0]; + // hash_bytes[1] = selector[1]; + // hash_bytes[2] = selector[2]; + // hash_bytes[3] = selector[3]; for i in 0..32 { hash_bytes[i + 4] = recipient_bytes[i]; diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts index b55cedc1e025..de5f34526be0 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts @@ -45,7 +45,7 @@ describe('e2e_cross_chain_messaging token_bridge_private', () => { }); // docs:start:e2e_private_cross_chain - it('Privately deposit funds from L1 -> L2 and withdraw back to L1', async () => { + it.only('Privately deposit funds from L1 -> L2 and withdraw back to L1', async () => { // Generate a claim secret using pedersen const l1TokenBalance = 1000000n; const bridgeAmount = 100n;