Sfoglia il codice sorgente

Update sigma-compiler and released proof dependencies

Use the draft-v3 sigma-compiler Git dependency with released sigma-proofs
0.4 and spongefish 0.8. Update the group, curve, hash-to-group, and RNG
dependencies and APIs to match the released versions.
Michele Orrù 1 mese fa
parent
commit
955c44ccb1
11 ha cambiato i file con 341 aggiunte e 388 eliminazioni
  1. 297 343
      Cargo.lock
  2. 9 10
      Cargo.toml
  3. 4 4
      README.md
  4. 2 2
      cmz-core/src/lib.rs
  5. 3 3
      cmz-derive/src/lib.rs
  6. 9 9
      src/lib.rs
  7. 2 2
      tests/basic.rs
  8. 3 3
      tests/priv_serialize.rs
  9. 6 6
      tests/rate_limiting.rs
  10. 2 2
      tests/submodule.rs
  11. 4 4
      tests/wallet.rs

File diff suppressed because it is too large
+ 297 - 343
Cargo.lock


+ 9 - 10
Cargo.toml

@@ -8,13 +8,13 @@ description = "A crate to automatically create protocols that use CMZ14 or µCMZ
 
 [dependencies]
 cmz-derive = "=0.3.0"
-ff = "0.13"
+ff = "0.14"
 generic_static = "0.2"
-group = "0.13"
+group = "0.14"
 hex = { version = "0.4", features = [ "serde" ] }
 lazy_static = "1"
 postcard = { version = "1", features = [ "alloc" ] }
-rand = "0.8.5"
+rand = "0.10"
 serde = { version = "1", features = [ "derive" ] }
 serde_bytes = "0.11"
 serde_with = "3"
@@ -23,17 +23,16 @@ thiserror = "2"
 
 [dev-dependencies]
 chrono = "0.4"
-curve25519-dalek = { version = "4", features = [ "group", "rand_core", "digest" ] }
-sha2 = "0.10"
+curve25519-dalek = { version = "5", features = [ "group", "rand_core", "digest" ] }
+sha2 = "0.11"
 
 [patch.crates-io]
 cmz-derive = { path = "cmz-derive" }
 cmz-core = { path = "cmz-core" }
-# sigma-compiler = { path = "../sigma-compiler" }
-# sigma-compiler-derive = { path = "../sigma-compiler/sigma-compiler-derive" }
-# sigma-compiler-core = { path = "../sigma-compiler/sigma-compiler-core" }
-# sigma-proofs = { path = "../sigma-proofs" }
-# spongefish = { path = "../spongefish/spongefish" }
+sigma-compiler = { path = "../sigma-compiler" }
+sigma-compiler-derive = { path = "../sigma-compiler/sigma-compiler-derive" }
+sigma-compiler-core = { path = "../sigma-compiler/sigma-compiler-core" }
+sigma-proofs = { path = "../sigma-proofs" }
 
 [features]
 # Dump (to stdout or to a string) the value of the instance on both the

+ 4 - 4
README.md

@@ -18,9 +18,9 @@ Your application can have multiple different kinds of credentials, each
 with its own set of attributes.  All of the credentials in your
 application should use the _same_ `Scalar` and `Point` types.  You get
 these from a mathematical _group_, which must satisfy the trait
