mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-05-15 12:39:30 +00:00
use identifier in private gms command
This commit is contained in:
parent
ee0fecee25
commit
f3389571f8
@ -55,6 +55,7 @@ async fn group_create_and_shared_account_registration() -> Result<()> {
|
|||||||
pda: false,
|
pda: false,
|
||||||
seed: None,
|
seed: None,
|
||||||
program_id: None,
|
program_id: None,
|
||||||
|
identifier: None,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let result = wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?;
|
let result = wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?;
|
||||||
@ -170,6 +171,7 @@ async fn fund_shared_account_from_public() -> Result<()> {
|
|||||||
pda: false,
|
pda: false,
|
||||||
seed: None,
|
seed: None,
|
||||||
program_id: None,
|
program_id: None,
|
||||||
|
identifier: None,
|
||||||
}));
|
}));
|
||||||
let result = wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?;
|
let result = wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?;
|
||||||
let SubcommandReturnValue::RegisterAccount {
|
let SubcommandReturnValue::RegisterAccount {
|
||||||
|
|||||||
@ -108,6 +108,10 @@ pub enum NewSubcommand {
|
|||||||
#[arg(long, requires = "pda")]
|
#[arg(long, requires = "pda")]
|
||||||
/// Program ID as hex string.
|
/// Program ID as hex string.
|
||||||
program_id: Option<String>,
|
program_id: Option<String>,
|
||||||
|
#[arg(long, requires = "pda")]
|
||||||
|
/// Identifier that diversifies this PDA within the (program_id, seed, npk) family.
|
||||||
|
/// Defaults to a random value if not specified.
|
||||||
|
identifier: Option<u128>,
|
||||||
},
|
},
|
||||||
/// Recommended for receiving from multiple senders: creates a key node (npk + vpk) without
|
/// Recommended for receiving from multiple senders: creates a key node (npk + vpk) without
|
||||||
/// registering any account.
|
/// registering any account.
|
||||||
@ -208,6 +212,7 @@ impl WalletSubcommand for NewSubcommand {
|
|||||||
pda,
|
pda,
|
||||||
seed,
|
seed,
|
||||||
program_id,
|
program_id,
|
||||||
|
identifier,
|
||||||
} => {
|
} => {
|
||||||
if let Some(label) = &label
|
if let Some(label) = &label
|
||||||
&& wallet_core
|
&& wallet_core
|
||||||
@ -239,7 +244,12 @@ impl WalletSubcommand for NewSubcommand {
|
|||||||
pid[i] = u32::from_le_bytes(chunk.try_into().unwrap());
|
pid[i] = u32::from_le_bytes(chunk.try_into().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
wallet_core.create_shared_pda_account(&group, pda_seed, pid)?
|
wallet_core.create_shared_pda_account(
|
||||||
|
&group,
|
||||||
|
pda_seed,
|
||||||
|
pid,
|
||||||
|
identifier.unwrap_or_else(rand::random),
|
||||||
|
)?
|
||||||
} else {
|
} else {
|
||||||
wallet_core.create_shared_regular_account(&group)?
|
wallet_core.create_shared_regular_account(&group)?
|
||||||
};
|
};
|
||||||
|
|||||||
@ -409,6 +409,7 @@ impl WalletCore {
|
|||||||
group_name: &str,
|
group_name: &str,
|
||||||
pda_seed: nssa_core::program::PdaSeed,
|
pda_seed: nssa_core::program::PdaSeed,
|
||||||
program_id: nssa_core::program::ProgramId,
|
program_id: nssa_core::program::ProgramId,
|
||||||
|
identifier: nssa_core::Identifier,
|
||||||
) -> Result<SharedAccountInfo> {
|
) -> Result<SharedAccountInfo> {
|
||||||
let holder = self
|
let holder = self
|
||||||
.storage
|
.storage
|
||||||
@ -419,12 +420,12 @@ impl WalletCore {
|
|||||||
let keys = holder.derive_keys_for_pda(&program_id, &pda_seed);
|
let keys = holder.derive_keys_for_pda(&program_id, &pda_seed);
|
||||||
let npk = keys.generate_nullifier_public_key();
|
let npk = keys.generate_nullifier_public_key();
|
||||||
let vpk = keys.generate_viewing_public_key();
|
let vpk = keys.generate_viewing_public_key();
|
||||||
let account_id = AccountId::for_private_pda(&program_id, &pda_seed, &npk, u128::MAX);
|
let account_id = AccountId::for_private_pda(&program_id, &pda_seed, &npk, identifier);
|
||||||
|
|
||||||
self.register_shared_account(
|
self.register_shared_account(
|
||||||
account_id,
|
account_id,
|
||||||
String::from(group_name),
|
String::from(group_name),
|
||||||
u128::MAX,
|
identifier,
|
||||||
Some(pda_seed),
|
Some(pda_seed),
|
||||||
Some(program_id),
|
Some(program_id),
|
||||||
);
|
);
|
||||||
@ -793,7 +794,7 @@ impl WalletCore {
|
|||||||
let shared_secret = SharedSecretKey::new(&vsk, &encrypted_data.epk);
|
let shared_secret = SharedSecretKey::new(&vsk, &encrypted_data.epk);
|
||||||
let commitment = &tx.message.new_commitments[ciph_id];
|
let commitment = &tx.message.new_commitments[ciph_id];
|
||||||
|
|
||||||
if let Some((_decrypted_identifier, new_acc)) = nssa_core::EncryptionScheme::decrypt(
|
if let Some((_kind, new_acc)) = nssa_core::EncryptionScheme::decrypt(
|
||||||
&encrypted_data.ciphertext,
|
&encrypted_data.ciphertext,
|
||||||
&shared_secret,
|
&shared_secret,
|
||||||
commitment,
|
commitment,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user