mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-07 20:50:39 +00:00
Remove Scalar::multiply_add
This commit is contained in:
parent
9e892dd5f3
commit
1caed9a4fc
1 changed files with 2 additions and 17 deletions
|
|
@ -512,11 +512,6 @@ impl Scalar {
|
||||||
UnpackedScalar::from_bytes(&self.bytes)
|
UnpackedScalar::from_bytes(&self.bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compute `(a * b) + c` (mod l).
|
|
||||||
pub fn multiply_add(a: &Scalar, b: &Scalar, c: &Scalar) -> Scalar {
|
|
||||||
UnpackedScalar::add(&UnpackedScalar::mul(&a.unpack(), &b.unpack()), &c.unpack()).pack()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Reduce this `Scalar` modulo \\(\ell\\).
|
/// Reduce this `Scalar` modulo \\(\ell\\).
|
||||||
pub fn reduce(&self) -> Scalar {
|
pub fn reduce(&self) -> Scalar {
|
||||||
let x = self.unpack();
|
let x = self.unpack();
|
||||||
|
|
@ -759,9 +754,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn scalar_multiply_by_one() {
|
fn scalar_multiply_by_one() {
|
||||||
let one = Scalar::one();
|
let test_scalar = &X * &Scalar::one();
|
||||||
let zero = Scalar::zero();
|
|
||||||
let test_scalar = Scalar::multiply_add(&X, &one, &zero);
|
|
||||||
for i in 0..32 {
|
for i in 0..32 {
|
||||||
assert!(test_scalar[i] == X[i]);
|
assert!(test_scalar[i] == X[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -788,17 +781,9 @@ mod test {
|
||||||
assert_eq!(should_be_X_times_Y, X_TIMES_Y);
|
assert_eq!(should_be_X_times_Y, X_TIMES_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn scalar_multiply_add() {
|
|
||||||
let test_scalar = Scalar::multiply_add(&X, &Y, &Z);
|
|
||||||
for i in 0..32 {
|
|
||||||
assert!(test_scalar[i] == W[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn square() {
|
fn square() {
|
||||||
let expected = Scalar::multiply_add(&X, &X, &Scalar::zero());
|
let expected = &X * &X;
|
||||||
let actual = X.unpack().square().pack();
|
let actual = X.unpack().square().pack();
|
||||||
for i in 0..32 {
|
for i in 0..32 {
|
||||||
assert!(expected[i] == actual[i]);
|
assert!(expected[i] == actual[i]);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue