This commit is contained in:
Neemek 2025-11-03 18:56:06 +01:00
parent 3c61f6f043
commit 59c2e1e6dd
5 changed files with 8 additions and 10 deletions

View file

@ -156,6 +156,7 @@ where
}
fn double(&self) -> Self {
/*
let a = self.x.add_mod(&self.y, &self.curve.p);
let b = a.mul_mod(&a, &self.curve.p);
let c = self.x.mul_mod(&self.x, &self.curve.p);
@ -174,6 +175,9 @@ where
z,
curve: self.curve,
}
*/
self.add(self, self)
}
fn mul(&self, x: &N) -> Self {
@ -200,7 +204,7 @@ where
+ ConstZero
+ crypto_bigint::subtle::ConstantTimeEq,
{
fn get_y(self) -> N {
pub fn get_y(self) -> N {
self.y
.mul_mod(&self.z.inv_mod(&self.curve.p).unwrap(), &self.curve.p)
}

View file

@ -75,9 +75,6 @@ impl From<U256> for Secret {
#[cfg(test)]
mod tests {
use super::*;
const BIG_VALID_VALUE: U256 = U256::ONE
.shl(251)
.add_mod(&U256::from_u64(1232039487203 * 8), &CURVE_25519.p);
#[test]
fn public_key_derivation() {

View file

@ -1,9 +1,8 @@
use crate::traits::{Curve, Point};
use crypto_bigint::subtle::{Choice, ConstantTimeEq};
use crypto_bigint::{AddMod, ConstChoice, Encoding, NonZero, SubMod, U256};
use crypto_bigint::{AddMod, Encoding, NonZero, SubMod, U256};
use crypto_bigint::{Integer, InvMod, MulMod};
use std::fmt::{Display, Formatter};
use std::ops::{Add, Div, Mul};
use std::ops::{Div, Mul};
/// A curve of the form `By^2 = x^3 + Ax^2 + x`
#[derive(Clone, Copy, Debug)]

View file

@ -1,4 +1,4 @@
use crypto_bigint::{AddMod, InvMod, MulMod, SubMod, U256};
use crypto_bigint::{AddMod, InvMod, MulMod, SubMod};
pub trait Curve<T, N>
where