mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-08 20:09:54 +00:00
Bump dalek-ff-group version
This commit is contained in:
parent
a2aa182cc4
commit
c53e7ad6c7
3 changed files with 7 additions and 10 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1378,7 +1378,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dalek-ff-group"
|
name = "dalek-ff-group"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crypto-bigint",
|
"crypto-bigint",
|
||||||
"curve25519-dalek 3.2.0",
|
"curve25519-dalek 3.2.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "dalek-ff-group"
|
name = "dalek-ff-group"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
description = "ff/group bindings around curve25519-dalek"
|
description = "ff/group bindings around curve25519-dalek"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/serai-dex/serai"
|
repository = "https://github.com/serai-dex/serai"
|
||||||
|
|
|
@ -165,27 +165,24 @@ impl FieldElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sqrt_ratio_i(u: FieldElement, v: FieldElement) -> (Choice, FieldElement) {
|
pub fn sqrt_ratio_i(u: FieldElement, v: FieldElement) -> (Choice, FieldElement) {
|
||||||
|
let i = SQRT_M1;
|
||||||
|
|
||||||
let v3 = v.square() * v;
|
let v3 = v.square() * v;
|
||||||
let v7 = v3.square() * v;
|
let v7 = v3.square() * v;
|
||||||
let mut r = (u * v3) *
|
let mut r = (u * v3) *
|
||||||
(u * v7).pow((-FieldElement::from(5u8)) * FieldElement::from(8u8).invert().unwrap());
|
(u * v7).pow((-FieldElement::from(5u8)) * FieldElement::from(8u8).invert().unwrap());
|
||||||
let check = (v) * r.square();
|
|
||||||
let i = SQRT_M1;
|
|
||||||
|
|
||||||
|
let check = v * r.square();
|
||||||
let correct_sign = check.ct_eq(&u);
|
let correct_sign = check.ct_eq(&u);
|
||||||
let flipped_sign = check.ct_eq(&(-u));
|
let flipped_sign = check.ct_eq(&(-u));
|
||||||
let flipped_sign_i = check.ct_eq(&((-u) * i));
|
let flipped_sign_i = check.ct_eq(&((-u) * i));
|
||||||
|
|
||||||
let r_prime = i * r;
|
r.conditional_assign(&(r * i), flipped_sign | flipped_sign_i);
|
||||||
|
|
||||||
r.conditional_assign(&r_prime, flipped_sign | flipped_sign_i);
|
|
||||||
|
|
||||||
let r_is_negative = r.is_odd();
|
let r_is_negative = r.is_odd();
|
||||||
r.conditional_negate(r_is_negative);
|
r.conditional_negate(r_is_negative);
|
||||||
|
|
||||||
let was_non_zero_square = correct_sign | flipped_sign;
|
(correct_sign | flipped_sign, r)
|
||||||
|
|
||||||
(was_non_zero_square, r)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue