Преглед изворни кода

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 месец
родитељ
комит
27e918c36e
11 измењених фајлова са 196 додато и 576 уклоњено
  1. 152 531
      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

Разлика између датотеке није приказан због своје велике величине
+ 152 - 531
Cargo.lock


+ 9 - 10
Cargo.toml

@@ -8,13 +8,13 @@ description = "A crate to automatically create protocols that use CMZ14 or µCMZ
 
 
 [dependencies]
 [dependencies]
 cmz-derive = "=0.3.0"
 cmz-derive = "=0.3.0"
-ff = "0.13"
+ff = "0.14"
 generic_static = "0.2"
 generic_static = "0.2"
-group = "0.13"
+group = "0.14"
 hex = { version = "0.4", features = [ "serde" ] }
 hex = { version = "0.4", features = [ "serde" ] }
 lazy_static = "1"
 lazy_static = "1"
 postcard = { version = "1", features = [ "alloc" ] }
 postcard = { version = "1", features = [ "alloc" ] }
-rand = "0.8.5"
+rand = "0.10"
 serde = { version = "1", features = [ "derive" ] }
 serde = { version = "1", features = [ "derive" ] }
 serde_bytes = "0.11"
 serde_bytes = "0.11"
 serde_with = "3"
 serde_with = "3"
@@ -23,17 +23,16 @@ thiserror = "2"
 
 
 [dev-dependencies]
 [dev-dependencies]
 chrono = "0.4"
 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]
 [patch.crates-io]
 cmz-derive = { path = "cmz-derive" }
 cmz-derive = { path = "cmz-derive" }
 cmz-core = { path = "cmz-core" }
 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]
 [features]
 # Dump (to stdout or to a string) the value of the instance on both the
 # 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
 with its own set of attributes.  All of the credentials in your
 application should use the _same_ `Scalar` and `Point` types.  You get
 application should use the _same_ `Scalar` and `Point` types.  You get
 these from a mathematical _group_, which must satisfy the trait
 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
 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
 To declare a credential type, use the `CMZ!` macro at the top level of
 your crate or module (outside of any function):
 your crate or module (outside of any function):
@@ -203,7 +203,7 @@ the following signature:
 
 
 ```text
 ```text
     pub fn prepare(
     pub fn prepare(
-        rng: &mut impl RngCore,
+        rng: &mut impl Rng,
         session_id: &[u8],
         session_id: &[u8],
         W: &Wallet,
         W: &Wallet,
         I: &Item,
         I: &Item,
@@ -229,7 +229,7 @@ the following signature:
 
 
 ```text
 ```text
     pub fn handle<F,A>(
     pub fn handle<F,A>(
-        rng: &mut impl RngCore,
+        rng: &mut impl Rng,
         session_id: &[u8],
         session_id: &[u8],
         request: Request,
         request: Request,
         fill_creds: F,
         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 reqf = request_fields.field_iter();
         let csf = clientstate_fields.field_iter();
         let csf = clientstate_fields.field_iter();
         quote! {
         quote! {
-            pub fn prepare(rng: &mut (impl CryptoRng + RngCore),
+            pub fn prepare(rng: &mut (impl CryptoRng + Rng),
                 session_id: &[u8],
                 session_id: &[u8],
                 #(#client_show_args)* #(#client_issue_args)* #client_params_arg)
                 #(#client_show_args)* #(#client_issue_args)* #client_params_arg)
                     -> Result<(Request, ClientState),CMZError> {
                     -> Result<(Request, ClientState),CMZError> {
@@ -1756,7 +1756,7 @@ pub fn cmz_core(
         };
         };
 
 
         quote! {
         quote! {
-            pub fn handle<F,A>(rng: &mut (impl CryptoRng + RngCore),
+            pub fn handle<F,A>(rng: &mut (impl CryptoRng + Rng),
                 session_id: &[u8],
                 session_id: &[u8],
                 request: Request, fill_creds: F, authorize: A)
                 request: Request, fill_creds: F, authorize: A)
                 -> #rettype
                 -> #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)]
                 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>) {
                     (CMZPrivkey<Self::Point>, CMZPubkey<Self::Point>) {
                 // Generate (num_attrs + 2) random scalars as the
                 // Generate (num_attrs + 2) random scalars as the
                 // private key
                 // private key
@@ -163,7 +163,7 @@ fn impl_cmzcred_derive(ast: &syn::DeriveInput, group_ident: &Ident) -> TokenStre
                 Ok(coeff)
                 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)?;
                 let coeff = self.compute_MAC_coeff(privkey)?;
                 self.MAC.P = <Self::Point as group::Group>::random(&mut *rng);
                 self.MAC.P = <Self::Point as group::Group>::random(&mut *rng);
                 self.MAC.Q = coeff * self.MAC.P;
                 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.P = <Self::Point as group::Group>::random(&mut *rng);
                 self.MAC.Q = <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")]
 #[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 }
 ///
 ///

+ 2 - 2
tests/basic.rs

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

+ 3 - 3
tests/priv_serialize.rs

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

+ 6 - 6
tests/rate_limiting.rs

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

+ 2 - 2
tests/submodule.rs

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

+ 4 - 4
tests/wallet.rs

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

Неке датотеке нису приказане због велике количине промена