Skip to content

ascon: remove byteorder dependency - #37

Merged
tarcieri merged 1 commit into
masterfrom
ascon/remove-byteorder-dependency
Feb 25, 2023
Merged

ascon: remove byteorder dependency#37
tarcieri merged 1 commit into
masterfrom
ascon/remove-byteorder-dependency

Conversation

@tarcieri

Copy link
Copy Markdown
Member

We can use the support in core instead

We can use the support in `core` instead
@tarcieri
tarcieri merged commit 6de759a into master Feb 25, 2023
@tarcieri
tarcieri deleted the ascon/remove-byteorder-dependency branch February 25, 2023 22:49
@tarcieri tarcieri mentioned this pull request Feb 26, 2023
Comment thread ascon/src/util.rs
pub fn u8_to_u64(input: &[u8], output: &mut [u64]) {
for (i, b) in output.iter_mut().enumerate() {
*b = Endian::read_u64(&input[(i * 8)..((i + 1) * 8)]);
*b = u64::from_be_bytes(input[(i * 8)..((i + 1) * 8)].try_into().unwrap());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI you can sue a more idiomatic version:

pub fn u8_to_u64(input: &[u8], output: &mut [u64]) {
    assert_eq!(input.len(), 8 * output.len());
    input
        .chunks_exact(8)
        .map(|c| c.try_into().unwrap())
        .map(u64::from_be_bytes)
        .zip(output.iter_mut())
        .for_each(|(inp, out)| *out = inp)
}

And in future array_chunks can make it even nicer.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants