瀏覽代碼

prepare and handle will need an rng

Ian Goldberg 6 月之前
父節點
當前提交
7f54f44bce
共有 3 個文件被更改,包括 7 次插入4 次删除
  1. 2 0
      README.md
  2. 4 3
      cmzcred_derive/src/lib.rs
  3. 1 1
      tests/basic.rs

+ 2 - 0
README.md

@@ -200,6 +200,7 @@ the following signature:
 
 ```rust
     pub fn prepare(
+        rng: &mut impl RngCore,
         W: &Wallet,
         I: &Item,
         N: Wallet,
@@ -220,6 +221,7 @@ the following signature:
 
 ```rust
     pub fn handle<F,A>(
+        rng: &mut impl RngCore,
         request: Request,
         fill_creds: F,
         authorize: A,

+ 4 - 3
cmzcred_derive/src/lib.rs

@@ -522,8 +522,8 @@ fn protocol_macro(
 
     // Build the client's prepare function
     let client_func = quote! {
-        pub fn prepare(#(#client_show_args)* #(#client_issue_args)*
-            #client_params_arg)
+        pub fn prepare(rng: &mut impl RngCore,
+            #(#client_show_args)* #(#client_issue_args)* #client_params_arg)
                 -> Result<(Request, ClientState),CMZError> {
             Ok((Request{}, ClientState{}))
         }
@@ -603,7 +603,8 @@ fn protocol_macro(
 
     // Build the issuer's handle function
     let issuer_func = quote! {
-        pub fn handle<F,A>(request: Request, fill_creds: F, authorize: A)
+        pub fn handle<F,A>(rng: &mut impl RngCore,
+            request: Request, fill_creds: F, authorize: A)
             -> #issuer_handle_ret
         where
             F: FnOnce(#(#issuer_fill_creds_args)*) ->

+ 1 - 1
tests/basic.rs

@@ -42,7 +42,7 @@ fn test_basic() {
 
     println!("{:#?}", basic_cred_bytes);
 
-    let (req, state) = basic_proto::prepare(&basic_cred).unwrap();
+    let (req, state) = basic_proto::prepare(&mut rng, &basic_cred).unwrap();
     println!("{req:#?}");
     println!("{state:#?}");
 }