3
2
Prechádzať zdrojové kódy

The CMZCredential trait should not itself be generic

Ian Goldberg 6 mesiacov pred
rodič
commit
00bca17b9c
2 zmenil súbory, kde vykonal 9 pridanie a 9 odobranie
  1. 1 1
      cmzcred_derive/src/lib.rs
  2. 8 8
      src/lib.rs

+ 1 - 1
cmzcred_derive/src/lib.rs

@@ -55,7 +55,7 @@ fn impl_cmzcred_derive(ast: &syn::DeriveInput, group_ident: &Ident) -> TokenStre
 
     // Output the CMZCredential trait implementation
     let gen = quote! {
-        impl CMZCredential<#group_ident> for #name {
+        impl CMZCredential for #name {
             type Scalar = <#group_ident as Group>::Scalar;
             type Point = #group_ident;
 

+ 8 - 8
src/lib.rs

@@ -169,7 +169,7 @@ pub fn cmz_privkey_to_pubkey<G: PrimeGroup>(privkey: &CMZPrivkey<G>) -> CMZPubke
 }
 
 /// The CMZCredential trait implemented by all CMZ credential struct types.
-pub trait CMZCredential<G: PrimeGroup>
+pub trait CMZCredential
 where
     Self: Default + Sized,
 {
@@ -195,29 +195,29 @@ where
     fn attr_mut(&mut self, name: &str) -> &mut Option<Self::Scalar>;
 
     /// Set the public key for this credential.
-    fn set_pubkey(&mut self, pubkey: &CMZPubkey<G>) -> &mut Self;
+    fn set_pubkey(&mut self, pubkey: &CMZPubkey<Self::Point>) -> &mut Self;
 
     /// Get a copy of the public key for this credential.  If the public
     /// key has not yet been set or computed, a pubkey with X0 == None
     /// will be returned.
-    fn get_pubkey(&self) -> CMZPubkey<G>;
+    fn get_pubkey(&self) -> CMZPubkey<Self::Point>;
 
     /// Set the private key for this credential.  The public key will
     /// automatically be computed from the private key.
-    fn set_privkey(&mut self, privkey: &CMZPrivkey<G>) -> &mut Self;
+    fn set_privkey(&mut self, privkey: &CMZPrivkey<Self::Point>) -> &mut Self;
 
     /// Get a copy of the private key for this credential.  If the
     /// private key has not yet been set, a privkey with an empty x
     /// vector will be returned.
-    fn get_privkey(&self) -> CMZPrivkey<G>;
+    fn get_privkey(&self) -> CMZPrivkey<Self::Point>;
 
     /// Generate random private and public keys for this credential
     /// type.
-    fn gen_keys(rng: &mut impl RngCore) -> (CMZPrivkey<G>, CMZPubkey<G>);
+    fn gen_keys(rng: &mut impl RngCore) -> (CMZPrivkey<Self::Point>, CMZPubkey<Self::Point>);
 
     /// Convenience function for creating a new Self, and loading the
     /// given private key (which will also compute the public key).
-    fn using_privkey(privkey: &CMZPrivkey<G>) -> Self {
+    fn using_privkey(privkey: &CMZPrivkey<Self::Point>) -> Self {
         let mut slf = Self::default();
         slf.set_privkey(privkey);
         slf
@@ -225,7 +225,7 @@ where
 
     /// Convenience function for creating a new Self, and loading the
     /// given public key.
-    fn using_pubkey(pubkey: &CMZPubkey<G>) -> Self {
+    fn using_pubkey(pubkey: &CMZPubkey<Self::Point>) -> Self {
         let mut slf = Self::default();
         slf.set_pubkey(pubkey);
         slf