-[group::prime::PrimeGroup](https://docs.rs/group/0.13.0/group/prime/trait.PrimeGroup.html).
+[group::prime::PrimeGroup](https://docs.rs/group/0.14.0/group/prime/trait.PrimeGroup.html).
 A typical such group would be
-[curve25519\_dalek::ristretto::RistrettoPoint](https://docs.rs/curve25519-dalek/4.1.3/curve25519_dalek/ristretto/struct.RistrettoPoint.html).
+[curve25519\_dalek::ristretto::RistrettoPoint](https://docs.rs/curve25519-dalek/5.0.0/curve25519_dalek/ristretto/struct.RistrettoPoint.html).
 
 To declare a credential type, use the `CMZ!` macro at the top level of
 your crate or module (outside of any function):
@@ -203,7 +203,7 @@ the following signature:
 
 ```text
     pub fn prepare(
-        rng: &mut impl RngCore,
+        rng: &mut impl Rng,
         session_id: &[u8],
         W: &Wallet,
         I: &Item,
@@ -229,7 +229,7 @@ the following signature:
 
 ```text
     pub fn handle<F,A>(
-        rng: &mut impl RngCore,
+        rng: &mut impl Rng,
         session_id: &[u8],
         request: Request,
         fill_creds: F,

+ 2 - 2
cmz-core/src/lib.rs

@@ -1615,7 +1615,7 @@ pub fn cmz_core(
         let reqf = request_fields.field_iter();
         let csf = clientstate_fields.field_iter();
         quote! {
-            pub fn prepare(rng: &mut (impl CryptoRng + RngCore),
+            pub fn prepare(rng: &mut (impl CryptoRng + Rng),
                 session_id: &[u8],
                 #(#client_show_args)* #(#client_issue_args)* #client_params_arg)
                     -> Result<(Request, ClientState),CMZError> {
@@ -1756,7 +1756,7 @@ pub fn cmz_core(
         };
 
         quote! {
-            pub fn handle<F,A>(rng: &mut (impl CryptoRng + RngCore),
+            pub fn handle<F,A>(rng: &mut (impl CryptoRng + Rng),
                 session_id: &[u8],
                 request: Request, fill_creds: F, authorize: A)
                 -> #rettype

+ 3 - 3
cmz-derive/src/lib.rs

@@ -131,7 +131,7 @@ fn impl_cmzcred_derive(ast: &syn::DeriveInput, group_ident: &Ident) -> TokenStre
                 self.pubkey.X[Self::attr_num(name)]
             }
 
-            fn gen_keys(rng: &mut impl RngCore, muCMZ: bool) ->
+            fn gen_keys(rng: &mut impl Rng, muCMZ: bool) ->
                     (CMZPrivkey<Self::Point>, CMZPubkey<Self::Point>) {
                 // Generate (num_attrs + 2) random scalars as the
                 // private key
@@ -163,7 +163,7 @@ fn impl_cmzcred_derive(ast: &syn::DeriveInput, group_ident: &Ident) -> TokenStre
                 Ok(coeff)
             }
 
-            fn create_MAC(&mut self, rng: &mut impl RngCore, privkey: &CMZPrivkey<Self::Point>) -> Result<(),()> {
+            fn create_MAC(&mut self, rng: &mut impl Rng, privkey: &CMZPrivkey<Self::Point>) -> Result<(),()> {
                 let coeff = self.compute_MAC_coeff(privkey)?;
                 self.MAC.P = <Self::Point as group::Group>::random(&mut *rng);
                 self.MAC.Q = coeff * self.MAC.P;
@@ -180,7 +180,7 @@ fn impl_cmzcred_derive(ast: &syn::DeriveInput, group_ident: &Ident) -> TokenStre
                 }
             }
 
-            fn fake_MAC(&mut self, rng: &mut impl RngCore) {
+            fn fake_MAC(&mut self, rng: &mut impl Rng) {
                 self.MAC.P = <Self::Point as group::Group>::random(&mut *rng);
                 self.MAC.Q = <Self::Point as group::Group>::random(&mut *rng);
             }

+ 9 - 9
src/lib.rs

@@ -12,7 +12,7 @@ use group::{Group, GroupEncoding};
 #[cfg(feature = "wnaf_is_constant_time")]
 use group::{WnafBase, WnafScalar};
 use lazy_static::lazy_static;
-use rand::RngCore;
+use rand::Rng;
 use serde::{Deserialize, Deserializer, Serialize, Serializer};
 pub use serde_with::serde_as;
 use serde_with::{DeserializeAs, SerializeAs};
@@ -168,12 +168,12 @@ impl<G: Group> CMZBasepoints<G> {
         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);
         (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);
         (x, self.mulB(&x))
     }
@@ -370,16 +370,16 @@ where
     /// type.  muCMZ should be true if this credential will be issued
     /// with muCMZ protocols (and _not_ classic CMZ14 protocols).
     fn gen_keys(
-        rng: &mut impl RngCore,
+        rng: &mut impl Rng,
         muCMZ: bool,
     ) -> (CMZPrivkey<Self::Point>, CMZPubkey<Self::Point>);
 
     /// 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)
     }
 
-    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)
     }
 
@@ -402,7 +402,7 @@ where
     /// Create the MAC for this credential, given the private key.
     fn create_MAC(
         &mut self,
-        rng: &mut impl RngCore,
+        rng: &mut impl Rng,
         privkey: &CMZPrivkey<Self::Point>,
     ) -> Result<(), ()>;
 
@@ -419,7 +419,7 @@ where
     /// 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
     /// 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
     /// default serializer skips the private key for safety reasons.
@@ -443,7 +443,7 @@ where
 ///
 ///     use cmz::*;
 ///     use group::Group;
-///     use rand::{CryptoRng, RngCore};
+///     use rand::{CryptoRng, Rng};
 ///     use curve25519_dalek::ristretto::RistrettoPoint as Grp;
 ///     CMZ!{ Name<Grp>: attr1, attr2, attr3 }
 ///

+ 2 - 2
tests/basic.rs

@@ -2,7 +2,7 @@ use cmz::*;
 use curve25519_dalek::ristretto::RistrettoPoint;
 use curve25519_dalek::scalar::Scalar;
 use group::Group;
-use rand::{CryptoRng, RngCore};
+use rand::{CryptoRng, Rng};
 use sha2::Sha512;
 
 CMZ! { Basic<RistrettoPoint> :
@@ -18,7 +18,7 @@ A: Basic {
 
 #[test]
 fn test_basic() {
-    let mut rng = rand::thread_rng();
+    let mut rng = rand::rng();
     cmz_group_init(RistrettoPoint::hash_from_bytes::<Sha512>(
         b"CMZ Generator A",
     ));

+ 3 - 3
tests/priv_serialize.rs

@@ -2,7 +2,7 @@ use cmz::*;
 use curve25519_dalek::ristretto::RistrettoPoint;
 use curve25519_dalek::scalar::Scalar;
 use group::Group;
-use rand::{CryptoRng, RngCore};
+use rand::{CryptoRng, Rng};
 use sha2::Sha512;
 
 CMZ! { Basic<RistrettoPoint> :
@@ -21,7 +21,7 @@ A: Basic {
 // Radically Open Security.
 #[test]
 fn test_default_serialize() {
-    let mut rng = rand::thread_rng();
+    let mut rng = rand::rng();
     cmz_group_init(RistrettoPoint::hash_from_bytes::<Sha512>(
         b"CMZ Generator A",
     ));
@@ -49,7 +49,7 @@ fn test_default_serialize() {
 // include the private key material.
 #[test]
 fn test_priv_serialize() {
-    let mut rng = rand::thread_rng();
+    let mut rng = rand::rng();
     cmz_group_init(RistrettoPoint::hash_from_bytes::<Sha512>(
         b"CMZ Generator A",
     ));

+ 6 - 6
tests/rate_limiting.rs

@@ -4,7 +4,7 @@ use chrono::Utc;
 use cmz::*;
 use curve25519_dalek::ristretto::RistrettoPoint;
 use group::{Group, GroupEncoding};
-use rand::{CryptoRng, RngCore};
+use rand::{CryptoRng, Rng};
 use sha2::Sha512;
 use std::collections::HashSet;
 
@@ -32,7 +32,7 @@ struct RateLimitClient {
 }
 
 impl RateLimitClient {
-    pub fn new(rng: &mut (impl CryptoRng + RngCore), cred: &Cred) -> Self {
+    pub fn new(rng: &mut (impl CryptoRng + Rng), cred: &Cred) -> Self {
         let (_, presnum_pubkey) = PresNum::mucmz_gen_keys(rng);
         Self {
             presnum_pubkey,
@@ -42,7 +42,7 @@ impl RateLimitClient {
 
     pub fn pres(
         &mut self,
-        rng: &mut (impl CryptoRng + RngCore),
+        rng: &mut (impl CryptoRng + Rng),
         epoch: &[u8],
         pres_num: u32,
     ) -> Result<Vec<u8>, CMZError> {
@@ -72,7 +72,7 @@ struct RateLimitServer {
 }
 
 impl RateLimitServer {
-    pub fn new(rng: &mut (impl CryptoRng + RngCore), privkey: &CMZPrivkey<G>) -> Self {
+    pub fn new(rng: &mut (impl CryptoRng + Rng), privkey: &CMZPrivkey<G>) -> Self {
         let (presnum_privkey, _) = PresNum::mucmz_gen_keys(rng);
         Self {
             privkey: privkey.clone(),
@@ -83,7 +83,7 @@ impl RateLimitServer {
 
     pub fn check(
         &mut self,
-        rng: &mut (impl CryptoRng + RngCore),
+        rng: &mut (impl CryptoRng + Rng),
         epoch: &[u8],
         msg: &[u8],
     ) -> Result<(), CMZError> {
@@ -124,7 +124,7 @@ impl RateLimitServer {
 
 #[test]
 fn test_rate_limiting() -> Result<(), CMZError> {
-    let mut rng = rand::thread_rng();
+    let mut rng = rand::rng();
     cmz_group_init(RistrettoPoint::hash_from_bytes::<Sha512>(
         b"CMZ Generator A",
     ));

+ 2 - 2
tests/submodule.rs

@@ -4,7 +4,7 @@ use cmz::*;
 use curve25519_dalek::ristretto::RistrettoPoint;
 use curve25519_dalek::scalar::Scalar;
 use group::Group;
-use rand::{CryptoRng, RngCore};
+use rand::{CryptoRng, Rng};
 use sha2::Sha512;
 
 pub mod cred {
@@ -29,7 +29,7 @@ pub mod submod {
 
     #[test]
     fn test_submodule() -> Result<(), CMZError> {
-        let mut rng = rand::thread_rng();
+        let mut rng = rand::rng();
         cmz_group_init(RistrettoPoint::hash_from_bytes::<Sha512>(
             b"CMZ Generator A",
         ));

+ 4 - 4
tests/wallet.rs

@@ -5,7 +5,7 @@
 use cmz::*;
 use curve25519_dalek::ristretto::RistrettoPoint as G;
 use group::Group;
-use rand::{CryptoRng, RngCore};
+use rand::{CryptoRng, Rng};
 use sha2::Sha512;
 
 CMZ! { Wallet: randid, balance }
@@ -48,7 +48,7 @@ macro_rules! protos_def {
             // The issuer runs this on its own to create an Item credential for a
             // particular item (specified by a serial number) with a given price.
             fn issue_item(
-                rng: &mut (impl CryptoRng + RngCore),
+                rng: &mut (impl CryptoRng + Rng),
                 serialno: u128,
                 price: u128,
                 privkey: &CMZPrivkey<G>,
@@ -79,7 +79,7 @@ macro_rules! protos_def {
             // with funds, to sent to a client.  The issuer will presumably charge
             // the client out of band for this loaded wallet.
             fn issue_wallet(
-                rng: &mut (impl CryptoRng + RngCore),
+                rng: &mut (impl CryptoRng + Rng),
                 balance: u128,
                 privkey: &CMZPrivkey<G>,
                 public: &CMZPubkey<G>,
@@ -108,7 +108,7 @@ macro_rules! protos_def {
             }
 
             // Initialization
-            let mut rng = rand::thread_rng();
+            let mut rng = rand::rng();
             cmz_group_init(G::hash_from_bytes::<Sha512>(b"CMZ Generator A"));
 
             // Issuer: generate private and public keys for each type of

Some files were not shown because too many files changed in this diff