Skip to content

Commit

Permalink
Merge 0c1b46a into e335c48
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan authored Nov 13, 2024
2 parents e335c48 + 0c1b46a commit 5486a0e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5486a0e

Please sign in to comment.