mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-22 19:49:22 +00:00
Make multiexp an optional, yet default, feature for DLEq
This commit is contained in:
parent
2e35854215
commit
ed569ea9c8
2 changed files with 17 additions and 5 deletions
|
@ -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"]
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue