mirror of
https://github.com/serai-dex/serai.git
synced 2025-03-24 08:08:51 +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"
|
ff = "0.12"
|
||||||
group = "0.12"
|
group = "0.12"
|
||||||
|
|
||||||
multiexp = { path = "../multiexp" }
|
multiexp = { path = "../multiexp", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
hex-literal = "0.3"
|
hex-literal = "0.3"
|
||||||
|
@ -35,4 +35,6 @@ transcript = { package = "flexible-transcript", path = "../transcript", features
|
||||||
serialize = []
|
serialize = []
|
||||||
cross_group = []
|
cross_group = []
|
||||||
secure_capacity_difference = []
|
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;
|
use crate::Generators;
|
||||||
|
|
||||||
pub mod scalar;
|
pub mod scalar;
|
||||||
use scalar::{scalar_normalize, scalar_convert};
|
use scalar::scalar_convert;
|
||||||
|
|
||||||
pub(crate) mod schnorr;
|
pub(crate) mod schnorr;
|
||||||
use schnorr::SchnorrPoK;
|
use schnorr::SchnorrPoK;
|
||||||
|
@ -159,13 +159,23 @@ impl<G0: PrimeGroup, G1: PrimeGroup> DLEqProof<G0, G1>
|
||||||
commitments: impl Iterator<Item = G>
|
commitments: impl Iterator<Item = G>
|
||||||
) -> G where G::Scalar: PrimeFieldBits {
|
) -> G where G::Scalar: PrimeFieldBits {
|
||||||
let mut pow_2 = G::Scalar::one();
|
let mut pow_2 = G::Scalar::one();
|
||||||
multiexp::multiexp_vartime(
|
#[cfg(feature = "multiexp")]
|
||||||
|
let res = multiexp::multiexp_vartime(
|
||||||
&commitments.map(|commitment| {
|
&commitments.map(|commitment| {
|
||||||
let res = (pow_2, commitment);
|
let res = (pow_2, commitment);
|
||||||
pow_2 = pow_2.double();
|
pow_2 = pow_2.double();
|
||||||
res
|
res
|
||||||
}).collect::<Vec<_>>()
|
}).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) {
|
fn reconstruct_keys(&self) -> (G0, G1) {
|
||||||
|
|
Loading…
Reference in a new issue