|
@@ -12,7 +12,7 @@ use group::{Group, GroupEncoding};
|
|
|
#[cfg(feature = "wnaf_is_constant_time")]
|
|
#[cfg(feature = "wnaf_is_constant_time")]
|
|
|
use group::{WnafBase, WnafScalar};
|
|
use group::{WnafBase, WnafScalar};
|
|
|
use lazy_static::lazy_static;
|
|
use lazy_static::lazy_static;
|
|
|
-use rand::RngCore;
|
|
|
|
|
|
|
+use rand::Rng;
|
|
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|
|
pub use serde_with::serde_as;
|
|
pub use serde_with::serde_as;
|
|
|
use serde_with::{DeserializeAs, SerializeAs};
|
|
use serde_with::{DeserializeAs, SerializeAs};
|
|
@@ -168,12 +168,12 @@ impl<G: Group> CMZBasepoints<G> {
|
|
|
self.B_ * s
|
|
self.B_ * s
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- pub fn keypairA(&self, rng: &mut impl RngCore) -> (G::Scalar, G) {
|
|
|
|
|
|
|
+ pub fn keypairA(&self, rng: &mut impl Rng) -> (G::Scalar, G) {
|
|
|
let x = G::Scalar::random(&mut *rng);
|
|
let x = G::Scalar::random(&mut *rng);
|
|
|
(x, self.mulA(&x))
|
|
(x, self.mulA(&x))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- pub fn keypairB(&self, rng: &mut impl RngCore) -> (G::Scalar, G) {
|
|
|
|
|
|
|
+ pub fn keypairB(&self, rng: &mut impl Rng) -> (G::Scalar, G) {
|
|
|
let x = G::Scalar::random(&mut *rng);
|
|
let x = G::Scalar::random(&mut *rng);
|
|
|
(x, self.mulB(&x))
|
|
(x, self.mulB(&x))
|
|
|
}
|
|
}
|
|
@@ -370,16 +370,16 @@ where
|
|
|
/// type. muCMZ should be true if this credential will be issued
|
|
/// type. muCMZ should be true if this credential will be issued
|
|
|
/// with muCMZ protocols (and _not_ classic CMZ14 protocols).
|
|
/// with muCMZ protocols (and _not_ classic CMZ14 protocols).
|
|
|
fn gen_keys(
|
|
fn gen_keys(
|
|
|
- rng: &mut impl RngCore,
|
|
|
|
|
|
|
+ rng: &mut impl Rng,
|
|
|
muCMZ: bool,
|
|
muCMZ: bool,
|
|
|
) -> (CMZPrivkey<Self::Point>, CMZPubkey<Self::Point>);
|
|
) -> (CMZPrivkey<Self::Point>, CMZPubkey<Self::Point>);
|
|
|
|
|
|
|
|
/// Convenience functions for the above
|
|
/// Convenience functions for the above
|
|
|
- fn cmz14_gen_keys(rng: &mut impl RngCore) -> (CMZPrivkey<Self::Point>, CMZPubkey<Self::Point>) {
|
|
|
|
|
|
|
+ fn cmz14_gen_keys(rng: &mut impl Rng) -> (CMZPrivkey<Self::Point>, CMZPubkey<Self::Point>) {
|
|
|
Self::gen_keys(rng, false)
|
|
Self::gen_keys(rng, false)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- fn mucmz_gen_keys(rng: &mut impl RngCore) -> (CMZPrivkey<Self::Point>, CMZPubkey<Self::Point>) {
|
|
|
|
|
|
|
+ fn mucmz_gen_keys(rng: &mut impl Rng) -> (CMZPrivkey<Self::Point>, CMZPubkey<Self::Point>) {
|
|
|
Self::gen_keys(rng, true)
|
|
Self::gen_keys(rng, true)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -402,7 +402,7 @@ where
|
|
|
/// Create the MAC for this credential, given the private key.
|
|
/// Create the MAC for this credential, given the private key.
|
|
|
fn create_MAC(
|
|
fn create_MAC(
|
|
|
&mut self,
|
|
&mut self,
|
|
|
- rng: &mut impl RngCore,
|
|
|
|
|
|
|
+ rng: &mut impl Rng,
|
|
|
privkey: &CMZPrivkey<Self::Point>,
|
|
privkey: &CMZPrivkey<Self::Point>,
|
|
|
) -> Result<(), ()>;
|
|
) -> Result<(), ()>;
|
|
|
|
|
|
|
@@ -419,7 +419,7 @@ where
|
|
|
/// Create a fake MAC for this credential. This is useful, for
|
|
/// Create a fake MAC for this credential. This is useful, for
|
|
|
/// example, when you're doing an OR proof, and in some arms of the
|
|
/// example, when you're doing an OR proof, and in some arms of the
|
|
|
/// disjunction, the credential does not have to be valid.
|
|
/// disjunction, the credential does not have to be valid.
|
|
|
- fn fake_MAC(&mut self, rng: &mut impl RngCore);
|
|
|
|
|
|
|
+ fn fake_MAC(&mut self, rng: &mut impl Rng);
|
|
|
|
|
|
|
|
/// Serialize this credential, _including_ the private key. The
|
|
/// Serialize this credential, _including_ the private key. The
|
|
|
/// default serializer skips the private key for safety reasons.
|
|
/// default serializer skips the private key for safety reasons.
|
|
@@ -443,7 +443,7 @@ where
|
|
|
///
|
|
///
|
|
|
/// use cmz::*;
|
|
/// use cmz::*;
|
|
|
/// use group::Group;
|
|
/// use group::Group;
|
|
|
-/// use rand::{CryptoRng, RngCore};
|
|
|
|
|
|
|
+/// use rand::{CryptoRng, Rng};
|
|
|
/// use curve25519_dalek::ristretto::RistrettoPoint as Grp;
|
|
/// use curve25519_dalek::ristretto::RistrettoPoint as Grp;
|
|
|
/// CMZ!{ Name<Grp>: attr1, attr2, attr3 }
|
|
/// CMZ!{ Name<Grp>: attr1, attr2, attr3 }
|
|
|
///
|
|
///
|