Skip to content

Commit

Permalink
Use as_array function for slice
Browse files Browse the repository at this point in the history
  • Loading branch information
aajj999 committed May 29, 2024
1 parent 5cb18c3 commit 7e52d4c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
8 changes: 0 additions & 8 deletions ethereum/circuits/lib/src/misc/arrays.nr
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,3 @@ pub fn sub_array_equals<TItem, SUBARRAY_LEN, ARRAY_LEN>(
}
result
}

pub fn slice_to_array<LENGTH>(slice: [u8]) -> [u8; LENGTH] {
let mut array = [0; LENGTH];
for i in 0..LENGTH {
array[i] = slice[i];
}
array
}
4 changes: 2 additions & 2 deletions ethereum/circuits/lib/src/misc/bytes32.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::misc::arrays::{memcpy, slice_to_array};
use crate::misc::arrays::memcpy;
use crate::misc::types::Bytes32;

pub fn address_to_bytes32(address: [u8; 20]) -> Bytes32 {
Expand All @@ -11,5 +11,5 @@ pub fn address_to_bytes32(address: [u8; 20]) -> Bytes32 {

pub fn field_to_bytes32(value: Field) -> [u8; 32] {
let byte_slice = value.to_be_bytes(32);
slice_to_array(byte_slice)
byte_slice.as_array()
}

0 comments on commit 7e52d4c

Please sign in to comment.