@@ -207,8 +207,12 @@ impl Transition {
207
207
compute_function_id ( & U16Native :: new ( CurrentNetwork :: ID ) , self . 0 . program_id ( ) , self . 0 . function_name ( ) )
208
208
. map_err ( |e| e. to_string ( ) ) ?;
209
209
210
+ // Create a vector that will be populated with decrypted private inputs and
211
+ // non-private inputs.
210
212
let mut decrypted_inputs = Vec :: with_capacity ( self . 0 . inputs ( ) . len ( ) ) ;
211
213
214
+ // Iterate over the inputs and decrypt if they are private. Non-private inputs
215
+ // such as public inputs and records are copied and added to the inputs vector.
212
216
for ( index, input) in self . 0 . inputs ( ) . iter ( ) . enumerate ( ) {
213
217
decrypted_inputs. push ( match input {
214
218
InputNative :: Private ( input_id, Some ( ciphertext) ) => {
@@ -224,8 +228,13 @@ impl Transition {
224
228
225
229
let outputs = self . 0 . outputs ( ) ;
226
230
let num_inputs = self . 0 . inputs ( ) . len ( ) ;
231
+
232
+ // Create a vector that will be populated with decrypted private outputs and
233
+ // non-private outputs.
227
234
let mut decrypted_outputs = Vec :: with_capacity ( outputs. len ( ) ) ;
228
235
236
+ // Iterate over the outputs and decrypt if they are private. Non-private outputs
237
+ // are copied and added to the outputs vector.
229
238
for ( index, output) in outputs. iter ( ) . enumerate ( ) {
230
239
decrypted_outputs. push ( match output {
231
240
OutputNative :: Private ( output_id, Some ( ciphertext) ) => {
@@ -239,6 +248,7 @@ impl Transition {
239
248
} ) ;
240
249
}
241
250
251
+ // The Transition struct is reconstructed with the decrypted inputs and outputs.
242
252
Ok ( Self (
243
253
TransitionNative :: new (
244
254
* self . 0 . program_id ( ) ,
@@ -249,7 +259,7 @@ impl Transition {
249
259
* self . 0 . tcm ( ) ,
250
260
* self . 0 . scm ( ) ,
251
261
)
252
- . expect ( "failed to construct decrypted transition" ) ,
262
+ . map_err ( || "failed to construct decrypted transition" . to_string ( ) ) ,
253
263
) )
254
264
}
255
265
}
0 commit comments