add privateaccountkind

This commit is contained in:
Sergio Chouhy 2026-05-01 00:49:28 -03:00
parent 0eb128e515
commit 64a8ea5807
2 changed files with 30 additions and 2 deletions

View File

@ -8,12 +8,40 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "host")]
pub use shared_key_derivation::{EphemeralPublicKey, EphemeralSecretKey, ViewingPublicKey};
use crate::{Commitment, Identifier, account::Account};
use crate::{
Commitment, Identifier,
account::Account,
program::{PdaSeed, ProgramId},
};
#[cfg(feature = "host")]
pub mod shared_key_derivation;
pub type Scalar = [u8; 32];
/// Discriminates the type of private account a ciphertext belongs to, carrying the data needed
/// to reconstruct the account's [`AccountId`] on the receiver side.
///
/// [`AccountId`]: crate::account::AccountId
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PrivateAccountKind {
Account(Identifier),
Pda {
program_id: ProgramId,
seed: PdaSeed,
identifier: Identifier,
},
}
impl PrivateAccountKind {
#[must_use]
pub fn identifier(&self) -> Identifier {
match self {
Self::Account(identifier) => *identifier,
Self::Pda { identifier, .. } => *identifier,
}
}
}
#[derive(Serialize, Deserialize, Clone, Copy)]
pub struct SharedSecretKey(pub [u8; 32]);

View File

@ -8,7 +8,7 @@ pub use commitment::{
Commitment, CommitmentSetDigest, DUMMY_COMMITMENT, DUMMY_COMMITMENT_HASH, MembershipProof,
compute_digest_for_path,
};
pub use encryption::{EncryptionScheme, SharedSecretKey};
pub use encryption::{EncryptionScheme, PrivateAccountKind, SharedSecretKey};
pub use nullifier::{Identifier, Nullifier, NullifierPublicKey, NullifierSecretKey};
pub mod account;