diff --git a/crates/nargo_cli/tests/test_data_ssa_refactor/to_le_bytes/src/main.nr b/crates/nargo_cli/tests/test_data_ssa_refactor/to_le_bytes/src/main.nr index a5476ec13bf..8703c18bb0a 100644 --- a/crates/nargo_cli/tests/test_data_ssa_refactor/to_le_bytes/src/main.nr +++ b/crates/nargo_cli/tests/test_data_ssa_refactor/to_le_bytes/src/main.nr @@ -7,8 +7,12 @@ fn main(x : Field) -> pub [u8; 4] { for i in 0..4 { first_four_bytes[i] = byte_array[i]; } + + let chash = std::hash::keccak256(x.to_le_bytes(8), 8); + assert(chash[0] > 0 | chash[1] > 0); + // Issue #617 fix // We were incorrectly mapping our output array from bit decomposition functions during acir generation first_four_bytes[3] = byte_array[31]; first_four_bytes -} +} \ No newline at end of file diff --git a/noir_stdlib/src/hash.nr b/noir_stdlib/src/hash.nr index e5dbdadaf7f..67fff28a13a 100644 --- a/noir_stdlib/src/hash.nr +++ b/noir_stdlib/src/hash.nr @@ -1,30 +1,30 @@ mod poseidon; #[foreign(sha256)] -fn sha256(_input : [u8; N]) -> [u8; 32] {} +fn sha256(_input : [u8]) -> [u8; 32] {} #[foreign(blake2s)] -fn blake2s(_input : [u8; N]) -> [u8; 32] {} +fn blake2s(_input : [u8]) -> [u8; 32] {} -fn pedersen(input : [Field; N]) -> [Field; 2] { +fn pedersen(input : [Field]) -> [Field; 2] { pedersen_with_separator(input, 0) } #[foreign(pedersen)] -fn pedersen_with_separator(_input : [Field; N], _separator : comptime u32) -> [Field; 2] {} +fn pedersen_with_separator(_input : [Field], _separator : comptime u32) -> [Field; 2] {} #[foreign(hash_to_field_128_security)] -fn hash_to_field(_input : [Field; N]) -> Field {} +fn hash_to_field(_input : [Field]) -> Field {} #[foreign(keccak256)] -fn keccak256(_input : [u8; N], _message_size: u32) -> [u8; 32] {} +fn keccak256(_input : [u8], _message_size: u32) -> [u8; 32] {} // mimc-p/p implementation // constants are (publicly generated) random numbers, for instance using keccak as a ROM. // You must use constants generated for the native field // Rounds number should be ~ log(p)/log(exp) // For 254 bit primes, exponent 7 and 91 rounds seems to be recommended -fn mimc(x: Field, k: Field, constants: [Field; N], exp : Field) -> Field { +fn mimc(x: Field, k: Field, constants: [Field], exp : Field) -> Field { //round 0 let mut t = x + k; let mut h = t.pow_32(exp); @@ -39,7 +39,7 @@ fn mimc(x: Field, k: Field, constants: [Field; N], exp : Field) -> Field { global MIMC_BN254_ROUNDS = 91; //mimc implementation with hardcoded parameters for BN254 curve. -fn mimc_bn254(array: [Field; N]) -> Field { +fn mimc_bn254(array: [Field]) -> Field { //mimc parameters let exponent = 7; //generated from seed "mimc" using keccak256 diff --git a/noir_stdlib/src/lib.nr b/noir_stdlib/src/lib.nr index f6c01ecdfaa..76ebdb7b100 100644 --- a/noir_stdlib/src/lib.nr +++ b/noir_stdlib/src/lib.nr @@ -18,7 +18,7 @@ mod compat; // Oracle calls are required to be wrapped in an unconstrained function // Thus, the only argument to the `println` oracle is expected to always be an ident #[oracle(println)] -unconstrained fn println_oracle(_input: T) {} +unconstrained fn println_oracle(_input: T) {} unconstrained fn println(input: T) { println_oracle(input); diff --git a/noir_stdlib/src/sha256.nr b/noir_stdlib/src/sha256.nr index 63107442bf8..c6cdf2d6057 100644 --- a/noir_stdlib/src/sha256.nr +++ b/noir_stdlib/src/sha256.nr @@ -99,7 +99,7 @@ fn msg_u8_to_u32(msg: [u8; 64]) -> [u32; 16] } // SHA-256 hash function -fn digest(msg: [u8; N]) -> [u8; 32] { +fn digest(msg: [u8]) -> [u8; 32] { let mut msg_block: [u8; 64] = [0; 64]; let mut h: [u32; 8] = [1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]; // Intermediate hash, starting with the canonical initial value let mut c: [u32; 8] = [0; 8]; // Compression of current message block as sequence of u32 diff --git a/noir_stdlib/src/sha512.nr b/noir_stdlib/src/sha512.nr index 1617af8e598..6093e5eb194 100644 --- a/noir_stdlib/src/sha512.nr +++ b/noir_stdlib/src/sha512.nr @@ -98,7 +98,7 @@ fn msg_u8_to_u64(msg: [u8; 128]) -> [u64; 16] } // SHA-512 hash function -fn digest(msg: [u8; N]) -> [u8; 64] +fn digest(msg: [u8]) -> [u8; 64] { let mut msg_block: [u8; 128] = [0; 128]; let mut h: [u64; 8] = [7640891576956012808, 13503953896175478587, 4354685564936845355, 11912009170470909681, 5840696475078001361, 11170449401992604703, 2270897969802886507, 6620516959819538809]; // Intermediate hash, starting with the canonical initial value