mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-23 03:59:22 +00:00
Add constant EDWARDS_D
in dalek-ff-group (#78)
This commit is contained in:
parent
96a49d8a88
commit
169d5e26ca
1 changed files with 12 additions and 0 deletions
|
@ -16,6 +16,10 @@ const FIELD_MODULUS: U256 =
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Default, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Default, Debug)]
|
||||||
pub struct FieldElement(U256);
|
pub struct FieldElement(U256);
|
||||||
|
|
||||||
|
pub const EDWARDS_D: FieldElement = FieldElement(U256::from_be_hex(
|
||||||
|
"52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3",
|
||||||
|
));
|
||||||
|
|
||||||
pub const SQRT_M1: FieldElement = FieldElement(U256::from_be_hex(
|
pub const SQRT_M1: FieldElement = FieldElement(U256::from_be_hex(
|
||||||
"2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0",
|
"2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0",
|
||||||
));
|
));
|
||||||
|
@ -154,6 +158,14 @@ impl FieldElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_edwards_d() {
|
||||||
|
let a = -FieldElement(U256::from_u32(121665));
|
||||||
|
let b = FieldElement(U256::from_u32(121666));
|
||||||
|
|
||||||
|
assert_eq!(EDWARDS_D, a * b.invert().unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mul() {
|
fn test_mul() {
|
||||||
assert_eq!(FieldElement(FIELD_MODULUS) * FieldElement::one(), FieldElement::zero());
|
assert_eq!(FieldElement(FIELD_MODULUS) * FieldElement::one(), FieldElement::zero());
|
||||||
|
|
Loading…
Reference in a new issue