mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-06 20:41:14 +00:00
Add constant value of 1/2 (mod p)
This commit is contained in:
parent
79afc6bd0f
commit
e1feb653be
1 changed files with 10 additions and 0 deletions
|
|
@ -32,6 +32,9 @@ pub const d2: FieldElement = FieldElement([
|
||||||
pub const SQRT_M1: FieldElement = FieldElement([
|
pub const SQRT_M1: FieldElement = FieldElement([
|
||||||
-32595792, -7943725, 9377950, 3500415, 12389472,
|
-32595792, -7943725, 9377950, 3500415, 12389472,
|
||||||
-272473, -25146209, -2005654, 326686, 11406482, ]);
|
-272473, -25146209, -2005654, 326686, 11406482, ]);
|
||||||
|
/// Precomputed value of 1/2 (mod p).
|
||||||
|
pub const HALF: FieldElement = FieldElement([
|
||||||
|
10, 0, 0, 0, 0, 0, 0, 0, 0, -16777216, ]);
|
||||||
|
|
||||||
/// In Montgomery form y² = x³+Ax²+x, Curve25519 has A=486662.
|
/// In Montgomery form y² = x³+Ax²+x, Curve25519 has A=486662.
|
||||||
pub const A: FieldElement = FieldElement([
|
pub const A: FieldElement = FieldElement([
|
||||||
|
|
@ -1480,6 +1483,13 @@ mod test {
|
||||||
use curve::PreComputedPoint;
|
use curve::PreComputedPoint;
|
||||||
use constants;
|
use constants;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_half() {
|
||||||
|
let one = FieldElement([1,0,0,0,0,0,0,0,0,0]);
|
||||||
|
let two = FieldElement([2,0,0,0,0,0,0,0,0,0]);
|
||||||
|
assert_eq!(one, &two * &constants::HALF);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
/// Test that SQRT_M1 is a square root of -1
|
/// Test that SQRT_M1 is a square root of -1
|
||||||
fn test_sqrt_minus_one() {
|
fn test_sqrt_minus_one() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue