2025-08-18 18:18:16 -03:00
|
|
|
use risc0_zkvm::serde::to_vec;
|
2025-08-18 07:39:41 -03:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
2025-08-18 14:28:26 -03:00
|
|
|
#[cfg(feature = "host")]
|
|
|
|
|
use crate::error::NssaCoreError;
|
2025-08-18 18:18:16 -03:00
|
|
|
|
2025-08-18 07:39:41 -03:00
|
|
|
use crate::{
|
|
|
|
|
account::{
|
|
|
|
|
Account, AccountWithMetadata, Commitment, Nonce, Nullifier, NullifierPublicKey,
|
|
|
|
|
NullifierSecretKey,
|
|
|
|
|
},
|
|
|
|
|
program::{ProgramId, ProgramOutput},
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-18 14:28:26 -03:00
|
|
|
#[cfg(feature = "host")]
|
|
|
|
|
use std::io::Cursor;
|
|
|
|
|
|
2025-08-06 20:05:04 -03:00
|
|
|
pub mod account;
|
|
|
|
|
pub mod program;
|
2025-08-18 07:39:41 -03:00
|
|
|
|
2025-08-18 14:28:26 -03:00
|
|
|
#[cfg(feature = "host")]
|
|
|
|
|
pub mod error;
|
|
|
|
|
|
2025-08-18 07:39:41 -03:00
|
|
|
pub type CommitmentSetDigest = [u32; 8];
|
|
|
|
|
pub type MembershipProof = Vec<[u8; 32]>;
|
|
|
|
|
pub fn verify_membership_proof(
|
|
|
|
|
commitment: &Commitment,
|
|
|
|
|
proof: &MembershipProof,
|
|
|
|
|
digest: &CommitmentSetDigest,
|
|
|
|
|
) -> bool {
|
|
|
|
|
todo!()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub type IncomingViewingPublicKey = [u8; 32];
|
|
|
|
|
pub type EphemeralSecretKey = [u8; 32];
|
|
|
|
|
pub struct EphemeralPublicKey;
|
|
|
|
|
|
|
|
|
|
impl From<&EphemeralSecretKey> for EphemeralPublicKey {
|
|
|
|
|
fn from(value: &EphemeralSecretKey) -> Self {
|
|
|
|
|
todo!()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct Tag(u8);
|
|
|
|
|
impl Tag {
|
|
|
|
|
pub fn new(Npk: &NullifierPublicKey, Ipk: &IncomingViewingPublicKey) -> Self {
|
|
|
|
|
todo!()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
2025-08-18 14:55:50 -03:00
|
|
|
pub struct EncryptedAccountData(u8);
|
2025-08-18 07:39:41 -03:00
|
|
|
|
|
|
|
|
impl EncryptedAccountData {
|
|
|
|
|
pub fn new(
|
|
|
|
|
account: &Account,
|
|
|
|
|
esk: &EphemeralSecretKey,
|
|
|
|
|
Npk: &NullifierPublicKey,
|
|
|
|
|
Ivk: &IncomingViewingPublicKey,
|
|
|
|
|
) -> Self {
|
|
|
|
|
// TODO: implement
|
2025-08-18 14:55:50 -03:00
|
|
|
Self(0)
|
2025-08-18 07:39:41 -03:00
|
|
|
}
|
2025-08-18 14:28:26 -03:00
|
|
|
|
|
|
|
|
#[cfg(feature = "host")]
|
|
|
|
|
pub fn from_cursor(cursor: &mut Cursor<&[u8]>) -> Result<Self, NssaCoreError> {
|
2025-08-18 14:55:50 -03:00
|
|
|
let dummy_value = EncryptedAccountData(0);
|
|
|
|
|
Ok(dummy_value)
|
2025-08-18 14:28:26 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl EncryptedAccountData {
|
|
|
|
|
pub fn to_bytes(&self) -> Vec<u8> {
|
|
|
|
|
// TODO: implement
|
|
|
|
|
vec![0]
|
|
|
|
|
}
|
2025-08-18 07:39:41 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
|
pub struct PrivacyPreservingCircuitInput {
|
|
|
|
|
pub program_output: ProgramOutput,
|
|
|
|
|
pub visibility_mask: Vec<u8>,
|
2025-08-18 18:18:16 -03:00
|
|
|
pub private_account_nonces: Vec<Nonce>,
|
|
|
|
|
pub private_account_keys: Vec<(
|
2025-08-18 07:39:41 -03:00
|
|
|
NullifierPublicKey,
|
|
|
|
|
IncomingViewingPublicKey,
|
|
|
|
|
EphemeralSecretKey,
|
|
|
|
|
)>,
|
|
|
|
|
pub private_account_auth: Vec<(NullifierSecretKey, MembershipProof)>,
|
|
|
|
|
pub program_id: ProgramId,
|
|
|
|
|
pub commitment_set_digest: CommitmentSetDigest,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
|
pub struct PrivacyPreservingCircuitOutput {
|
|
|
|
|
pub public_pre_states: Vec<AccountWithMetadata>,
|
|
|
|
|
pub public_post_states: Vec<Account>,
|
|
|
|
|
pub encrypted_private_post_states: Vec<EncryptedAccountData>,
|
|
|
|
|
pub new_commitments: Vec<Commitment>,
|
|
|
|
|
pub new_nullifiers: Vec<Nullifier>,
|
|
|
|
|
pub commitment_set_digest: CommitmentSetDigest,
|
|
|
|
|
}
|