File tree 1 file changed +17
-10
lines changed
crates/components/hmac-sha256/src/prf/function
1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ pub(crate) struct PrfFunction {
15
15
start_seed_label : Option < Vec < u8 > > ,
16
16
a : Vec < PHash > ,
17
17
p : Vec < PHash > ,
18
+ assigned : bool ,
18
19
}
19
20
20
21
impl PrfFunction {
@@ -55,19 +56,24 @@ impl PrfFunction {
55
56
}
56
57
57
58
pub ( crate ) fn make_progress ( & mut self , vm : & mut dyn Vm < Binary > ) -> Result < bool , PrfError > {
58
- let a = self . a . first_mut ( ) . expect ( "prf should be allocated" ) ;
59
- let msg = a. msg ;
59
+ let assigned = self . assigned ;
60
60
61
- let msg_value = self
62
- . start_seed_label
63
- . clone ( )
64
- . expect ( "seed should be assigned by now" ) ;
61
+ if !assigned {
62
+ let a = self . a . first_mut ( ) . expect ( "prf should be allocated" ) ;
63
+ let msg = a. msg ;
65
64
66
- vm. mark_public ( msg) . map_err ( PrfError :: vm) ?;
67
- vm. assign ( msg, msg_value) . map_err ( PrfError :: vm) ?;
68
- vm. commit ( msg) . map_err ( PrfError :: vm) ?;
65
+ let msg_value = self
66
+ . start_seed_label
67
+ . clone ( )
68
+ . expect ( "seed should be assigned by now" ) ;
69
69
70
- Ok ( true )
70
+ vm. mark_public ( msg) . map_err ( PrfError :: vm) ?;
71
+ vm. assign ( msg, msg_value) . map_err ( PrfError :: vm) ?;
72
+ vm. commit ( msg) . map_err ( PrfError :: vm) ?;
73
+ }
74
+
75
+ self . assigned = true ;
76
+ Ok ( assigned)
71
77
}
72
78
73
79
pub ( crate ) fn set_start_seed ( & mut self , seed : Vec < u8 > ) {
@@ -93,6 +99,7 @@ impl PrfFunction {
93
99
start_seed_label : None ,
94
100
a : vec ! [ ] ,
95
101
p : vec ! [ ] ,
102
+ assigned : false ,
96
103
} ;
97
104
98
105
assert ! (
You can’t perform that action at this time.
0 commit comments