refactor: revert host crates to AccountId derivation constructors

This commit is contained in:
Artem Gureev 2026-06-30 17:58:53 +00:00 committed by agureev
parent 6fa05fa847
commit f14fe836c6
20 changed files with 137 additions and 182 deletions

View File

@ -156,12 +156,11 @@ async fn import_private_account() -> Result<()> {
let mut ctx = TestContext::new().await?;
let key_chain = KeyChain::new_os_random();
let account_id = lee::PrivateAddressPlaintext::new(
let account_id = lee::AccountId::for_regular_private_account(
key_chain.nullifier_public_key,
&key_chain.viewing_public_key,
0,
)
.account_id();
);
let account = lee::Account {
program_owner: Program::authenticated_transfer_program().id(),
balance: 777,
@ -218,12 +217,11 @@ async fn import_private_account_second_time_overrides_account_data() -> Result<(
let mut ctx = TestContext::new().await?;
let key_chain = KeyChain::new_os_random();
let account_id = lee::PrivateAddressPlaintext::new(
let account_id = lee::AccountId::for_regular_private_account(
key_chain.nullifier_public_key,
&key_chain.viewing_public_key,
0,
)
.account_id();
);
let key_chain_json =
serde_json::to_string(&key_chain).context("Failed to serialize key chain")?;

View File

@ -7,7 +7,7 @@ use integration_tests::{
public_mention, verify_commitment_is_in_state,
};
use lee::{
AccountId, PrivateAddressPlaintext, execute_and_prove,
AccountId, execute_and_prove,
privacy_preserving_transaction::circuit::ProgramWithDependencies, program::Program,
};
use lee_core::{
@ -599,14 +599,14 @@ async fn shielded_transfers_to_two_identifiers_same_npk() -> Result<()> {
.await?;
// Both accounts must be discovered with the correct balances.
let account_id_1 = PrivateAddressPlaintext::new(npk, &vpk, identifier_1).account_id();
let account_id_1 = AccountId::for_regular_private_account(npk, &vpk, identifier_1);
let acc_1 = ctx
.wallet()
.get_account_private(account_id_1)
.context("account for identifier 1 not found after sync")?;
assert_eq!(acc_1.balance, 100);
let account_id_2 = PrivateAddressPlaintext::new(npk, &vpk, identifier_2).account_id();
let account_id_2 = AccountId::for_regular_private_account(npk, &vpk, identifier_2);
let acc_2 = ctx
.wallet()
.get_account_private(account_id_2)
@ -667,7 +667,7 @@ async fn ppt_cant_chain_call_faucet() -> Result<()> {
let vpk = ViewingPublicKey::from_bytes(vec![4_u8; 1184]).unwrap();
let attacker_vault_id = {
let seed = vault_core::compute_vault_seed(attacker_id);
PrivateAddressPlaintext::new(npk, &vpk, 1337).pda_account_id(&vault_program_id, &seed)
AccountId::for_regular_private_account(npk, &vpk, 1337).pda(&vault_program_id, &seed)
};
let amount: u128 = 1;

View File

@ -13,7 +13,7 @@ use integration_tests::{
verify_commitment_is_in_state,
};
use lee::{
AccountId, PrivacyPreservingTransaction, PrivateAddressPlaintext, ProgramId,
AccountId, PrivacyPreservingTransaction, ProgramId,
privacy_preserving_transaction::{
circuit::{ProgramWithDependencies, execute_and_prove},
message::Message,
@ -51,8 +51,7 @@ async fn fund_private_pda(
amount: u128,
auth_transfer: &ProgramWithDependencies,
) -> Result<()> {
let pda_account_id = PrivateAddressPlaintext::new(npk, &vpk, identifier)
.pda_account_id(&authority_program_id, &seed);
let pda_account_id = AccountId::for_regular_private_account(npk, &vpk, identifier).pda(&authority_program_id, &seed);
let sender_account = wallet
.get_account_public(sender)
.await
@ -178,9 +177,9 @@ async fn private_pda_family_members_receive_and_spend() -> Result<()> {
ProgramWithDependencies::new(proxy, [(auth_transfer_id, auth_transfer)].into());
let alice_pda_0_id =
PrivateAddressPlaintext::new(alice_npk, &alice_vpk, 0).pda_account_id(&proxy_id, &seed);
AccountId::for_regular_private_account(alice_npk, &alice_vpk, 0).pda(&proxy_id, &seed);
let alice_pda_1_id =
PrivateAddressPlaintext::new(alice_npk, &alice_vpk, 1).pda_account_id(&proxy_id, &seed);
AccountId::for_regular_private_account(alice_npk, &alice_vpk, 1).pda(&proxy_id, &seed);
// Use two different public senders to avoid nonce conflicts between the back-to-back txs.
let senders = ctx.existing_public_accounts();

View File

@ -16,7 +16,7 @@ use bytesize::ByteSize;
use common::transaction::LeeTransaction;
use integration_tests::{TestContext, config::SequencerPartialConfig};
use lee::{
Account, AccountId, PrivacyPreservingTransaction, PrivateAddressPlaintext, PrivateKey,
Account, AccountId, PrivacyPreservingTransaction, PrivateKey,
PublicKey, PublicTransaction,
privacy_preserving_transaction::{self as pptx, circuit},
program::Program,
@ -266,7 +266,7 @@ fn build_privacy_transaction() -> PrivacyPreservingTransaction {
data: Data::default(),
},
true,
PrivateAddressPlaintext::new(sender_npk, &sender_vpk, 0).account_id(),
AccountId::for_regular_private_account(sender_npk, &sender_vpk, 0),
);
let recipient_nsk = [2; 32];
let recipient_vpk = ViewingPublicKey::from_seed(&[101_u8; 32], &[102_u8; 32]);
@ -274,7 +274,7 @@ fn build_privacy_transaction() -> PrivacyPreservingTransaction {
let recipient_pre = AccountWithMetadata::new(
Account::default(),
false,
PrivateAddressPlaintext::new(recipient_npk, &recipient_vpk, 0).account_id(),
AccountId::for_regular_private_account(recipient_npk, &recipient_vpk, 0),
);
let balance_to_move: u128 = 1;

View File

@ -908,8 +908,7 @@ fn test_wallet_ffi_transfer_shielded() -> Result<()> {
let mut out_keys = FfiPrivateAccountKeys::default();
wallet_ffi_create_private_accounts_key(wallet_ffi_handle, &raw mut out_keys).unwrap();
let account_id =
lee::PrivateAddressPlaintext::new(out_keys.npk(), &out_keys.vpk().unwrap(), 0_u128)
.account_id();
lee::AccountId::for_regular_private_account(out_keys.npk(), &out_keys.vpk().unwrap(), 0_u128);
let to: FfiBytes32 = account_id.into();
(to, out_keys)
};
@ -1047,8 +1046,7 @@ fn test_wallet_ffi_transfer_private() -> Result<()> {
let mut out_keys = FfiPrivateAccountKeys::default();
wallet_ffi_create_private_accounts_key(wallet_ffi_handle, &raw mut out_keys).unwrap();
let account_id =
lee::PrivateAddressPlaintext::new(out_keys.npk(), &out_keys.vpk().unwrap(), 0_u128)
.account_id();
lee::AccountId::for_regular_private_account(out_keys.npk(), &out_keys.vpk().unwrap(), 0_u128);
let to: FfiBytes32 = account_id.into();
(to, out_keys)
};

View File

@ -327,7 +327,7 @@ mod tests {
/// pattern from `for_private_pda_matches_pinned_value` in `lee_core`.
#[test]
fn pinned_end_to_end_derivation_for_private_pda() {
use lee_core::{account::PrivateAddressPlaintext, program::ProgramId};
use lee_core::{account::AccountId, program::ProgramId};
let gms = [42_u8; 32];
let seed = PdaSeed::new([1; 32]);
@ -338,7 +338,7 @@ mod tests {
let npk = keys.generate_nullifier_public_key();
let vpk = keys.generate_viewing_public_key();
let account_id =
PrivateAddressPlaintext::new(npk, &vpk, u128::MAX).pda_account_id(&program_id, &seed);
AccountId::for_regular_private_account(npk, &vpk, u128::MAX).pda(&program_id, &seed);
let expected_npk = NullifierPublicKey([
136, 176, 234, 71, 208, 8, 143, 142, 126, 155, 132, 18, 71, 27, 88, 56, 100, 90, 79,
@ -346,8 +346,7 @@ mod tests {
]);
// AccountId is derived from (program_id, seed, npk), so it changes when npk changes.
// We verify npk is pinned, and AccountId is deterministically derived from it.
let expected_account_id = PrivateAddressPlaintext::new(expected_npk, &vpk, u128::MAX)
.pda_account_id(&program_id, &seed);
let expected_account_id = AccountId::for_regular_private_account(expected_npk, &vpk, u128::MAX).pda(&program_id, &seed);
assert_eq!(npk, expected_npk);
assert_eq!(account_id, expected_account_id);
@ -525,7 +524,7 @@ mod tests {
/// Full lifecycle: create group, distribute GMS via seal/unseal, verify key agreement.
#[test]
fn group_pda_lifecycle() {
use lee_core::account::PrivateAddressPlaintext;
use lee_core::account::AccountId;
let alice_holder = GroupKeyHolder::new();
let pda_seed = PdaSeed::new([42_u8; 32]);
@ -550,10 +549,8 @@ mod tests {
let alice_vpk = alice_keys.generate_viewing_public_key();
let bob_group_vpk = bob_group_keys.generate_viewing_public_key();
let alice_account_id = PrivateAddressPlaintext::new(alice_npk, &alice_vpk, 0)
.pda_account_id(&program_id, &pda_seed);
let bob_account_id = PrivateAddressPlaintext::new(bob_npk, &bob_group_vpk, 0)
.pda_account_id(&program_id, &pda_seed);
let alice_account_id = AccountId::for_regular_private_account(alice_npk, &alice_vpk, 0).pda(&program_id, &pda_seed);
let bob_account_id = AccountId::for_regular_private_account(bob_npk, &bob_group_vpk, 0).pda(&program_id, &pda_seed);
assert_eq!(alice_account_id, bob_account_id);
}

View File

@ -275,12 +275,11 @@ impl KeyTree<ChildKeysPrivate> {
identifier: Identifier,
) -> Option<lee::AccountId> {
let node = self.key_map.get(cci)?;
let account_id = lee::PrivateAddressPlaintext::new(
let account_id = lee::AccountId::for_regular_private_account(
node.value.0.nullifier_public_key,
&node.value.0.viewing_public_key,
identifier,
)
.account_id();
);
if self.account_id_map.contains_key(&account_id) {
return None;
}

View File

@ -5,7 +5,7 @@
pub use lee_core::{
GENESIS_BLOCK_ID, SharedSecretKey,
account::{Account, AccountId, Data, PrivateAddressPlaintext},
account::{Account, AccountId, Data},
encryption::EphemeralPublicKey,
program::ProgramId,
};

View File

@ -181,7 +181,7 @@ mod tests {
Commitment, DUMMY_COMMITMENT_HASH, EncryptionScheme, EphemeralSecretKey, Nullifier,
PrivacyPreservingCircuitOutput, SharedSecretKey,
account::{
Account, AccountId, AccountWithMetadata, Nonce, PrivateAddressPlaintext, data::Data,
Account, AccountId, AccountWithMetadata, Nonce, data::Data,
},
program::{PdaSeed, PrivateAccountKind},
};
@ -238,8 +238,7 @@ mod tests {
);
let recipient_account_id =
PrivateAddressPlaintext::new(recipient_keys.npk(), &recipient_keys.vpk(), 0)
.account_id();
AccountId::for_regular_private_account(recipient_keys.npk(), &recipient_keys.vpk(), 0);
let recipient = AccountWithMetadata::new(Account::default(), false, recipient_account_id);
let balance_to_move: u128 = 37;
@ -319,15 +318,14 @@ mod tests {
data: Data::default(),
},
true,
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0),
);
let sender_account_id =
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id();
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0);
let commitment_sender = Commitment::new(&sender_account_id, &sender_pre.account);
let recipient_account_id =
PrivateAddressPlaintext::new(recipient_keys.npk(), &recipient_keys.vpk(), 0)
.account_id();
AccountId::for_regular_private_account(recipient_keys.npk(), &recipient_keys.vpk(), 0);
let recipient = AccountWithMetadata::new(Account::default(), false, recipient_account_id);
let balance_to_move: u128 = 37;
@ -433,7 +431,7 @@ mod tests {
let pre = AccountWithMetadata::new(
Account::default(),
false,
PrivateAddressPlaintext::new(account_keys.npk(), &account_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(account_keys.npk(), &account_keys.vpk(), 0),
);
let validity_window_chain_caller = Program::validity_window_chain_caller();
@ -477,8 +475,7 @@ mod tests {
let npk = keys.npk();
let seed = PdaSeed::new([42; 32]);
let identifier: u128 = 99;
let account_id = PrivateAddressPlaintext::new(npk, &keys.vpk(), identifier)
.pda_account_id(&program.id(), &seed);
let account_id = AccountId::for_regular_private_account(npk, &keys.vpk(), identifier).pda(&program.id(), &seed);
let init_nonce = Nonce::private_account_nonce_init(&account_id);
let esk = EphemeralSecretKey::new(&account_id, &[0; 32], &init_nonce);
let shared_secret = SharedSecretKey::encapsulate_deterministic(&keys.vpk(), &esk).0;
@ -522,7 +519,7 @@ mod tests {
// PDA (new, private PDA)
let pda_id =
PrivateAddressPlaintext::new(npk, &keys.vpk(), 0).pda_account_id(&program.id(), &seed);
AccountId::for_regular_private_account(npk, &keys.vpk(), 0).pda(&program.id(), &seed);
let pda_pre = AccountWithMetadata::new(Account::default(), false, pda_id);
let auth_id = auth_transfer.id();
@ -562,7 +559,7 @@ mod tests {
// PDA (new, private PDA)
let pda_id =
PrivateAddressPlaintext::new(npk, &keys.vpk(), 0).pda_account_id(&program.id(), &seed);
AccountId::for_regular_private_account(npk, &keys.vpk(), 0).pda(&program.id(), &seed);
let pda_pre = AccountWithMetadata::new(Account::default(), false, pda_id);
// Recipient (public)
@ -630,8 +627,7 @@ mod tests {
// Recipient: shared private account (new, unauthorized)
let shared_account_id =
PrivateAddressPlaintext::new(shared_npk, &shared_keys.vpk(), shared_identifier)
.account_id();
AccountId::for_regular_private_account(shared_npk, &shared_keys.vpk(), shared_identifier);
let recipient = AccountWithMetadata::new(Account::default(), false, shared_account_id);
let balance_to_move: u128 = 100;
@ -669,7 +665,7 @@ mod tests {
let keys = test_private_account_keys_1();
let identifier: u128 = 99;
let account_id =
PrivateAddressPlaintext::new(keys.npk(), &keys.vpk(), identifier).account_id();
AccountId::for_regular_private_account(keys.npk(), &keys.vpk(), identifier);
let nonce = Nonce::private_account_nonce_init(&account_id);
let esk = EphemeralSecretKey::new(&account_id, &[0; 32], &nonce);
let ssk = SharedSecretKey::encapsulate_deterministic(&keys.vpk(), &esk).0;
@ -703,7 +699,7 @@ mod tests {
let keys = test_private_account_keys_1();
let identifier: u128 = 99;
let account_id =
PrivateAddressPlaintext::new(keys.npk(), &keys.vpk(), identifier).account_id();
AccountId::for_regular_private_account(keys.npk(), &keys.vpk(), identifier);
let pre = AccountWithMetadata::new(Account::default(), true, account_id);
let (output, _) = execute_and_prove(
@ -749,7 +745,7 @@ mod tests {
let identifier: u128 = 99;
// create an account id with one set of viewing keys
let account_id =
PrivateAddressPlaintext::new(keys.npk(), &keys.vpk(), identifier).account_id();
AccountId::for_regular_private_account(keys.npk(), &keys.vpk(), identifier);
let pre = AccountWithMetadata::new(Account::default(), true, account_id);
let result = execute_and_prove(
@ -778,7 +774,7 @@ mod tests {
let keys = test_private_account_keys_1();
let identifier: u128 = 99;
let recipient_id =
PrivateAddressPlaintext::new(keys.npk(), &keys.vpk(), identifier).account_id();
AccountId::for_regular_private_account(keys.npk(), &keys.vpk(), identifier);
let init_nonce = Nonce::private_account_nonce_init(&recipient_id);
let esk = EphemeralSecretKey::new(&recipient_id, &[0; 32], &init_nonce);
let ssk = SharedSecretKey::encapsulate_deterministic(&keys.vpk(), &esk).0;
@ -827,7 +823,7 @@ mod tests {
let keys = test_private_account_keys_1();
let identifier: u128 = 99;
let account_id =
PrivateAddressPlaintext::new(keys.npk(), &keys.vpk(), identifier).account_id();
AccountId::for_regular_private_account(keys.npk(), &keys.vpk(), identifier);
let update_nonce = Nonce::default().private_account_nonce_increment(&keys.nsk);
let esk = EphemeralSecretKey::new(&account_id, &[0; 32], &update_nonce);
let ssk = SharedSecretKey::encapsulate_deterministic(&keys.vpk(), &esk).0;
@ -880,8 +876,7 @@ mod tests {
let seed = PdaSeed::new([42; 32]);
let identifier: u128 = 99;
let auth_transfer_id = auth_transfer.id();
let pda_id = PrivateAddressPlaintext::new(npk, &keys.vpk(), identifier)
.pda_account_id(&program.id(), &seed);
let pda_id = AccountId::for_regular_private_account(npk, &keys.vpk(), identifier).pda(&program.id(), &seed);
let update_nonce = Nonce::default().private_account_nonce_increment(&keys.nsk);
let esk = EphemeralSecretKey::new(&pda_id, &[0; 32], &update_nonce);
let ssk = SharedSecretKey::encapsulate_deterministic(&keys.vpk(), &esk).0;
@ -938,7 +933,7 @@ mod tests {
let npk = keys.npk();
let seed = PdaSeed::new([42; 32]);
let account_id =
PrivateAddressPlaintext::new(npk, &keys.vpk(), 5).pda_account_id(&program.id(), &seed);
AccountId::for_regular_private_account(npk, &keys.vpk(), 5).pda(&program.id(), &seed);
let pre_state = AccountWithMetadata::new(Account::default(), false, account_id);
let result = execute_and_prove(
@ -966,7 +961,7 @@ mod tests {
let seed = PdaSeed::new([42; 32]);
let auth_transfer_id = auth_transfer.id();
let pda_id =
PrivateAddressPlaintext::new(npk, &keys.vpk(), 5).pda_account_id(&program.id(), &seed);
AccountId::for_regular_private_account(npk, &keys.vpk(), 5).pda(&program.id(), &seed);
let pda_account = Account {
program_owner: auth_transfer_id,
balance: 1,

View File

@ -120,11 +120,11 @@ pub mod tests {
let encrypted_private_post_states = Vec::new();
let account_id2 =
lee_core::account::PrivateAddressPlaintext::new(npk2, &vpk, 0).account_id();
lee_core::account::AccountId::for_regular_private_account(npk2, &vpk, 0);
let new_commitments = vec![Commitment::new(&account_id2, &account2)];
let account_id1 =
lee_core::account::PrivateAddressPlaintext::new(npk1, &vpk, 0).account_id();
lee_core::account::AccountId::for_regular_private_account(npk1, &vpk, 0);
let old_commitment = Commitment::new(&account_id1, &account1);
let new_nullifiers = vec![(
Nullifier::for_account_update(&old_commitment, &nsk1),
@ -200,7 +200,7 @@ pub mod tests {
let npk = NullifierPublicKey::from(&[1; 32]);
let vpk = ViewingPublicKey::from_seed(&[2_u8; 32], &[3_u8; 32]);
let account = Account::default();
let account_id = lee_core::account::PrivateAddressPlaintext::new(npk, &vpk, 0).account_id();
let account_id = lee_core::account::AccountId::for_regular_private_account(npk, &vpk, 0);
let commitment = Commitment::new(&account_id, &account);
let (shared_secret, epk) =
SharedSecretKey::encapsulate_deterministic(&vpk, &EphemeralSecretKey([0_u8; 32]));

View File

@ -421,7 +421,7 @@ pub mod tests {
BlockId, Commitment, InputAccountIdentity, Nullifier, NullifierPublicKey,
NullifierSecretKey, Timestamp,
account::{
Account, AccountId, AccountWithMetadata, Nonce, PrivateAddressPlaintext, data::Data,
Account, AccountId, AccountWithMetadata, Nonce, data::Data,
},
encryption::ViewingPublicKey,
program::{
@ -519,7 +519,7 @@ pub mod tests {
#[must_use]
pub fn with_private_account(mut self, keys: &TestPrivateKeys, account: &Account) -> Self {
let account_id = PrivateAddressPlaintext::new(keys.npk(), &keys.vpk(), 0).account_id();
let account_id = AccountId::for_regular_private_account(keys.npk(), &keys.vpk(), 0);
let commitment = Commitment::new(&account_id, account);
self.private_state.0.extend(&[commitment]);
self
@ -731,8 +731,8 @@ pub mod tests {
..Account::default()
};
let account_id1 = PrivateAddressPlaintext::new(keys1.npk(), &keys1.vpk(), 0).account_id();
let account_id2 = PrivateAddressPlaintext::new(keys2.npk(), &keys2.vpk(), 0).account_id();
let account_id1 = AccountId::for_regular_private_account(keys1.npk(), &keys1.vpk(), 0);
let account_id2 = AccountId::for_regular_private_account(keys2.npk(), &keys2.vpk(), 0);
let init_commitment1 = Commitment::new(&account_id1, &account);
let init_commitment2 = Commitment::new(&account_id2, &account);
@ -1408,8 +1408,7 @@ pub mod tests {
let recipient = AccountWithMetadata::new(
Account::default(),
false,
PrivateAddressPlaintext::new(recipient_keys.npk(), &recipient_keys.vpk(), 0)
.account_id(),
AccountId::for_regular_private_account(recipient_keys.npk(), &recipient_keys.vpk(), 0),
);
let (output, proof) = circuit::execute_and_prove(
@ -1451,18 +1450,17 @@ pub mod tests {
) -> PrivacyPreservingTransaction {
let program = Program::authenticated_transfer_program();
let sender_account_id =
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id();
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0);
let sender_commitment = Commitment::new(&sender_account_id, sender_private_account);
let sender_pre = AccountWithMetadata::new(
sender_private_account.clone(),
true,
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0),
);
let recipient_pre = AccountWithMetadata::new(
Account::default(),
false,
PrivateAddressPlaintext::new(recipient_keys.npk(), &recipient_keys.vpk(), 0)
.account_id(),
AccountId::for_regular_private_account(recipient_keys.npk(), &recipient_keys.vpk(), 0),
);
let (output, proof) = circuit::execute_and_prove(
@ -1508,12 +1506,12 @@ pub mod tests {
) -> PrivacyPreservingTransaction {
let program = Program::authenticated_transfer_program();
let sender_account_id =
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id();
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0);
let sender_commitment = Commitment::new(&sender_account_id, sender_private_account);
let sender_pre = AccountWithMetadata::new(
sender_private_account.clone(),
true,
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0),
);
let recipient_pre = AccountWithMetadata::new(
state.get_account_by_id(*recipient_account_id),
@ -1619,10 +1617,9 @@ pub mod tests {
);
let sender_account_id =
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id();
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0);
let recipient_account_id =
PrivateAddressPlaintext::new(recipient_keys.npk(), &recipient_keys.vpk(), 0)
.account_id();
AccountId::for_regular_private_account(recipient_keys.npk(), &recipient_keys.vpk(), 0);
let expected_new_commitment_1 = Commitment::new(
&sender_account_id,
&Account {
@ -1774,7 +1771,7 @@ pub mod tests {
);
let sender_account_id =
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id();
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0);
let expected_new_commitment = Commitment::new(
&sender_account_id,
&Account {
@ -2086,13 +2083,12 @@ pub mod tests {
..Account::default()
},
true,
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0),
);
let private_account_2 = AccountWithMetadata::new(
Account::default(),
false,
PrivateAddressPlaintext::new(recipient_keys.npk(), &recipient_keys.vpk(), 0)
.account_id(),
AccountId::for_regular_private_account(recipient_keys.npk(), &recipient_keys.vpk(), 0),
);
// Setting the recipient nsk to authorize the sender.
@ -2135,7 +2131,7 @@ pub mod tests {
..Account::default()
},
true,
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0),
);
let private_account_2 = AccountWithMetadata::new(
Account {
@ -2144,8 +2140,7 @@ pub mod tests {
..Account::default()
},
false,
PrivateAddressPlaintext::new(recipient_keys.npk(), &recipient_keys.vpk(), 0)
.account_id(),
AccountId::for_regular_private_account(recipient_keys.npk(), &recipient_keys.vpk(), 0),
);
let result = execute_and_prove(
@ -2184,7 +2179,7 @@ pub mod tests {
..Account::default()
},
true,
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0),
);
let private_account_2 = AccountWithMetadata::new(
Account {
@ -2193,8 +2188,7 @@ pub mod tests {
..Account::default()
},
false,
PrivateAddressPlaintext::new(recipient_keys.npk(), &recipient_keys.vpk(), 0)
.account_id(),
AccountId::for_regular_private_account(recipient_keys.npk(), &recipient_keys.vpk(), 0),
);
let result = execute_and_prove(
@ -2233,7 +2227,7 @@ pub mod tests {
..Account::default()
},
true,
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0),
);
let private_account_2 = AccountWithMetadata::new(
Account {
@ -2242,8 +2236,7 @@ pub mod tests {
..Account::default()
},
false,
PrivateAddressPlaintext::new(recipient_keys.npk(), &recipient_keys.vpk(), 0)
.account_id(),
AccountId::for_regular_private_account(recipient_keys.npk(), &recipient_keys.vpk(), 0),
);
let result = execute_and_prove(
@ -2282,7 +2275,7 @@ pub mod tests {
..Account::default()
},
true,
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0),
);
let private_account_2 = AccountWithMetadata::new(
Account {
@ -2291,8 +2284,7 @@ pub mod tests {
..Account::default()
},
false,
PrivateAddressPlaintext::new(recipient_keys.npk(), &recipient_keys.vpk(), 0)
.account_id(),
AccountId::for_regular_private_account(recipient_keys.npk(), &recipient_keys.vpk(), 0),
);
let result = execute_and_prove(
@ -2332,14 +2324,13 @@ pub mod tests {
..Account::default()
},
true,
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0),
);
let private_account_2 = AccountWithMetadata::new(
Account::default(),
// This should be set to false in normal circumstances
true,
PrivateAddressPlaintext::new(recipient_keys.npk(), &recipient_keys.vpk(), 0)
.account_id(),
AccountId::for_regular_private_account(recipient_keys.npk(), &recipient_keys.vpk(), 0),
);
let result = execute_and_prove(
@ -2408,8 +2399,8 @@ pub mod tests {
/// Happy path: a program claims a new private PDA via `Claim::Pda(seed)`. The circuit
/// reads the npk for that `pre_state` from `private_account_keys` at the `pre_state`'s
/// position, derives `AccountId` via `PrivateAddressPlaintext::new(npk,
/// ..).pda_account_id(program_id, seed)`, and asserts it equals the `pre_state`'s
/// position, derives `AccountId` via `AccountId::for_regular_private_account(npk,
/// ..).pda(program_id, seed)`, and asserts it equals the `pre_state`'s
/// `account_id`. The equality both validates the claim and binds the supplied npk to the
/// `account_id`.
#[test]
@ -2419,8 +2410,7 @@ pub mod tests {
let npk = keys.npk();
let seed = PdaSeed::new([42; 32]);
let account_id = PrivateAddressPlaintext::new(npk, &keys.vpk(), u128::MAX)
.pda_account_id(&program.id(), &seed);
let account_id = AccountId::for_regular_private_account(npk, &keys.vpk(), u128::MAX).pda(&program.id(), &seed);
let pre_state = AccountWithMetadata::new(Account::default(), false, account_id);
let result = execute_and_prove(
@ -2445,7 +2435,7 @@ pub mod tests {
}
/// An npk is supplied that does not match the `pre_state`'s `account_id` under
/// `PrivateAddressPlaintext::new(npk, ..).pda_account_id(program, claim_seed)`. The claim
/// `AccountId::for_regular_private_account(npk, ..).pda(program, claim_seed)`. The claim
/// equality check rejects.
#[test]
fn private_pda_npk_mismatch_fails() {
@ -2459,10 +2449,9 @@ pub mod tests {
let seed = PdaSeed::new([42; 32]);
// `account_id` is derived from `npk_a`, but `npk_b` is supplied for this pre_state.
// `PrivateAddressPlaintext::new(npk_b, ..).pda_account_id(program, seed) != account_id`, so
// `AccountId::for_regular_private_account(npk_b, ..).pda(program, seed) != account_id`, so
// the claim check in the circuit must reject.
let account_id = PrivateAddressPlaintext::new(npk_a, &keys_a.vpk(), u128::MAX)
.pda_account_id(&program.id(), &seed);
let account_id = AccountId::for_regular_private_account(npk_a, &keys_a.vpk(), u128::MAX).pda(&program.id(), &seed);
let pre_state = AccountWithMetadata::new(Account::default(), false, account_id);
let result = execute_and_prove(
@ -2485,7 +2474,7 @@ pub mod tests {
/// private PDA via `Claim::Pda(seed)`, then chains to a callee (`noop`) delegating the same
/// seed via `ChainedCall.pda_seeds`. In the callee's step, the `pre_state`'s authorization
/// is established via the private derivation
/// `PrivateAddressPlaintext::new(npk, ..).pda_account_id(delegator, seed) == pre.account_id`.
/// `AccountId::for_regular_private_account(npk, ..).pda(delegator, seed) == pre.account_id`.
#[test]
fn caller_pda_seeds_authorize_private_pda_for_callee() {
let delegator = Program::private_pda_delegator();
@ -2494,8 +2483,7 @@ pub mod tests {
let npk = keys.npk();
let seed = PdaSeed::new([77; 32]);
let account_id = PrivateAddressPlaintext::new(npk, &keys.vpk(), u128::MAX)
.pda_account_id(&delegator.id(), &seed);
let account_id = AccountId::for_regular_private_account(npk, &keys.vpk(), u128::MAX).pda(&delegator.id(), &seed);
let pre_state = AccountWithMetadata::new(Account::default(), false, account_id);
let callee_id = callee.id();
@ -2534,8 +2522,7 @@ pub mod tests {
let claim_seed = PdaSeed::new([77; 32]);
let wrong_delegated_seed = PdaSeed::new([88; 32]);
let account_id = PrivateAddressPlaintext::new(npk, &keys.vpk(), u128::MAX)
.pda_account_id(&delegator.id(), &claim_seed);
let account_id = AccountId::for_regular_private_account(npk, &keys.vpk(), u128::MAX).pda(&delegator.id(), &claim_seed);
let pre_state = AccountWithMetadata::new(Account::default(), false, account_id);
let callee_id = callee.id();
@ -2573,10 +2560,8 @@ pub mod tests {
let keys_b = test_private_account_keys_2();
let seed = PdaSeed::new([55; 32]);
let account_a = PrivateAddressPlaintext::new(keys_a.npk(), &keys_a.vpk(), u128::MAX)
.pda_account_id(&program.id(), &seed);
let account_b = PrivateAddressPlaintext::new(keys_b.npk(), &keys_b.vpk(), u128::MAX)
.pda_account_id(&program.id(), &seed);
let account_a = AccountId::for_regular_private_account(keys_a.npk(), &keys_a.vpk(), u128::MAX).pda(&program.id(), &seed);
let account_b = AccountId::for_regular_private_account(keys_b.npk(), &keys_b.vpk(), u128::MAX).pda(&program.id(), &seed);
let pre_a = AccountWithMetadata::new(Account::default(), false, account_a);
let pre_b = AccountWithMetadata::new(Account::default(), false, account_b);
@ -2620,8 +2605,7 @@ pub mod tests {
// Simulate a previously-claimed private PDA: program_owner != DEFAULT, is_authorized =
// true, account_id derived via the private formula.
let account_id = PrivateAddressPlaintext::new(npk, &keys.vpk(), u128::MAX)
.pda_account_id(&program.id(), &seed);
let account_id = AccountId::for_regular_private_account(npk, &keys.vpk(), u128::MAX).pda(&program.id(), &seed);
let owned_pre_state = AccountWithMetadata::new(
Account {
program_owner: program.id(),
@ -2714,7 +2698,7 @@ pub mod tests {
..Account::default()
},
true,
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0),
);
let result = execute_and_prove(
@ -3048,7 +3032,7 @@ pub mod tests {
..Account::default()
};
let sender_account_id =
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id();
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0);
let sender_commitment = Commitment::new(&sender_account_id, &sender_private_account);
let sender_init_nullifier = Nullifier::for_account_initialization(&sender_account_id);
let mut state = V03State::new_with_genesis_accounts(
@ -3059,7 +3043,7 @@ pub mod tests {
let sender_pre = AccountWithMetadata::new(
sender_private_account,
true,
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0),
);
let recipient_private_key = PrivateKey::try_new([2; 32]).unwrap();
let recipient_account_id =
@ -3132,7 +3116,7 @@ pub mod tests {
..Account::default()
},
true,
PrivateAddressPlaintext::new(from_keys.npk(), &from_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(from_keys.npk(), &from_keys.vpk(), 0),
);
let to_account = AccountWithMetadata::new(
Account {
@ -3140,13 +3124,13 @@ pub mod tests {
..Account::default()
},
true,
PrivateAddressPlaintext::new(to_keys.npk(), &to_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(to_keys.npk(), &to_keys.vpk(), 0),
);
let from_account_id =
PrivateAddressPlaintext::new(from_keys.npk(), &from_keys.vpk(), 0).account_id();
AccountId::for_regular_private_account(from_keys.npk(), &from_keys.vpk(), 0);
let to_account_id =
PrivateAddressPlaintext::new(to_keys.npk(), &to_keys.vpk(), 0).account_id();
AccountId::for_regular_private_account(to_keys.npk(), &to_keys.vpk(), 0);
let from_commitment = Commitment::new(&from_account_id, &from_account.account);
let to_commitment = Commitment::new(&to_account_id, &to_account.account);
let from_init_nullifier = Nullifier::for_account_initialization(&from_account_id);
@ -3453,7 +3437,7 @@ pub mod tests {
let authorized_account = AccountWithMetadata::new(
Account::default(),
true,
PrivateAddressPlaintext::new(private_keys.npk(), &private_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(private_keys.npk(), &private_keys.vpk(), 0),
);
let program = Program::authenticated_transfer_program();
@ -3486,7 +3470,7 @@ pub mod tests {
assert!(result.is_ok());
let account_id =
PrivateAddressPlaintext::new(private_keys.npk(), &private_keys.vpk(), 0).account_id();
AccountId::for_regular_private_account(private_keys.npk(), &private_keys.vpk(), 0);
let nullifier = Nullifier::for_account_initialization(&account_id);
assert!(state.private_state.1.contains(&nullifier));
}
@ -3503,7 +3487,7 @@ pub mod tests {
let unauthorized_account = AccountWithMetadata::new(
Account::default(),
false,
PrivateAddressPlaintext::new(private_keys.npk(), &private_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(private_keys.npk(), &private_keys.vpk(), 0),
);
let program = Program::claimer();
@ -3531,7 +3515,7 @@ pub mod tests {
.unwrap();
let account_id =
PrivateAddressPlaintext::new(private_keys.npk(), &private_keys.vpk(), 0).account_id();
AccountId::for_regular_private_account(private_keys.npk(), &private_keys.vpk(), 0);
let nullifier = Nullifier::for_account_initialization(&account_id);
assert!(state.private_state.1.contains(&nullifier));
}
@ -3547,7 +3531,7 @@ pub mod tests {
let authorized_account = AccountWithMetadata::new(
Account::default(),
true,
PrivateAddressPlaintext::new(private_keys.npk(), &private_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(private_keys.npk(), &private_keys.vpk(), 0),
);
let claimer_program = Program::claimer();
@ -3584,7 +3568,7 @@ pub mod tests {
// Verify the account is now initialized (nullifier exists)
let account_id =
PrivateAddressPlaintext::new(private_keys.npk(), &private_keys.vpk(), 0).account_id();
AccountId::for_regular_private_account(private_keys.npk(), &private_keys.vpk(), 0);
let nullifier = Nullifier::for_account_initialization(&account_id);
assert!(state.private_state.1.contains(&nullifier));
@ -3674,7 +3658,7 @@ pub mod tests {
let private_account = AccountWithMetadata::new(
Account::default(),
true,
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0),
);
// Don't change data (None) and don't claim (false)
let instruction: (Option<Vec<u8>>, bool) = (None, false);
@ -3703,7 +3687,7 @@ pub mod tests {
let private_account = AccountWithMetadata::new(
Account::default(),
true,
PrivateAddressPlaintext::new(sender_keys.npk(), &sender_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(sender_keys.npk(), &sender_keys.vpk(), 0),
);
// Change data but don't claim (false) - should fail
let new_data = vec![1, 2, 3, 4, 5];
@ -3746,13 +3730,11 @@ pub mod tests {
let recipient_account = AccountWithMetadata::new(
Account::default(),
true,
PrivateAddressPlaintext::new(recipient_keys.npk(), &recipient_keys.vpk(), 0)
.account_id(),
AccountId::for_regular_private_account(recipient_keys.npk(), &recipient_keys.vpk(), 0),
);
let recipient_account_id =
PrivateAddressPlaintext::new(recipient_keys.npk(), &recipient_keys.vpk(), 0)
.account_id();
AccountId::for_regular_private_account(recipient_keys.npk(), &recipient_keys.vpk(), 0);
let recipient_commitment =
Commitment::new(&recipient_account_id, &recipient_account.account);
let recipient_init_nullifier = Nullifier::for_account_initialization(&recipient_account_id);
@ -3921,7 +3903,7 @@ pub mod tests {
let pre = AccountWithMetadata::new(
Account::default(),
false,
PrivateAddressPlaintext::new(account_keys.npk(), &account_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(account_keys.npk(), &account_keys.vpk(), 0),
);
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0).with_test_programs();
let tx = {
@ -3986,7 +3968,7 @@ pub mod tests {
let pre = AccountWithMetadata::new(
Account::default(),
false,
PrivateAddressPlaintext::new(account_keys.npk(), &account_keys.vpk(), 0).account_id(),
AccountId::for_regular_private_account(account_keys.npk(), &account_keys.vpk(), 0),
);
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0).with_test_programs();
let tx = {
@ -4517,10 +4499,8 @@ pub mod tests {
ProgramWithDependencies::new(proxy, [(auth_transfer_id, auth_transfer.clone())].into());
let funder_id = funder_keys.account_id();
let alice_pda_0_id = PrivateAddressPlaintext::new(alice_npk, &alice_keys.vpk(), 0)
.pda_account_id(&proxy_id, &seed);
let alice_pda_1_id = PrivateAddressPlaintext::new(alice_npk, &alice_keys.vpk(), 1)
.pda_account_id(&proxy_id, &seed);
let alice_pda_0_id = AccountId::for_regular_private_account(alice_npk, &alice_keys.vpk(), 0).pda(&proxy_id, &seed);
let alice_pda_1_id = AccountId::for_regular_private_account(alice_npk, &alice_keys.vpk(), 1).pda(&proxy_id, &seed);
let recipient_id = test_public_account_keys_2().account_id();
let recipient_signing_key = test_public_account_keys_2().signing_key;

View File

@ -511,7 +511,7 @@ fn n_unique<T: Eq + Hash>(data: &[T]) -> usize {
#[cfg(test)]
mod tests {
use lee_core::account::{AccountId, Nonce, PrivateAddressPlaintext};
use lee_core::account::{AccountId, Nonce};
use crate::{
PrivateKey, PublicKey, V03State,
@ -603,7 +603,7 @@ mod tests {
// Attacker controls a private account.
let attacker_keys = test_private_account_keys_1();
let attacker_id =
PrivateAddressPlaintext::new(attacker_keys.npk(), &attacker_keys.vpk(), 0).account_id();
AccountId::for_regular_private_account(attacker_keys.npk(), &attacker_keys.vpk(), 0);
let victim_id = AccountId::new([20_u8; 32]);
let recipient_id = AccountId::new([42_u8; 32]);
@ -709,7 +709,7 @@ mod tests {
/// There are two routes, both closed:
///
/// - **mask=1 (`PrivateAuthorizedUpdate`)**: the circuit derives `account_id =
/// PrivateAddressPlaintext::new(npk_from(nsk), &vpk, identifier).account_id()` and asserts it
/// AccountId::for_regular_private_account(npk_from(nsk), &vpk, identifier)` and asserts it
/// matches `pre_state.account_id`. Passing this check requires the victim's `nsk`, which the
/// attacker does not have. `execute_and_prove` panics inside the ZKVM and no proof is
/// produced.
@ -755,12 +755,12 @@ mod tests {
// Attacker controls a private account.
let attacker_keys = test_private_account_keys_1();
let attacker_id =
PrivateAddressPlaintext::new(attacker_keys.npk(), &attacker_keys.vpk(), 0).account_id();
AccountId::for_regular_private_account(attacker_keys.npk(), &attacker_keys.vpk(), 0);
// Victim is a private account — not registered in public chain state.
let victim_keys = test_private_account_keys_2();
let victim_id =
PrivateAddressPlaintext::new(victim_keys.npk(), &victim_keys.vpk(), 0).account_id();
AccountId::for_regular_private_account(victim_keys.npk(), &victim_keys.vpk(), 0);
let victim_balance = 5_000_u128;
let recipient_id = AccountId::new([42_u8; 32]);

View File

@ -819,7 +819,7 @@ mod tests {
};
use key_protocol::key_management::KeyChain;
use lee::{
Account, Data, PrivacyPreservingTransaction, PrivateAddressPlaintext, V03State,
Account, AccountId, Data, PrivacyPreservingTransaction, V03State,
error::LeeError,
execute_and_prove,
privacy_preserving_transaction::{Message, circuit::ProgramWithDependencies},
@ -1604,12 +1604,11 @@ mod tests {
#[test]
fn private_bridge_withdraw_invocation_is_dropped() {
let sender_keys = KeyChain::new_os_random();
let sender_account_id = PrivateAddressPlaintext::new(
let sender_account_id = AccountId::for_regular_private_account(
sender_keys.nullifier_public_key,
&sender_keys.viewing_public_key,
0,
)
.account_id();
);
let sender_private_account = Account {
program_owner: Program::authenticated_transfer_program().id(),
balance: 100,
@ -1632,12 +1631,11 @@ mod tests {
let sender_pre = AccountWithMetadata::new(
sender_private_account,
true,
PrivateAddressPlaintext::new(
AccountId::for_regular_private_account(
sender_keys.nullifier_public_key,
&sender_keys.viewing_public_key,
0,
)
.account_id(),
),
);
let bridge_pre = AccountWithMetadata::new(
state.get_account_by_id(bridge_account_id),

View File

@ -106,12 +106,11 @@ pub struct PrivateAccountPrivateInitialData {
impl PrivateAccountPrivateInitialData {
#[must_use]
pub fn account_id(&self) -> lee::AccountId {
lee::PrivateAddressPlaintext::new(
lee::AccountId::for_regular_private_account(
self.key_chain.nullifier_public_key,
&self.key_chain.viewing_public_key,
self.identifier,
)
.account_id()
}
}
@ -220,7 +219,7 @@ pub fn initial_state() -> V03State {
.map(|init_comm_data| {
let npk = &init_comm_data.npk;
let account_id =
lee::PrivateAddressPlaintext::new(*npk, &init_comm_data.vpk, 0).account_id();
lee::AccountId::for_regular_private_account(*npk, &init_comm_data.vpk, 0);
let mut acc = init_comm_data.account.clone();

View File

@ -2,7 +2,7 @@ use core::fmt;
use anyhow::Result;
use keycard_wallet::{KeycardWallet, python_path};
use lee::{AccountId, PrivateAddressPlaintext, PrivateKey, PublicKey, Signature};
use lee::{AccountId, PrivateKey, PublicKey, Signature};
use lee_core::{
Identifier, InputAccountIdentity, MembershipProof, NullifierPublicKey, NullifierSecretKey,
SharedSecretKey,
@ -264,7 +264,7 @@ impl AccountManager {
let auth_acc = AccountWithMetadata::new(
acc,
false,
PrivateAddressPlaintext::new(npk, &vpk, identifier).account_id(),
AccountId::for_regular_private_account(npk, &vpk, identifier),
);
let mut random_seed: [u8; 32] = [0; 32];
OsRng.fill_bytes(&mut random_seed);
@ -314,7 +314,7 @@ impl AccountManager {
identifier,
} => {
let account_id =
lee::PrivateAddressPlaintext::new(npk, &vpk, identifier).account_id();
lee::AccountId::for_regular_private_account(npk, &vpk, identifier);
let pre = private_shared_acc_preparation(
wallet, account_id, nsk, npk, vpk, identifier, false,
)

View File

@ -525,12 +525,11 @@ impl WalletSubcommand for ImportSubcommand {
let key_chain: KeyChain = serde_json::from_str(&key_chain_json)
.map_err(|err| anyhow::anyhow!("Invalid key chain JSON: {err}"))?;
let account = lee::Account::from(account_state);
let account_id = lee::PrivateAddressPlaintext::new(
let account_id = lee::AccountId::for_regular_private_account(
key_chain.nullifier_public_key,
&key_chain.viewing_public_key,
identifier,
)
.account_id();
);
wallet_core
.storage_mut()

View File

@ -17,7 +17,7 @@ use common::{HashType, transaction::LeeTransaction};
use config::WalletConfig;
use key_protocol::key_management::key_tree::chain_index::ChainIndex;
use lee::{
Account, AccountId, PrivacyPreservingTransaction, PrivateAddressPlaintext,
Account, AccountId, PrivacyPreservingTransaction,
privacy_preserving_transaction::{
circuit::ProgramWithDependencies, message::EncryptedAccountData,
},
@ -377,8 +377,7 @@ impl WalletCore {
let keys = holder.derive_keys_for_pda(&program_id, &pda_seed);
let npk = keys.generate_nullifier_public_key();
let vpk = keys.generate_viewing_public_key();
let account_id = PrivateAddressPlaintext::new(npk, &vpk, identifier)
.pda_account_id(&program_id, &pda_seed);
let account_id = AccountId::for_regular_private_account(npk, &vpk, identifier).pda(&program_id, &pda_seed);
self.register_shared_account(
account_id,
@ -420,7 +419,7 @@ impl WalletCore {
let keys = holder.derive_keys_for_shared_account(&derivation_seed);
let npk = keys.generate_nullifier_public_key();
let vpk = keys.generate_viewing_public_key();
let account_id = PrivateAddressPlaintext::new(npk, &vpk, identifier).account_id();
let account_id = AccountId::for_regular_private_account(npk, &vpk, identifier);
self.register_shared_account(account_id, group_name, identifier, None, None);

View File

@ -696,7 +696,6 @@ impl Default for UserKeyChain {
#[cfg(test)]
mod tests {
use lee::PrivateAddressPlaintext;
use super::*;
@ -736,12 +735,11 @@ mod tests {
let mut user_data = UserKeyChain::default();
let key_chain = KeyChain::new_os_random();
let account_id = PrivateAddressPlaintext::new(
let account_id = AccountId::for_regular_private_account(
key_chain.nullifier_public_key,
&key_chain.viewing_public_key,
0,
)
.account_id();
);
let account = lee_core::account::Account::default();
user_data.add_imported_private_account(key_chain, None, 0, account);
@ -756,12 +754,11 @@ mod tests {
let mut user_data = UserKeyChain::default();
let key_chain = KeyChain::new_os_random();
let account_id = PrivateAddressPlaintext::new(
let account_id = AccountId::for_regular_private_account(
key_chain.nullifier_public_key,
&key_chain.viewing_public_key,
0,
)
.account_id();
);
let account = lee_core::account::Account::default();
user_data.add_imported_private_account(key_chain, None, 0, account.clone());
@ -806,12 +803,11 @@ mod tests {
let mut user_data = UserKeyChain::default();
let key_chain = KeyChain::new_os_random();
let account_id = PrivateAddressPlaintext::new(
let account_id = AccountId::for_regular_private_account(
key_chain.nullifier_public_key,
&key_chain.viewing_public_key,
0,
)
.account_id();
);
let new_account = lee_core::account::Account {
balance: 100,
@ -832,12 +828,11 @@ mod tests {
let mut user_data = UserKeyChain::default();
let key_chain = KeyChain::new_os_random();
let account_id1 = PrivateAddressPlaintext::new(
let account_id1 = AccountId::for_regular_private_account(
key_chain.nullifier_public_key,
&key_chain.viewing_public_key,
0,
)
.account_id();
);
let account = lee_core::account::Account::default();
user_data.add_imported_private_account(key_chain, None, 0, account);

View File

@ -4,7 +4,7 @@ use anyhow::{Context as _, Result};
use bytesize::ByteSize;
use indexer_service::{ChannelId, ClientConfig, IndexerConfig};
use key_protocol::key_management::KeyChain;
use lee::{AccountId, PrivateAddressPlaintext, PrivateKey, PublicKey};
use lee::{AccountId, PrivateKey, PublicKey};
use lee_core::Identifier;
use sequencer_core::config::{BedrockConfig, GenesisAction, SequencerConfig};
use url::Url;
@ -23,12 +23,11 @@ pub struct InitialPrivateAccountForWallet {
impl InitialPrivateAccountForWallet {
#[must_use]
pub fn account_id(&self) -> AccountId {
PrivateAddressPlaintext::new(
AccountId::for_regular_private_account(
self.key_chain.nullifier_public_key,
&self.key_chain.viewing_public_key,
self.identifier,
)
.account_id()
}
}

View File

@ -12,7 +12,7 @@ use criterion::{Criterion, criterion_group, criterion_main};
use key_protocol::key_management::KeyChain;
use lee_core::{
Commitment, EncryptionScheme, SharedSecretKey,
account::{Account, PrivateAddressPlaintext},
account::{Account, AccountId},
program::PrivateAccountKind,
};
@ -49,7 +49,7 @@ fn bench_encryption(c: &mut Criterion) {
let npk = recipient_kc.nullifier_public_key;
let account = Account::default();
let account_id =
PrivateAddressPlaintext::new(npk, &recipient_kc.viewing_public_key, 0).account_id();
AccountId::for_regular_private_account(npk, &recipient_kc.viewing_public_key, 0);
let commitment = Commitment::new(&account_id, &account);
let (shared, _epk) = SharedSecretKey::encapsulate(&recipient_kc.viewing_public_key);
let kind = PrivateAccountKind::Regular(0_u128);