Skip to content

Commit f026643

Browse files
committed
added comments to decrypt_transition() method
1 parent ba99dbe commit f026643

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

wasm/src/ledger/transition.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,12 @@ impl Transition {
207207
compute_function_id(&U16Native::new(CurrentNetwork::ID), self.0.program_id(), self.0.function_name())
208208
.map_err(|e| e.to_string())?;
209209

210+
// Create a vector that will be populated with decrypted private inputs and
211+
// non-private inputs.
210212
let mut decrypted_inputs = Vec::with_capacity(self.0.inputs().len());
211213

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.
212216
for (index, input) in self.0.inputs().iter().enumerate() {
213217
decrypted_inputs.push(match input {
214218
InputNative::Private(input_id, Some(ciphertext)) => {
@@ -224,8 +228,13 @@ impl Transition {
224228

225229
let outputs = self.0.outputs();
226230
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.
227234
let mut decrypted_outputs = Vec::with_capacity(outputs.len());
228235

236+
// Iterate over the outputs and decrypt if they are private. Non-private outputs
237+
// are copied and added to the outputs vector.
229238
for (index, output) in outputs.iter().enumerate() {
230239
decrypted_outputs.push(match output {
231240
OutputNative::Private(output_id, Some(ciphertext)) => {
@@ -239,6 +248,7 @@ impl Transition {
239248
});
240249
}
241250

251+
// The Transition struct is reconstructed with the decrypted inputs and outputs.
242252
Ok(Self(
243253
TransitionNative::new(
244254
*self.0.program_id(),
@@ -249,7 +259,7 @@ impl Transition {
249259
*self.0.tcm(),
250260
*self.0.scm(),
251261
)
252-
.expect("failed to construct decrypted transition"),
262+
.map_err(||"failed to construct decrypted transition".to_string()),
253263
))
254264
}
255265
}

0 commit comments

Comments
 (0)