mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-23 03:59:22 +00:00
Update crypto-bigint to 0.5
This commit is contained in:
parent
f2218b4d4e
commit
9952c67d98
5 changed files with 25 additions and 20 deletions
19
Cargo.lock
generated
19
Cargo.lock
generated
|
@ -1488,6 +1488,17 @@ dependencies = [
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crypto-bigint"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7c2538c4e68e52548bacb3e83ac549f903d44f011ac9d5abb5e132e67d0808f7"
|
||||||
|
dependencies = [
|
||||||
|
"rand_core 0.6.4",
|
||||||
|
"subtle",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crypto-common"
|
name = "crypto-common"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
|
@ -1626,7 +1637,7 @@ dependencies = [
|
||||||
name = "dalek-ff-group"
|
name = "dalek-ff-group"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crypto-bigint",
|
"crypto-bigint 0.5.1",
|
||||||
"curve25519-dalek 3.2.0",
|
"curve25519-dalek 3.2.0",
|
||||||
"digest 0.10.6",
|
"digest 0.10.6",
|
||||||
"ff",
|
"ff",
|
||||||
|
@ -2089,7 +2100,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3"
|
checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base16ct",
|
"base16ct",
|
||||||
"crypto-bigint",
|
"crypto-bigint 0.4.9",
|
||||||
"der",
|
"der",
|
||||||
"digest 0.10.6",
|
"digest 0.10.6",
|
||||||
"ff",
|
"ff",
|
||||||
|
@ -4925,7 +4936,7 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
|
||||||
name = "minimal-ed448"
|
name = "minimal-ed448"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crypto-bigint",
|
"crypto-bigint 0.5.1",
|
||||||
"dalek-ff-group",
|
"dalek-ff-group",
|
||||||
"ff",
|
"ff",
|
||||||
"ff-group-tests",
|
"ff-group-tests",
|
||||||
|
@ -6869,7 +6880,7 @@ version = "0.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb"
|
checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crypto-bigint",
|
"crypto-bigint 0.4.9",
|
||||||
"hmac 0.12.1",
|
"hmac 0.12.1",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
|
@ -22,7 +22,7 @@ subtle = "^2.4"
|
||||||
ff = { version = "0.12", features = ["bits"] }
|
ff = { version = "0.12", features = ["bits"] }
|
||||||
group = "0.12"
|
group = "0.12"
|
||||||
|
|
||||||
crypto-bigint = "0.4"
|
crypto-bigint = "0.5"
|
||||||
|
|
||||||
sha2 = "0.9"
|
sha2 = "0.9"
|
||||||
curve25519-dalek = "^3.2"
|
curve25519-dalek = "^3.2"
|
||||||
|
|
|
@ -8,7 +8,7 @@ use subtle::{
|
||||||
ConditionallySelectable,
|
ConditionallySelectable,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crypto_bigint::{Integer, Encoding, U256, U512};
|
use crypto_bigint::{Integer, NonZero, Encoding, U256, U512};
|
||||||
|
|
||||||
use group::ff::{Field, PrimeField, FieldBits, PrimeFieldBits};
|
use group::ff::{Field, PrimeField, FieldBits, PrimeFieldBits};
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ const MOD_3_8: FieldElement =
|
||||||
const MOD_5_8: FieldElement = FieldElement(MOD_3_8.0.saturating_sub(&U256::ONE));
|
const MOD_5_8: FieldElement = FieldElement(MOD_3_8.0.saturating_sub(&U256::ONE));
|
||||||
|
|
||||||
fn reduce(x: U512) -> U256 {
|
fn reduce(x: U512) -> U256 {
|
||||||
U256::from_le_slice(&x.reduce(&WIDE_MODULUS).unwrap().to_le_bytes()[.. 32])
|
U256::from_le_slice(&x.rem(&NonZero::new(WIDE_MODULUS).unwrap()).to_le_bytes()[.. 32])
|
||||||
}
|
}
|
||||||
|
|
||||||
constant_time!(FieldElement, U256);
|
constant_time!(FieldElement, U256);
|
||||||
|
@ -87,10 +87,7 @@ math!(
|
||||||
FieldElement,
|
FieldElement,
|
||||||
|x, y| U256::add_mod(&x, &y, &MODULUS),
|
|x, y| U256::add_mod(&x, &y, &MODULUS),
|
||||||
|x, y| U256::sub_mod(&x, &y, &MODULUS),
|
|x, y| U256::sub_mod(&x, &y, &MODULUS),
|
||||||
|x, y| {
|
|x, y| reduce(U512::from(U256::mul_wide(&x, &y)))
|
||||||
let wide = U256::mul_wide(&x, &y);
|
|
||||||
reduce(U512::from((wide.1, wide.0)))
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
from_uint!(FieldElement, U256);
|
from_uint!(FieldElement, U256);
|
||||||
|
|
||||||
|
@ -125,7 +122,7 @@ impl Field for FieldElement {
|
||||||
FieldElement(reduce(self.0.square()))
|
FieldElement(reduce(self.0.square()))
|
||||||
}
|
}
|
||||||
fn double(&self) -> Self {
|
fn double(&self) -> Self {
|
||||||
FieldElement((self.0 << 1).reduce(&MODULUS).unwrap())
|
FieldElement((self.0 << 1).rem(&NonZero::new(MODULUS).unwrap()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn invert(&self) -> CtOption<Self> {
|
fn invert(&self) -> CtOption<Self> {
|
||||||
|
|
|
@ -24,7 +24,7 @@ ff = { version = "0.12", features = ["bits"] }
|
||||||
group = "0.12"
|
group = "0.12"
|
||||||
|
|
||||||
generic-array = "0.14"
|
generic-array = "0.14"
|
||||||
crypto-bigint = { version = "0.4", features = ["zeroize"] }
|
crypto-bigint = { version = "0.5", features = ["zeroize"] }
|
||||||
|
|
||||||
dalek-ff-group = { path = "../dalek-ff-group", version = "0.2" }
|
dalek-ff-group = { path = "../dalek-ff-group", version = "0.2" }
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ macro_rules! field {
|
||||||
use rand_core::RngCore;
|
use rand_core::RngCore;
|
||||||
|
|
||||||
use generic_array::{typenum::U57, GenericArray};
|
use generic_array::{typenum::U57, GenericArray};
|
||||||
use crypto_bigint::{Integer, Encoding};
|
use crypto_bigint::{Integer, NonZero, Encoding};
|
||||||
|
|
||||||
use group::ff::{Field, PrimeField, FieldBits, PrimeFieldBits};
|
use group::ff::{Field, PrimeField, FieldBits, PrimeFieldBits};
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ macro_rules! field {
|
||||||
use $crate::backend::u8_from_bool;
|
use $crate::backend::u8_from_bool;
|
||||||
|
|
||||||
fn reduce(x: U1024) -> U512 {
|
fn reduce(x: U1024) -> U512 {
|
||||||
U512::from_le_slice(&x.reduce(&$WIDE_MODULUS).unwrap().to_le_bytes()[.. 64])
|
U512::from_le_slice(&x.rem(&NonZero::new($WIDE_MODULUS).unwrap()).to_le_bytes()[.. 64])
|
||||||
}
|
}
|
||||||
|
|
||||||
constant_time!($FieldName, U512);
|
constant_time!($FieldName, U512);
|
||||||
|
@ -54,10 +54,7 @@ macro_rules! field {
|
||||||
$FieldName,
|
$FieldName,
|
||||||
|x, y| U512::add_mod(&x, &y, &$MODULUS.0),
|
|x, y| U512::add_mod(&x, &y, &$MODULUS.0),
|
||||||
|x, y| U512::sub_mod(&x, &y, &$MODULUS.0),
|
|x, y| U512::sub_mod(&x, &y, &$MODULUS.0),
|
||||||
|x, y| {
|
|x, y| reduce(U1024::from(U512::mul_wide(&x, &y)))
|
||||||
let wide = U512::mul_wide(&x, &y);
|
|
||||||
reduce(U1024::from((wide.1, wide.0)))
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
from_uint!($FieldName, U512);
|
from_uint!($FieldName, U512);
|
||||||
|
|
||||||
|
@ -122,7 +119,7 @@ macro_rules! field {
|
||||||
*self * self
|
*self * self
|
||||||
}
|
}
|
||||||
fn double(&self) -> Self {
|
fn double(&self) -> Self {
|
||||||
$FieldName((self.0 << 1).reduce(&$MODULUS.0).unwrap())
|
$FieldName((self.0 << 1).rem(&NonZero::new($MODULUS.0).unwrap()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn invert(&self) -> CtOption<Self> {
|
fn invert(&self) -> CtOption<Self> {
|
||||||
|
|
Loading…
Reference in a new issue