mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-04 20:03:39 +00:00
Remove FieldExt::from_u64
This commit is contained in:
parent
11c5ddbc02
commit
ad0360bc1c
4 changed files with 7 additions and 17 deletions
|
|
@ -18,6 +18,7 @@ and this project adheres to Rust's notion of
|
|||
- `FieldExt::{T_MINUS1_OVER2, pow_by_t_minus1_over2, sqrt_alt, sqrt_ratio}`
|
||||
(moved to `SqrtRatio` trait).
|
||||
- `FieldExt::{RESCUE_ALPHA, RESCUE_INVALPHA}`
|
||||
- `FieldExt::from_u64` (use `From<u64> for ff::PrimeField` instead).
|
||||
|
||||
## [0.2.1] - 2021-09-17
|
||||
### Changed
|
||||
|
|
|
|||
|
|
@ -82,9 +82,6 @@ pub trait FieldExt: SqrtRatio + From<bool> + Ord + Group<Scalar = Self> {
|
|||
Self::random(rand::rngs::OsRng)
|
||||
}
|
||||
|
||||
/// Obtains a field element congruent to the integer `v`.
|
||||
fn from_u64(v: u64) -> Self;
|
||||
|
||||
/// Obtains a field element congruent to the integer `v`.
|
||||
fn from_u128(v: u128) -> Self;
|
||||
|
||||
|
|
|
|||
|
|
@ -737,10 +737,6 @@ impl FieldExt for Fp {
|
|||
0x12ccca834acdba71,
|
||||
]);
|
||||
|
||||
fn from_u64(v: u64) -> Self {
|
||||
Fp::from_raw([v as u64, 0, 0, 0])
|
||||
}
|
||||
|
||||
fn from_u128(v: u128) -> Self {
|
||||
Fp::from_raw([v as u64, (v >> 64) as u64, 0, 0])
|
||||
}
|
||||
|
|
@ -821,9 +817,9 @@ fn test_pow_by_t_minus1_over2() {
|
|||
fn test_sqrt_ratio_and_alt() {
|
||||
// (true, sqrt(num/div)), if num and div are nonzero and num/div is a square in the field
|
||||
let num = (Fp::TWO_INV).square();
|
||||
let div = Fp::from_u64(25);
|
||||
let div = Fp::from(25);
|
||||
let div_inverse = div.invert().unwrap();
|
||||
let expected = Fp::TWO_INV * Fp::from_u64(5).invert().unwrap();
|
||||
let expected = Fp::TWO_INV * Fp::from(5).invert().unwrap();
|
||||
let (is_square, v) = Fp::sqrt_ratio(&num, &div);
|
||||
assert!(bool::from(is_square));
|
||||
assert!(v == expected || (-v) == expected);
|
||||
|
|
@ -834,7 +830,7 @@ fn test_sqrt_ratio_and_alt() {
|
|||
|
||||
// (false, sqrt(ROOT_OF_UNITY * num/div)), if num and div are nonzero and num/div is a nonsquare in the field
|
||||
let num = num * Fp::root_of_unity();
|
||||
let expected = Fp::TWO_INV * Fp::root_of_unity() * Fp::from_u64(5).invert().unwrap();
|
||||
let expected = Fp::TWO_INV * Fp::root_of_unity() * Fp::from(5).invert().unwrap();
|
||||
let (is_square, v) = Fp::sqrt_ratio(&num, &div);
|
||||
assert!(!bool::from(is_square));
|
||||
assert!(v == expected || (-v) == expected);
|
||||
|
|
|
|||
|
|
@ -737,10 +737,6 @@ impl FieldExt for Fq {
|
|||
0x06819a58283e528e,
|
||||
]);
|
||||
|
||||
fn from_u64(v: u64) -> Self {
|
||||
Fq::from_raw([v as u64, 0, 0, 0])
|
||||
}
|
||||
|
||||
fn from_u128(v: u128) -> Self {
|
||||
Fq::from_raw([v as u64, (v >> 64) as u64, 0, 0])
|
||||
}
|
||||
|
|
@ -821,9 +817,9 @@ fn test_pow_by_t_minus1_over2() {
|
|||
fn test_sqrt_ratio_and_alt() {
|
||||
// (true, sqrt(num/div)), if num and div are nonzero and num/div is a square in the field
|
||||
let num = (Fq::TWO_INV).square();
|
||||
let div = Fq::from_u64(25);
|
||||
let div = Fq::from(25);
|
||||
let div_inverse = div.invert().unwrap();
|
||||
let expected = Fq::TWO_INV * Fq::from_u64(5).invert().unwrap();
|
||||
let expected = Fq::TWO_INV * Fq::from(5).invert().unwrap();
|
||||
let (is_square, v) = Fq::sqrt_ratio(&num, &div);
|
||||
assert!(bool::from(is_square));
|
||||
assert!(v == expected || (-v) == expected);
|
||||
|
|
@ -834,7 +830,7 @@ fn test_sqrt_ratio_and_alt() {
|
|||
|
||||
// (false, sqrt(ROOT_OF_UNITY * num/div)), if num and div are nonzero and num/div is a nonsquare in the field
|
||||
let num = num * Fq::root_of_unity();
|
||||
let expected = Fq::TWO_INV * Fq::root_of_unity() * Fq::from_u64(5).invert().unwrap();
|
||||
let expected = Fq::TWO_INV * Fq::root_of_unity() * Fq::from(5).invert().unwrap();
|
||||
let (is_square, v) = Fq::sqrt_ratio(&num, &div);
|
||||
assert!(!bool::from(is_square));
|
||||
assert!(v == expected || (-v) == expected);
|
||||
|
|
|
|||
Loading…
Reference in a new issue