mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-06 20:41:14 +00:00
Implement addition and subtraction for DecafPoint.
This commit is contained in:
parent
f52e2ee37e
commit
084c29c4ed
1 changed files with 29 additions and 0 deletions
29
src/decaf.rs
29
src/decaf.rs
|
|
@ -25,6 +25,8 @@ use constants;
|
||||||
use field::FieldElement;
|
use field::FieldElement;
|
||||||
use subtle::CTAssignable;
|
use subtle::CTAssignable;
|
||||||
|
|
||||||
|
use core::ops::{Add, Sub, Neg};
|
||||||
|
|
||||||
use curve::ExtendedPoint;
|
use curve::ExtendedPoint;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
@ -151,6 +153,33 @@ impl DecafPoint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Arithmetic
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
impl<'a, 'b> Add<&'b DecafPoint> for &'a DecafPoint {
|
||||||
|
type Output = DecafPoint;
|
||||||
|
|
||||||
|
fn add(self, other: &'b DecafPoint) -> DecafPoint {
|
||||||
|
DecafPoint(&self.0 + &other.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'b> Sub<&'b DecafPoint> for &'a DecafPoint {
|
||||||
|
type Output = DecafPoint;
|
||||||
|
|
||||||
|
fn sub(self, other: &'b DecafPoint) -> DecafPoint {
|
||||||
|
DecafPoint(&self.0 - &other.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Neg for &'a DecafPoint {
|
||||||
|
type Output = DecafPoint;
|
||||||
|
|
||||||
|
fn neg(self) -> DecafPoint {
|
||||||
|
DecafPoint(-&self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Debug traits
|
// Debug traits
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue