Skip to content

Commit

Permalink
RistrettoPoint::vartime_check_double_scalar_mul_basepoint
Browse files Browse the repository at this point in the history
Checks whether [a]A + [b]B = C in variable time.
  • Loading branch information
str4d committed Dec 12, 2022
1 parent 6df1917 commit 28b9aa5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/ristretto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ use digest::Digest;
use crate::constants;
use crate::field::FieldElement;

#[cfg(feature = "alloc")]
use cfg_if::cfg_if;

use subtle::Choice;
Expand All @@ -199,7 +198,6 @@ use crate::traits::Identity;
#[cfg(feature = "alloc")]
use crate::traits::{MultiscalarMul, VartimeMultiscalarMul, VartimePrecomputedMultiscalarMul};

#[cfg(feature = "alloc")]
cfg_if! {
if #[cfg(all(
curve25519_dalek_backend = "simd",
Expand Down Expand Up @@ -1025,6 +1023,18 @@ impl RistrettoPoint {
a, &A.0, b,
))
}

/// Checks whether \\([a]A + [b]B = C\\) in variable time.
pub fn vartime_check_double_scalar_mul_basepoint(
a: &Scalar,
A: &RistrettoPoint,
b: &Scalar,
C: &RistrettoPoint,
) -> bool {
use crate::traits::IsIdentity;

scalar_mul::abglsv_pornin::mul(a, &A.0, b, &C.0).is_identity()
}
}

/// A precomputed table of multiples of a basepoint, used to accelerate
Expand Down

0 comments on commit 28b9aa5

Please sign in to comment.