Browse Source

Add set_keypair function to CMZ credentials

Set both the private and public keys, without recomputing the public key
from the private key
Ian Goldberg 2 weeks ago
parent
commit
3ffaa57daa
2 changed files with 14 additions and 0 deletions
  1. 7 0
      cmz-derive/src/lib.rs
  2. 7 0
      src/lib.rs

+ 7 - 0
cmz-derive/src/lib.rs

@@ -112,6 +112,13 @@ fn impl_cmzcred_derive(ast: &syn::DeriveInput, group_ident: &Ident) -> TokenStre
                 self
             }
 
+            fn set_keypair(&mut self, privkey: &CMZPrivkey<Self::Point>,
+                    pubkey: &CMZPubkey<Self::Point>) -> &mut Self {
+                self.pubkey = pubkey.clone();
+                self.privkey = privkey.clone();
+                self
+            }
+
             fn get_privkey<'a> (&'a self) -> &'a CMZPrivkey<Self::Point> {
                 &self.privkey
             }

+ 7 - 0
src/lib.rs

@@ -325,6 +325,13 @@ where
     /// automatically be computed from the private key.
     fn set_privkey(&mut self, privkey: &CMZPrivkey<Self::Point>) -> &mut Self;
 
+    /// Set the private and public keys for this credential.
+    fn set_keypair(
+        &mut self,
+        privkey: &CMZPrivkey<Self::Point>,
+        pubkey: &CMZPubkey<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.