Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p521: Use unsaturated limbs #945

Merged
merged 3 commits into from
Nov 1, 2023
Merged

p521: Use unsaturated limbs #945

merged 3 commits into from
Nov 1, 2023

Conversation

MasterAwesome
Copy link
Contributor

Introduces a function to converts the U576 into a little endian byte array in constant time and uses it for from_uint_unchecked.

Tests:

  • Verified that math on generator such as doubling the point etc returns the expected outputs.

`U576::words()` returns saturated 64-bit limbs but the field
arithmetic for tight points require 59-bit limbs, convert it into a
little endian byte array and let `fiat-crypto` deal with the
unsaturation.

Signed-off-by: Arvind Mukund <[email protected]>
Signed-off-by: Arvind Mukund <[email protected]>

/// Converts the saturated representation [`U576`] into a 528bit array. Each
/// word is copied in little-endian.
pub const fn uint_to_le_bytes_unchecked(w: U576) -> [u8; 66] {
Copy link
Member

Choose a reason for hiding this comment

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

We should probably add some const fn serializers upstream in crypto-bigint that could handle this sort of thing, but this is fine for now.

@tarcieri tarcieri merged commit 1f6eb5b into RustCrypto:master Nov 1, 2023
11 checks passed
@tarcieri
Copy link
Member

tarcieri commented Nov 1, 2023

Thanks! Curious if this might make some of the field arithmetic tests that were failing work.

@tarcieri
Copy link
Member

tarcieri commented Nov 1, 2023

Something else still seems to be amiss: #946

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