Skip to content

Commit 093df0b

Browse files
authored
primefield: use const_prime_monty_params! (#1674)
Uses the built in prime modulus support in `crypto-bigint`. We should be able to further leverage this to replace our modular square root implementation, but for starters this just uses the new macro to define the modulus type/constant.
1 parent adb366b commit 093df0b

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ed448-goldilocks/src/field/scalar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ impl<C: CurveWithScalar> Scalar<C> {
676676

677677
/// Square this scalar
678678
pub const fn square(&self) -> Self {
679-
let value = self.scalar.square_wide();
679+
let value = self.scalar.widening_square();
680680
Self::new(U448::rem_wide_vartime(value, ORDER.as_nz_ref()))
681681
}
682682

primefield/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ keywords = ["crypto", "ecc", "field", "prime"]
1616
edition = "2024"
1717
rust-version = "1.85"
1818

19+
[dependencies.bigint]
20+
version = "0.7.0-rc.28"
21+
package = "crypto-bigint"
22+
default-features = false
23+
features = ["rand_core", "hybrid-array", "subtle"]
24+
1925
[dependencies]
20-
bigint = { package = "crypto-bigint", version = "0.7.0-rc.27", default-features = false, features = ["rand_core", "hybrid-array", "subtle"] }
2126
common = { package = "crypto-common", version = "0.2", features = ["rand_core"] }
2227
ff = { version = "0.14.0-rc.0", package = "rustcrypto-ff", default-features = false }
2328
subtle = { version = "2.6", default-features = false, features = ["const-generics"] }

primefield/src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ macro_rules! monty_field_params {
3737
) => {
3838
use $crate::bigint::modular::ConstMontyParams;
3939

40-
$crate::bigint::const_monty_params!($name, $uint, $modulus_hex, $doc);
40+
$crate::bigint::const_prime_monty_params!($name, $uint, $modulus_hex, $doc);
4141

4242
impl $crate::MontyFieldParams<{ <$uint>::LIMBS }> for $name {
4343
type ByteSize = $crate::bigint::hybrid_array::typenum::U<

0 commit comments

Comments
 (0)