mirror of
https://github.com/logos-blockchain/lssa-zkvm-testing.git
synced 2026-01-02 13:23:08 +00:00
add comments
This commit is contained in:
parent
e3969d76a3
commit
952b6469c2
@ -71,7 +71,9 @@ pub fn execute<P: Program>(
|
||||
Ok(inputs_outputs)
|
||||
}
|
||||
|
||||
pub fn extract_private_outputs_from_inner_results(
|
||||
/// Builds the private outputs from the results of the execution of an inner program.
|
||||
/// Populates the nonces with the ones provided.
|
||||
pub fn build_private_outputs_from_inner_results(
|
||||
inputs_outputs: &[Account],
|
||||
num_inputs: usize,
|
||||
visibilities: &[InputVisibiility],
|
||||
@ -91,6 +93,9 @@ pub fn extract_private_outputs_from_inner_results(
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Executes and proves the inner program `P` and executes and proves the outer program on top of it.
|
||||
/// Returns the proof of execution of the outer program and the list of new private accounts
|
||||
/// resulted from this execution.
|
||||
pub fn invoke_privacy_execution<P: Program>(
|
||||
inputs: &[Account],
|
||||
instruction_data: P::InstructionData,
|
||||
@ -105,7 +110,6 @@ pub fn invoke_privacy_execution<P: Program>(
|
||||
let output_nonces: Vec<_> = (0..num_inputs).map(|_| new_random_nonce()).collect();
|
||||
|
||||
// Prove outer program.
|
||||
// This computes the nullifiers for the input accounts and commitments for the output accounts.
|
||||
let mut env_builder = ExecutorEnv::builder();
|
||||
env_builder.add_assumption(inner_receipt);
|
||||
env_builder.write(&(num_inputs as u32)).unwrap();
|
||||
@ -115,14 +119,16 @@ pub fn invoke_privacy_execution<P: Program>(
|
||||
env_builder.write(&commitment_tree_root).unwrap();
|
||||
env_builder.write(&P::PROGRAM_ID).unwrap();
|
||||
let env = env_builder.build().unwrap();
|
||||
|
||||
let prover = default_prover();
|
||||
let prove_info = prover.prove(env, OUTER_ELF).unwrap();
|
||||
|
||||
// Build private accounts.
|
||||
let private_outputs =
|
||||
extract_private_outputs_from_inner_results(&inputs_outputs, num_inputs, &visibilities, &output_nonces);
|
||||
build_private_outputs_from_inner_results(&inputs_outputs, num_inputs, &visibilities, &output_nonces);
|
||||
Ok((prove_info.receipt, private_outputs))
|
||||
}
|
||||
|
||||
/// Verifies a proof of the outer program for the given parameters.
|
||||
pub fn verify_privacy_execution(
|
||||
receipt: Receipt,
|
||||
public_accounts_inputs_outputs: &[Account],
|
||||
|
||||
@ -3,6 +3,7 @@ use core::types::ProgramId;
|
||||
use program_methods::{PINATA_ELF, PINATA_ID, TRANSFER_ELF, TRANSFER_ID, TRANSFER_MULTIPLE_ELF, TRANSFER_MULTIPLE_ID};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A trait to be implemented by inner programs.
|
||||
pub trait Program {
|
||||
const PROGRAM_ID: ProgramId;
|
||||
const PROGRAM_ELF: &[u8];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user