mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-22 19:49:22 +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]]
|
||||
name = "dalek-ff-group"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
dependencies = [
|
||||
"crypto-bigint",
|
||||
"curve25519-dalek 3.2.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "dalek-ff-group"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
description = "ff/group bindings around curve25519-dalek"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/serai-dex/serai"
|
||||
|
|
|
@ -165,27 +165,24 @@ impl FieldElement {
|
|||
}
|
||||
|
||||
pub fn sqrt_ratio_i(u: FieldElement, v: FieldElement) -> (Choice, FieldElement) {
|
||||
let i = SQRT_M1;
|
||||
|
||||
let v3 = v.square() * v;
|
||||
let v7 = v3.square() * v;
|
||||
let mut r = (u * v3) *
|
||||
(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 flipped_sign = check.ct_eq(&(-u));
|
||||
let flipped_sign_i = check.ct_eq(&((-u) * i));
|
||||
|
||||
let r_prime = i * r;
|
||||
|
||||
r.conditional_assign(&r_prime, flipped_sign | flipped_sign_i);
|
||||
r.conditional_assign(&(r * i), flipped_sign | flipped_sign_i);
|
||||
|
||||
let r_is_negative = r.is_odd();
|
||||
r.conditional_negate(r_is_negative);
|
||||
|
||||
let was_non_zero_square = correct_sign | flipped_sign;
|
||||
|
||||
(was_non_zero_square, r)
|
||||
(correct_sign | flipped_sign, r)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue