mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-07-01 03:19:29 +00:00
refactor(lee_core): remove the dead PrivateAddressPlaintext struct
This commit is contained in:
parent
f14fe836c6
commit
f4ef11b04b
@ -7,8 +7,8 @@ use integration_tests::{
|
||||
public_mention, verify_commitment_is_in_state,
|
||||
};
|
||||
use lee::{
|
||||
AccountId, execute_and_prove,
|
||||
privacy_preserving_transaction::circuit::ProgramWithDependencies, program::Program,
|
||||
AccountId, execute_and_prove, privacy_preserving_transaction::circuit::ProgramWithDependencies,
|
||||
program::Program,
|
||||
};
|
||||
use lee_core::{
|
||||
InputAccountIdentity, NullifierPublicKey, account::AccountWithMetadata,
|
||||
|
||||
@ -51,7 +51,8 @@ async fn fund_private_pda(
|
||||
amount: u128,
|
||||
auth_transfer: &ProgramWithDependencies,
|
||||
) -> Result<()> {
|
||||
let pda_account_id = AccountId::for_regular_private_account(npk, &vpk, identifier).pda(&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
|
||||
|
||||
@ -16,8 +16,7 @@ use bytesize::ByteSize;
|
||||
use common::transaction::LeeTransaction;
|
||||
use integration_tests::{TestContext, config::SequencerPartialConfig};
|
||||
use lee::{
|
||||
Account, AccountId, PrivacyPreservingTransaction, PrivateKey,
|
||||
PublicKey, PublicTransaction,
|
||||
Account, AccountId, PrivacyPreservingTransaction, PrivateKey, PublicKey, PublicTransaction,
|
||||
privacy_preserving_transaction::{self as pptx, circuit},
|
||||
program::Program,
|
||||
public_transaction as putx,
|
||||
|
||||
@ -907,8 +907,11 @@ fn test_wallet_ffi_transfer_shielded() -> Result<()> {
|
||||
let (to, to_keys) = unsafe {
|
||||
let mut out_keys = FfiPrivateAccountKeys::default();
|
||||
wallet_ffi_create_private_accounts_key(wallet_ffi_handle, &raw mut out_keys).unwrap();
|
||||
let account_id =
|
||||
lee::AccountId::for_regular_private_account(out_keys.npk(), &out_keys.vpk().unwrap(), 0_u128);
|
||||
let 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)
|
||||
};
|
||||
@ -1045,8 +1048,11 @@ fn test_wallet_ffi_transfer_private() -> Result<()> {
|
||||
let (to, to_keys) = unsafe {
|
||||
let mut out_keys = FfiPrivateAccountKeys::default();
|
||||
wallet_ffi_create_private_accounts_key(wallet_ffi_handle, &raw mut out_keys).unwrap();
|
||||
let account_id =
|
||||
lee::AccountId::for_regular_private_account(out_keys.npk(), &out_keys.vpk().unwrap(), 0_u128);
|
||||
let 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)
|
||||
};
|
||||
|
||||
@ -323,7 +323,7 @@ mod tests {
|
||||
|
||||
/// Pins the end-to-end derivation for a fixed (GMS, `ProgramId`, `PdaSeed`). Any change
|
||||
/// to `secret_spending_key_for_pda`, the `PrivateKeyHolder` nsk/npk chain, or the
|
||||
/// `PrivateAddressPlaintext::pda_account_id` formula breaks this test. Mirrors the pinned-value
|
||||
/// `AccountId::pda` formula breaks this test. Mirrors the pinned-value
|
||||
/// pattern from `for_private_pda_matches_pinned_value` in `lee_core`.
|
||||
#[test]
|
||||
fn pinned_end_to_end_derivation_for_private_pda() {
|
||||
@ -346,7 +346,9 @@ 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 = AccountId::for_regular_private_account(expected_npk, &vpk, u128::MAX).pda(&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);
|
||||
@ -549,8 +551,10 @@ 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 = 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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -10,10 +10,7 @@ use risc0_zkvm::sha::{Impl, Sha256 as _};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::{DeserializeFromStr, SerializeDisplay};
|
||||
|
||||
use crate::{
|
||||
Identifier, NullifierPublicKey, NullifierSecretKey, encryption::ViewingPublicKey,
|
||||
program::ProgramId,
|
||||
};
|
||||
use crate::{NullifierSecretKey, program::ProgramId};
|
||||
|
||||
pub mod data;
|
||||
|
||||
@ -182,28 +179,6 @@ impl AccountId {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(any(feature = "host", test), derive(Debug, PartialEq, Eq))]
|
||||
pub struct PrivateAddressPlaintext<'vpk> {
|
||||
pub npk: NullifierPublicKey,
|
||||
pub vpk: &'vpk ViewingPublicKey,
|
||||
pub identifier: Identifier,
|
||||
}
|
||||
|
||||
impl<'vpk> PrivateAddressPlaintext<'vpk> {
|
||||
#[must_use]
|
||||
pub const fn new(
|
||||
npk: NullifierPublicKey,
|
||||
vpk: &'vpk ViewingPublicKey,
|
||||
identifier: Identifier,
|
||||
) -> Self {
|
||||
Self {
|
||||
npk,
|
||||
vpk,
|
||||
identifier,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<[u8]> for AccountId {
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
&self.value
|
||||
|
||||
@ -110,7 +110,11 @@ impl InputAccountIdentity {
|
||||
vpk,
|
||||
identifier,
|
||||
..
|
||||
} => Some(AccountId::for_regular_private_account(*npk, vpk, *identifier)),
|
||||
} => Some(AccountId::for_regular_private_account(
|
||||
*npk,
|
||||
vpk,
|
||||
*identifier,
|
||||
)),
|
||||
Self::PrivatePdaUpdate {
|
||||
nsk,
|
||||
vpk,
|
||||
|
||||
@ -2,11 +2,7 @@ use borsh::{BorshDeserialize, BorshSerialize};
|
||||
use risc0_zkvm::sha::{Impl, Sha256 as _};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
Commitment,
|
||||
account::{AccountId, PrivateAddressPlaintext},
|
||||
encryption::ViewingPublicKey,
|
||||
};
|
||||
use crate::{Commitment, account::AccountId, encryption::ViewingPublicKey};
|
||||
|
||||
const PRIVATE_ACCOUNT_ID_PREFIX: &[u8; 32] = b"/LEE/v0.3/AccountId/Private/\x00\x00\x00\x00";
|
||||
|
||||
@ -16,26 +12,6 @@ pub type Identifier = u128;
|
||||
#[cfg_attr(any(feature = "host", test), derive(Hash))]
|
||||
pub struct NullifierPublicKey(pub [u8; 32]);
|
||||
|
||||
impl PrivateAddressPlaintext<'_> {
|
||||
/// Derives an [`AccountId`] for a regular (non-PDA) private account from the nullifier public
|
||||
/// key and identifier.
|
||||
#[must_use]
|
||||
pub fn account_id(&self) -> AccountId {
|
||||
let mut bytes = [0_u8; 32 + 32 + ViewingPublicKey::LEN + 16];
|
||||
bytes[0..32].copy_from_slice(PRIVATE_ACCOUNT_ID_PREFIX);
|
||||
bytes[32..64].copy_from_slice(&self.npk.0);
|
||||
bytes[64..64 + ViewingPublicKey::LEN].copy_from_slice(self.vpk.to_bytes());
|
||||
bytes[64 + ViewingPublicKey::LEN..].copy_from_slice(&self.identifier.to_le_bytes());
|
||||
|
||||
AccountId::new(
|
||||
Impl::hash_bytes(&bytes)
|
||||
.as_bytes()
|
||||
.try_into()
|
||||
.expect("Conversion should not fail"),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl AccountId {
|
||||
#[must_use]
|
||||
pub fn for_regular_private_account(
|
||||
|
||||
@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
BlockId, Identifier, NullifierPublicKey, Timestamp,
|
||||
account::{Account, AccountId, AccountWithMetadata, PrivateAddressPlaintext},
|
||||
account::{Account, AccountId, AccountWithMetadata},
|
||||
encryption::ViewingPublicKey,
|
||||
};
|
||||
|
||||
@ -183,37 +183,6 @@ impl AccountId {
|
||||
}
|
||||
}
|
||||
|
||||
impl PrivateAddressPlaintext<'_> {
|
||||
/// Derives an [`AccountId`] for a private PDA from the program ID, seed, nullifier public
|
||||
/// key, and identifier.
|
||||
///
|
||||
/// Unlike public PDAs ([`AccountId::for_public_pda`]), this includes the `npk` in the
|
||||
/// derivation, making the address unique per group of controllers sharing viewing keys.
|
||||
/// The `identifier` further diversifies the address, so a single `(program_id, seed, npk)`
|
||||
/// tuple controls a family of 2^128 addresses.
|
||||
#[must_use]
|
||||
pub fn pda_account_id(&self, program_id: &ProgramId, seed: &PdaSeed) -> AccountId {
|
||||
use risc0_zkvm::sha::{Impl, Sha256 as _};
|
||||
const PRIVATE_PDA_PREFIX: &[u8; 32] = b"/LEE/v0.3/AccountId/PrivatePDA/\x00";
|
||||
|
||||
let mut bytes = [0_u8; 32 + 32 + 32 + 32 + ViewingPublicKey::LEN + 16];
|
||||
bytes[0..32].copy_from_slice(PRIVATE_PDA_PREFIX);
|
||||
let program_id_bytes: &[u8] =
|
||||
bytemuck::try_cast_slice(program_id).expect("ProgramId should be castable to &[u8]");
|
||||
bytes[32..64].copy_from_slice(program_id_bytes);
|
||||
bytes[64..96].copy_from_slice(&seed.0);
|
||||
bytes[96..128].copy_from_slice(&self.npk.to_byte_array());
|
||||
bytes[128..128 + ViewingPublicKey::LEN].copy_from_slice(self.vpk.to_bytes());
|
||||
bytes[128 + ViewingPublicKey::LEN..].copy_from_slice(&self.identifier.to_le_bytes());
|
||||
AccountId::new(
|
||||
Impl::hash_bytes(&bytes)
|
||||
.as_bytes()
|
||||
.try_into()
|
||||
.expect("Hash output must be exactly 32 bytes long"),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||
pub struct ChainedCall {
|
||||
/// The program ID of the program to execute.
|
||||
@ -642,7 +611,7 @@ pub enum ExecutionValidationError {
|
||||
///
|
||||
/// Returns only public-form derivations, suitable for contexts where all accounts are public
|
||||
/// (e.g. the public-execution path). The privacy circuit must additionally check each mask-3
|
||||
/// `pre_state` against [`PrivateAddressPlaintext::pda_account_id`] with the supplied npk for that
|
||||
/// `pre_state` against [`AccountId::pda`] with the supplied npk for that
|
||||
/// `pre_state`.
|
||||
#[must_use]
|
||||
pub fn compute_public_authorized_pdas(
|
||||
@ -966,9 +935,9 @@ mod tests {
|
||||
assert_eq!(account_post_state.account_mut(), &mut account);
|
||||
}
|
||||
|
||||
// ---- PrivateAddressPlaintext::pda_account_id tests ----
|
||||
// ---- AccountId::pda tests ----
|
||||
|
||||
/// Pins `PrivateAddressPlaintext::pda_account_id` against a hardcoded expected output for a
|
||||
/// Pins `AccountId::pda` against a hardcoded expected output for a
|
||||
/// specific `(program_id, seed, npk, identifier)` tuple. Any change to
|
||||
/// `PRIVATE_PDA_PREFIX`, byte ordering, or the underlying hash breaks this test.
|
||||
#[test]
|
||||
|
||||
@ -180,9 +180,7 @@ mod tests {
|
||||
use lee_core::{
|
||||
Commitment, DUMMY_COMMITMENT_HASH, EncryptionScheme, EphemeralSecretKey, Nullifier,
|
||||
PrivacyPreservingCircuitOutput, SharedSecretKey,
|
||||
account::{
|
||||
Account, AccountId, AccountWithMetadata, Nonce, data::Data,
|
||||
},
|
||||
account::{Account, AccountId, AccountWithMetadata, Nonce, data::Data},
|
||||
program::{PdaSeed, PrivateAccountKind},
|
||||
};
|
||||
|
||||
@ -475,7 +473,8 @@ mod tests {
|
||||
let npk = keys.npk();
|
||||
let seed = PdaSeed::new([42; 32]);
|
||||
let identifier: u128 = 99;
|
||||
let account_id = AccountId::for_regular_private_account(npk, &keys.vpk(), identifier).pda(&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;
|
||||
@ -626,8 +625,11 @@ mod tests {
|
||||
);
|
||||
|
||||
// Recipient: shared private account (new, unauthorized)
|
||||
let shared_account_id =
|
||||
AccountId::for_regular_private_account(shared_npk, &shared_keys.vpk(), shared_identifier);
|
||||
let shared_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;
|
||||
@ -876,7 +878,8 @@ mod tests {
|
||||
let seed = PdaSeed::new([42; 32]);
|
||||
let identifier: u128 = 99;
|
||||
let auth_transfer_id = auth_transfer.id();
|
||||
let pda_id = AccountId::for_regular_private_account(npk, &keys.vpk(), identifier).pda(&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;
|
||||
|
||||
@ -119,12 +119,10 @@ pub mod tests {
|
||||
|
||||
let encrypted_private_post_states = Vec::new();
|
||||
|
||||
let account_id2 =
|
||||
lee_core::account::AccountId::for_regular_private_account(npk2, &vpk, 0);
|
||||
let account_id2 = 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::AccountId::for_regular_private_account(npk1, &vpk, 0);
|
||||
let account_id1 = 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),
|
||||
|
||||
@ -420,9 +420,7 @@ pub mod tests {
|
||||
use lee_core::{
|
||||
BlockId, Commitment, InputAccountIdentity, Nullifier, NullifierPublicKey,
|
||||
NullifierSecretKey, Timestamp,
|
||||
account::{
|
||||
Account, AccountId, AccountWithMetadata, Nonce, data::Data,
|
||||
},
|
||||
account::{Account, AccountId, AccountWithMetadata, Nonce, data::Data},
|
||||
encryption::ViewingPublicKey,
|
||||
program::{
|
||||
BlockValidityWindow, ExecutionValidationError, PdaSeed, ProgramId,
|
||||
@ -2410,7 +2408,8 @@ pub mod tests {
|
||||
let npk = keys.npk();
|
||||
let seed = PdaSeed::new([42; 32]);
|
||||
|
||||
let account_id = AccountId::for_regular_private_account(npk, &keys.vpk(), u128::MAX).pda(&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(
|
||||
@ -2451,7 +2450,8 @@ pub mod tests {
|
||||
// `account_id` is derived from `npk_a`, but `npk_b` is supplied for this pre_state.
|
||||
// `AccountId::for_regular_private_account(npk_b, ..).pda(program, seed) != account_id`, so
|
||||
// the claim check in the circuit must reject.
|
||||
let account_id = AccountId::for_regular_private_account(npk_a, &keys_a.vpk(), u128::MAX).pda(&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(
|
||||
@ -2483,7 +2483,8 @@ pub mod tests {
|
||||
let npk = keys.npk();
|
||||
let seed = PdaSeed::new([77; 32]);
|
||||
|
||||
let account_id = AccountId::for_regular_private_account(npk, &keys.vpk(), u128::MAX).pda(&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();
|
||||
@ -2522,7 +2523,8 @@ pub mod tests {
|
||||
let claim_seed = PdaSeed::new([77; 32]);
|
||||
let wrong_delegated_seed = PdaSeed::new([88; 32]);
|
||||
|
||||
let account_id = AccountId::for_regular_private_account(npk, &keys.vpk(), u128::MAX).pda(&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();
|
||||
@ -2560,8 +2562,12 @@ pub mod tests {
|
||||
let keys_b = test_private_account_keys_2();
|
||||
let seed = PdaSeed::new([55; 32]);
|
||||
|
||||
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 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);
|
||||
@ -2605,7 +2611,8 @@ 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 = AccountId::for_regular_private_account(npk, &keys.vpk(), u128::MAX).pda(&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(),
|
||||
@ -4499,8 +4506,12 @@ 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 = 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 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;
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ pub enum AccountIdentity {
|
||||
identifier: Identifier,
|
||||
},
|
||||
/// An owned private PDA: wallet holds the nsk/npk; `account_id` was derived via
|
||||
/// [`PrivateAddressPlaintext::pda_account_id`].
|
||||
/// [`AccountId::pda`].
|
||||
PrivatePdaOwned(AccountId),
|
||||
/// A foreign private PDA: wallet knows the recipient's npk/vpk but not their nsk.
|
||||
/// Uses a default (uninitialised) account.
|
||||
@ -50,7 +50,7 @@ pub enum AccountIdentity {
|
||||
identifier: Identifier,
|
||||
},
|
||||
/// A shared private PDA with externally-provided keys (e.g. from GMS).
|
||||
/// `account_id` was derived via [`PrivateAddressPlaintext::pda_account_id`].
|
||||
/// `account_id` was derived via [`AccountId::pda`].
|
||||
PrivatePdaShared {
|
||||
account_id: AccountId,
|
||||
nsk: NullifierSecretKey,
|
||||
|
||||
@ -377,7 +377,8 @@ 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 = AccountId::for_regular_private_account(npk, &vpk, identifier).pda(&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,
|
||||
|
||||
@ -295,7 +295,9 @@ impl ExecutionState {
|
||||
seed: Some((seed, authority_program_id)),
|
||||
..
|
||||
}) => {
|
||||
let expected = AccountId::for_regular_private_account(*npk, vpk, *identifier).pda(authority_program_id, seed);
|
||||
let expected =
|
||||
AccountId::for_regular_private_account(*npk, vpk, *identifier)
|
||||
.pda(authority_program_id, seed);
|
||||
assert_eq!(
|
||||
pre_account_id, expected,
|
||||
"External seed mismatch for PrivatePdaInit at position {pre_state_position}"
|
||||
@ -310,7 +312,9 @@ impl ExecutionState {
|
||||
..
|
||||
}) => {
|
||||
let npk = NullifierPublicKey::from(nsk);
|
||||
let expected = AccountId::for_regular_private_account(npk, vpk, *identifier).pda(authority_program_id, seed);
|
||||
let expected =
|
||||
AccountId::for_regular_private_account(npk, vpk, *identifier)
|
||||
.pda(authority_program_id, seed);
|
||||
assert_eq!(
|
||||
pre_account_id, expected,
|
||||
"External seed mismatch for PrivatePdaUpdate at position {pre_state_position}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user