add privacy preserving transaction scaffolding

This commit is contained in:
Sergio Chouhy 2025-08-14 12:10:27 -03:00
parent fe06a22589
commit 35ffb65df0
9 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,2 @@
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Commitment([u8; 32]);

View File

@ -2,6 +2,12 @@ use serde::{Deserialize, Serialize};
use crate::program::ProgramId; use crate::program::ProgramId;
mod commitment;
mod nullifier;
pub use commitment::Commitment;
pub use nullifier::Nullifier;
pub type Nonce = u128; pub type Nonce = u128;
type Data = Vec<u8>; type Data = Vec<u8>;

View File

@ -0,0 +1,2 @@
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Nullifier([u8; 32]);

View File

@ -2,6 +2,7 @@ mod address;
pub mod error; pub mod error;
pub mod program; pub mod program;
pub mod public_transaction; pub mod public_transaction;
mod privacy_preserving_transaction;
mod signature; mod signature;
mod state; mod state;

View File

@ -0,0 +1,16 @@
use nssa_core::account::{Account, Commitment, Nonce, Nullifier};
use crate::Address;
#[derive(Debug, Clone, PartialEq, Eq)]
struct EncryptedAccountData;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Message {
public_addresses: Vec<Address>,
nonces: Vec<Nonce>,
public_post_states: Vec<Account>,
encrypted_private_post_states: Vec<EncryptedAccountData>,
new_commitments: Vec<Commitment>,
new_nullifiers: Vec<Nullifier>,
}

View File

@ -0,0 +1,3 @@
mod transaction;
mod message;
mod witness_set;

View File

@ -0,0 +1,10 @@
use super::message::Message;
use super::witness_set::WitnessSet;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PrivacyPreservingTransaction {
message: Message,
witness_set: WitnessSet,
}

View File

@ -0,0 +1,2 @@
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WitnessSet;

View File

@ -57,6 +57,13 @@ impl Program {
Ok(post_states) Ok(post_states)
} }
pub fn prove(
&self,
pre_states: &[AccountWithMetadata],
instruction_data: &InstructionData,
) {
}
/// Writes inputs to `env_builder` in the order expected by the programs /// Writes inputs to `env_builder` in the order expected by the programs
fn write_inputs( fn write_inputs(
pre_states: &[AccountWithMetadata], pre_states: &[AccountWithMetadata],