Comment the previous commit

Despite the intentions of https://github.com/serai-dex/serai/issues/85, 
it failed to be practically faster :/

Updates a DLEq test to be better as well.
This commit is contained in:
Luke Parker 2022-08-13 19:43:18 -04:00
parent 062cd77a98
commit 75c3cdc5af
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6
2 changed files with 21 additions and 11 deletions

View file

@ -16,10 +16,11 @@ fn test_schnorr<G: PrimeGroup + Zeroize>()
where where
G::Scalar: PrimeFieldBits + Zeroize, G::Scalar: PrimeFieldBits + Zeroize,
{ {
let private = G::Scalar::random(&mut OsRng);
let transcript = RecommendedTranscript::new(b"Schnorr Test"); let transcript = RecommendedTranscript::new(b"Schnorr Test");
let mut batch = BatchVerifier::new(3);
let mut batch = BatchVerifier::new(10);
for _ in 0 .. 10 {
let private = G::Scalar::random(&mut OsRng);
SchnorrPoK::prove(&mut OsRng, &mut transcript.clone(), G::generator(), private).verify( SchnorrPoK::prove(&mut OsRng, &mut transcript.clone(), G::generator(), private).verify(
&mut OsRng, &mut OsRng,
&mut transcript.clone(), &mut transcript.clone(),
@ -27,6 +28,8 @@ where
G::generator() * private, G::generator() * private,
&mut batch, &mut batch,
); );
}
assert!(batch.verify_vartime()); assert!(batch.verify_vartime());
} }

View file

@ -2,7 +2,7 @@ use rand_core::{RngCore, CryptoRng};
use zeroize::Zeroize; use zeroize::Zeroize;
use ff::{Field, PrimeField, PrimeFieldBits}; use ff::{Field, PrimeFieldBits};
use group::Group; use group::Group;
use crate::{multiexp, multiexp_vartime}; use crate::{multiexp, multiexp_vartime};
@ -32,6 +32,12 @@ where
} else { } else {
let mut weight; let mut weight;
while { while {
// Generate a random scalar
weight = G::Scalar::random(&mut *rng);
// Clears half the bits, maintaining security, to minimize scalar additions
// Is not practically faster for whatever reason
/*
// Generate a random scalar // Generate a random scalar
let mut repr = G::Scalar::random(&mut *rng).to_repr(); let mut repr = G::Scalar::random(&mut *rng).to_repr();
@ -55,6 +61,7 @@ where
repr.as_mut().reverse(); repr.as_mut().reverse();
weight = G::Scalar::from_repr(repr).unwrap(); weight = G::Scalar::from_repr(repr).unwrap();
} }
*/
// Ensure it's non-zero, as a zero scalar would cause this item to pass no matter what // Ensure it's non-zero, as a zero scalar would cause this item to pass no matter what
weight.is_zero().into() weight.is_zero().into()