mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-23 12:09:37 +00:00
Remove re-calculation of N
Moves most BP assertions to debug.
This commit is contained in:
parent
7d9834be87
commit
60e15d5160
2 changed files with 7 additions and 8 deletions
|
@ -19,8 +19,8 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) const MAX_M: usize = 16;
|
pub(crate) const MAX_M: usize = 16;
|
||||||
pub(crate) const MAX_N: usize = 64;
|
const N: usize = 64;
|
||||||
const MAX_MN: usize = MAX_M * MAX_N;
|
const MAX_MN: usize = MAX_M * N;
|
||||||
|
|
||||||
// Wrap random_scalar and hash_to_scalar into dalek_ff_group
|
// Wrap random_scalar and hash_to_scalar into dalek_ff_group
|
||||||
fn random_scalar<R: RngCore + CryptoRng>(rng: &mut R) -> Scalar {
|
fn random_scalar<R: RngCore + CryptoRng>(rng: &mut R) -> Scalar {
|
||||||
|
@ -49,7 +49,7 @@ lazy_static! {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn vector_exponent(a: &ScalarVector, b: &ScalarVector) -> EdwardsPoint {
|
pub(crate) fn vector_exponent(a: &ScalarVector, b: &ScalarVector) -> EdwardsPoint {
|
||||||
assert_eq!(a.len(), b.len());
|
debug_assert_eq!(a.len(), b.len());
|
||||||
(a * &G_i[.. a.len()]) + (b * &H_i[.. b.len()])
|
(a * &G_i[.. a.len()]) + (b * &H_i[.. b.len()])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +69,7 @@ pub(crate) fn prove<R: RngCore + CryptoRng>(
|
||||||
let gamma = ScalarVector(commitments.iter().cloned().map(|c| Scalar(c.mask)).collect());
|
let gamma = ScalarVector(commitments.iter().cloned().map(|c| Scalar(c.mask)).collect());
|
||||||
|
|
||||||
let logN = 6;
|
let logN = 6;
|
||||||
let N = 1 << logN;
|
debug_assert_eq!(N, 1 << logN);
|
||||||
assert_eq!(N, 64);
|
|
||||||
|
|
||||||
let mut logM = 0;
|
let mut logM = 0;
|
||||||
let mut M;
|
let mut M;
|
||||||
|
|
|
@ -26,7 +26,7 @@ macro_rules! math_op {
|
||||||
impl $Op<ScalarVector> for ScalarVector {
|
impl $Op<ScalarVector> for ScalarVector {
|
||||||
type Output = ScalarVector;
|
type Output = ScalarVector;
|
||||||
fn $op(self, b: ScalarVector) -> ScalarVector {
|
fn $op(self, b: ScalarVector) -> ScalarVector {
|
||||||
assert_eq!(self.len(), b.len());
|
debug_assert_eq!(self.len(), b.len());
|
||||||
ScalarVector(self.0.iter().zip(b.0.iter()).map($f).collect())
|
ScalarVector(self.0.iter().zip(b.0.iter()).map($f).collect())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ macro_rules! math_op {
|
||||||
impl $Op<&ScalarVector> for &ScalarVector {
|
impl $Op<&ScalarVector> for &ScalarVector {
|
||||||
type Output = ScalarVector;
|
type Output = ScalarVector;
|
||||||
fn $op(self, b: &ScalarVector) -> ScalarVector {
|
fn $op(self, b: &ScalarVector) -> ScalarVector {
|
||||||
assert_eq!(self.len(), b.len());
|
debug_assert_eq!(self.len(), b.len());
|
||||||
ScalarVector(self.0.iter().zip(b.0.iter()).map($f).collect())
|
ScalarVector(self.0.iter().zip(b.0.iter()).map($f).collect())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ pub(crate) fn inner_product(a: &ScalarVector, b: &ScalarVector) -> Scalar {
|
||||||
impl Mul<&[EdwardsPoint]> for &ScalarVector {
|
impl Mul<&[EdwardsPoint]> for &ScalarVector {
|
||||||
type Output = EdwardsPoint;
|
type Output = EdwardsPoint;
|
||||||
fn mul(self, b: &[EdwardsPoint]) -> EdwardsPoint {
|
fn mul(self, b: &[EdwardsPoint]) -> EdwardsPoint {
|
||||||
assert_eq!(self.len(), b.len());
|
debug_assert_eq!(self.len(), b.len());
|
||||||
multiexp(&self.0.iter().cloned().zip(b.iter().cloned()).collect::<Vec<_>>())
|
multiexp(&self.0.iter().cloned().zip(b.iter().cloned()).collect::<Vec<_>>())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue