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

Replace limbs initializer with const from_hex #1702

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

vkrasnov
Copy link
Contributor

@vkrasnov vkrasnov commented Oct 6, 2023

The current macro initializer is not uniform across architectures, and doesn't work when the number of 64bit limbs is not exactly half that of 32bit limbs, (i.e. 521 bit).
This change replaces all limbs! initializers with a new const function with hex string initializers, which is more portable and more ergonomic.

@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

Merging #1702 (9072cb4) into main (244a1de) will decrease coverage by 0.14%.
Report is 79 commits behind head on main.
The diff coverage is 22.58%.

@@            Coverage Diff             @@
##             main    #1702      +/-   ##
==========================================
- Coverage   95.99%   95.85%   -0.14%     
==========================================
  Files         134      135       +1     
  Lines       19980    19982       +2     
  Branches      199      199              
==========================================
- Hits        19179    19154      -25     
- Misses        765      791      +26     
- Partials       36       37       +1     
Files Coverage Δ
src/ec/curve25519/scalar.rs 100.00% <100.00%> (ø)
src/ec/suite_b/ops.rs 98.05% <ø> (ø)
src/ec/suite_b/ops/p256.rs 100.00% <100.00%> (ø)
src/ec/suite_b/ops/p384.rs 100.00% <100.00%> (ø)
src/ec/suite_b/ops/elem.rs 88.40% <0.00%> (-9.99%) ⬇️
src/arithmetic/constant.rs 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

The current macro initializer is not uniform across architectures,
and doesn't work when the number of 64bit limbs is not exactly half
that of 32bit limbs, (i.e. 521 bit).
This change replaces all limbs! initializers with a new const
function with hex string initializers, which is more portable and
more ergonomic.
n: Elem::from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),
a: Elem::from_hex("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffffffc0000000000000003fffffffc"),
b: Elem::from_hex("cd08114b604fbff9b62b21f41f022094e3374bee94938ae277f2209b1920022ef729add87a4c32ec081188719d412dcc")
,
Copy link
Owner

Choose a reason for hiding this comment

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

This comma shouldn't be on its own line; it should be at the end of the line above. I will fix this after I merge this.

0x19b409a9, 0x2d319b24, 0xdf1aa419, 0xff3d81e5, 0xfcb82947, 0xbc3e483a, 0x4aab1cc5, 0xd40d4917,
0x28266895, 0x3fb05b7a, 0x2b39bf21, 0x0c84ee01
];
const N_RR_HEX: &str = "0c84ee012b39bf213fb05b7a28266895d40d49174aab1cc5bc3e483afcb82947ff3d81e5df1aa4192d319b2419b409a9";
Copy link
Owner

Choose a reason for hiding this comment

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

This doesn't need to have the leading zero, right? I will fix this after I merge it.

@briansmith briansmith merged commit 20672b2 into briansmith:main Oct 17, 2023
138 of 140 checks passed
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