mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-07-09 23:39:34 +00:00
feat(circuit): use dummy_inputs in ppc
This commit is contained in:
parent
35df009837
commit
8c7f3764a5
@ -9,6 +9,7 @@ fn main() {
|
||||
program_outputs,
|
||||
account_identities,
|
||||
program_id,
|
||||
dummy_inputs,
|
||||
} = env::read();
|
||||
|
||||
let execution_state = execution_state::ExecutionState::derive_from_outputs(
|
||||
@ -17,7 +18,8 @@ fn main() {
|
||||
program_outputs,
|
||||
);
|
||||
|
||||
let output = output::compute_circuit_output(execution_state, &account_identities);
|
||||
let output =
|
||||
output::compute_circuit_output(execution_state, &account_identities, dummy_inputs);
|
||||
|
||||
env::commit(&output);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use lee_core::{
|
||||
Commitment, CommitmentSetDigest, EncryptedAccountData, EncryptionScheme, EphemeralSecretKey,
|
||||
Commitment, CommitmentSetDigest, DummyInput, EncryptedAccountData, EncryptionScheme, EphemeralSecretKey,
|
||||
InputAccountIdentity, MembershipProof, Nullifier, NullifierPublicKey, NullifierSecretKey,
|
||||
PrivacyPreservingCircuitOutput, PrivateAccountKind, SharedSecretKey,
|
||||
account::{Account, AccountId, Nonce},
|
||||
@ -12,6 +12,7 @@ use crate::execution_state::ExecutionState;
|
||||
pub fn compute_circuit_output(
|
||||
execution_state: ExecutionState,
|
||||
account_identities: &[InputAccountIdentity],
|
||||
dummy_inputs: Vec<DummyInput>,
|
||||
) -> PrivacyPreservingCircuitOutput {
|
||||
let (block_validity_window, timestamp_validity_window, pda_seed_by_position, states_iter) =
|
||||
execution_state.into_parts();
|
||||
@ -262,9 +263,21 @@ pub fn compute_circuit_output(
|
||||
}
|
||||
}
|
||||
|
||||
for dummy in dummy_inputs {
|
||||
emit_dummy_output(&mut output, dummy);
|
||||
}
|
||||
|
||||
output
|
||||
}
|
||||
|
||||
fn emit_dummy_output(output: &mut PrivacyPreservingCircuitOutput, dummy: DummyInput) {
|
||||
let nullifier = Nullifier::for_dummy(&dummy.nullifier_seed);
|
||||
let commitment = Commitment::for_dummy(&nullifier, &dummy.commitment_seed);
|
||||
output.new_nullifiers.push((nullifier, dummy.commitment_root));
|
||||
output.new_commitments.push(commitment);
|
||||
output.encrypted_private_post_states.push(dummy.note);
|
||||
}
|
||||
|
||||
#[expect(
|
||||
clippy::too_many_arguments,
|
||||
reason = "Inputs are distinct concerns from the variant arms; bundling would be artificial"
|
||||
|
||||
@ -19,6 +19,7 @@ pub struct PrivacyPreservingCircuitInput {
|
||||
pub account_identities: Vec<InputAccountIdentity>,
|
||||
/// Program ID.
|
||||
pub program_id: ProgramId,
|
||||
pub dummy_inputs: Vec<DummyInput>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
|
||||
@ -2,7 +2,7 @@ use std::collections::{HashMap, VecDeque};
|
||||
|
||||
use borsh::{BorshDeserialize, BorshSerialize};
|
||||
use lee_core::{
|
||||
InputAccountIdentity, PrivacyPreservingCircuitInput, PrivacyPreservingCircuitOutput,
|
||||
DummyInput, InputAccountIdentity, PrivacyPreservingCircuitInput, PrivacyPreservingCircuitOutput,
|
||||
account::AccountWithMetadata,
|
||||
program::{ChainedCall, InstructionData, ProgramId, ProgramOutput},
|
||||
};
|
||||
@ -69,6 +69,22 @@ pub fn execute_and_prove(
|
||||
instruction_data: InstructionData,
|
||||
account_identities: Vec<InputAccountIdentity>,
|
||||
program_with_dependencies: &ProgramWithDependencies,
|
||||
) -> Result<(PrivacyPreservingCircuitOutput, Proof), LeeError> {
|
||||
execute_and_prove_with_dummy_inputs(
|
||||
pre_states,
|
||||
instruction_data,
|
||||
account_identities,
|
||||
vec![],
|
||||
program_with_dependencies,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn execute_and_prove_with_dummy_inputs(
|
||||
pre_states: Vec<AccountWithMetadata>,
|
||||
instruction_data: InstructionData,
|
||||
account_identities: Vec<InputAccountIdentity>,
|
||||
dummy_inputs: Vec<DummyInput>,
|
||||
program_with_dependencies: &ProgramWithDependencies,
|
||||
) -> Result<(PrivacyPreservingCircuitOutput, Proof), LeeError> {
|
||||
let ProgramWithDependencies {
|
||||
program: initial_program,
|
||||
@ -127,6 +143,7 @@ pub fn execute_and_prove(
|
||||
program_outputs,
|
||||
account_identities,
|
||||
program_id: program_with_dependencies.program.id(),
|
||||
dummy_inputs,
|
||||
};
|
||||
|
||||
env_builder.write(&circuit_input).unwrap();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user