Make multiexp an optional, yet default, feature for DLEq

This commit is contained in:
Luke Parker 2022-07-02 02:48:27 -04:00
parent 2e35854215
commit ed569ea9c8
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6
2 changed files with 17 additions and 5 deletions

View file

@ -19,7 +19,7 @@ transcript = { package = "flexible-transcript", path = "../transcript", version
ff = "0.12"
group = "0.12"
multiexp = { path = "../multiexp" }
multiexp = { path = "../multiexp", optional = true }
[dev-dependencies]
hex-literal = "0.3"
@ -35,4 +35,6 @@ transcript = { package = "flexible-transcript", path = "../transcript", features
serialize = []
cross_group = []
secure_capacity_difference = []
default = ["secure_capacity_difference"]
# These only apply to cross_group, yet are default to ensure its integrity and performance
default = ["secure_capacity_difference", "multiexp"]

View file

@ -12,7 +12,7 @@ use group::{ff::{Field, PrimeField, PrimeFieldBits}, prime::PrimeGroup};
use crate::Generators;
pub mod scalar;
use scalar::{scalar_normalize, scalar_convert};
use scalar::scalar_convert;
pub(crate) mod schnorr;
use schnorr::SchnorrPoK;
@ -159,13 +159,23 @@ impl<G0: PrimeGroup, G1: PrimeGroup> DLEqProof<G0, G1>
commitments: impl Iterator<Item = G>
) -> G where G::Scalar: PrimeFieldBits {
let mut pow_2 = G::Scalar::one();
multiexp::multiexp_vartime(
#[cfg(feature = "multiexp")]
let res = multiexp::multiexp_vartime(
&commitments.map(|commitment| {
let res = (pow_2, commitment);
pow_2 = pow_2.double();
res
}).collect::<Vec<_>>()
)
);
#[cfg(not(feature = "multiexp"))]
let res = commitments.fold(G::identity(), |key, commitment| {
let res = key + (commitment * pow_2);
pow_2 = pow_2.double();
res
});
res
}
fn reconstruct_keys(&self) -> (G0, G1) {