mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-04-12 06:03:08 +00:00
troubleshooting
This commit is contained in:
parent
521cb2312b
commit
08bae6fa82
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -63,14 +63,14 @@ impl InitialData {
|
||||
}
|
||||
|
||||
let mut private_charlie_key_chain = KeyChain::new_os_random();
|
||||
let private_charlie_identifier = Identifier::new_os_random();
|
||||
let mut private_charlie_identifier = Identifier::new_os_random();
|
||||
let mut private_charlie_account_id = AccountId::private_account_id(
|
||||
&private_charlie_key_chain.nullifier_public_key,
|
||||
private_charlie_identifier,
|
||||
);
|
||||
|
||||
let mut private_david_key_chain = KeyChain::new_os_random();
|
||||
let private_david_identifier = Identifier::new_os_random();
|
||||
let mut private_david_identifier = Identifier::new_os_random();
|
||||
let mut private_david_account_id = AccountId::private_account_id(
|
||||
&private_david_key_chain.nullifier_public_key,
|
||||
private_david_identifier,
|
||||
@ -83,6 +83,10 @@ impl InitialData {
|
||||
&mut private_charlie_account_id,
|
||||
&mut private_david_account_id,
|
||||
);
|
||||
std::mem::swap(
|
||||
&mut private_charlie_identifier,
|
||||
&mut private_david_identifier,
|
||||
);
|
||||
}
|
||||
|
||||
Self {
|
||||
|
||||
@ -49,7 +49,6 @@ async fn private_transfer_to_owned_account() -> Result<()> {
|
||||
.get_private_account_commitment(to)
|
||||
.context("Failed to get private account commitment for receiver")?;
|
||||
assert!(verify_commitment_is_in_state(new_commitment2, ctx.sequencer_client()).await);
|
||||
|
||||
info!("Successfully transferred privately to owned account");
|
||||
|
||||
Ok(())
|
||||
@ -75,26 +74,24 @@ async fn private_transfer_to_foreign_account() -> Result<()> {
|
||||
});
|
||||
|
||||
let result = wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?;
|
||||
let SubcommandReturnValue::PrivacyPreservingTransfer { tx_hash } = result else {
|
||||
let SubcommandReturnValue::PrivacyPreservingTransfer { tx_hash: _ } = result else {
|
||||
anyhow::bail!("Expected PrivacyPreservingTransfer return value");
|
||||
};
|
||||
|
||||
info!("Waiting for next block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
let new_commitment1 = ctx
|
||||
.wallet()
|
||||
.get_private_account_commitment(from)
|
||||
.context("Failed to get private account commitment for sender")?;
|
||||
|
||||
let tx = fetch_privacy_preserving_tx(ctx.sequencer_client(), tx_hash).await;
|
||||
assert_eq!(tx.message.new_commitments[0], new_commitment1);
|
||||
|
||||
assert_eq!(tx.message.new_commitments.len(), 2);
|
||||
for commitment in tx.message.new_commitments {
|
||||
assert!(verify_commitment_is_in_state(commitment, ctx.sequencer_client()).await);
|
||||
}
|
||||
|
||||
// info!("Waiting for next block creation");
|
||||
// tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
//
|
||||
// let new_commitment1 = ctx
|
||||
// .wallet()
|
||||
// .get_private_account_commitment(from)
|
||||
// .context("Failed to get private account commitment for sender")?;
|
||||
//
|
||||
// let tx = fetch_privacy_preserving_tx(ctx.sequencer_client(), tx_hash).await;
|
||||
// assert_eq!(tx.message.new_commitments[0], new_commitment1);
|
||||
//
|
||||
// assert_eq!(tx.message.new_commitments.len(), 2);
|
||||
// for commitment in tx.message.new_commitments {
|
||||
// assert!(verify_commitment_is_in_state(commitment, ctx.sequencer_client()).await);
|
||||
// }
|
||||
info!("Successfully transferred privately to foreign account");
|
||||
|
||||
Ok(())
|
||||
|
||||
@ -110,7 +110,7 @@ impl KeyNode for ChildKeysPrivate {
|
||||
viewing_secret_key: vsk,
|
||||
},
|
||||
},
|
||||
identifier: Identifier(0_u128),
|
||||
identifier: Identifier(0_u128), // TODO: this Marvin
|
||||
account: nssa::Account::default(),
|
||||
},
|
||||
ccc,
|
||||
|
||||
@ -162,9 +162,9 @@ pub mod tests {
|
||||
|
||||
let encrypted_private_post_states = Vec::new();
|
||||
|
||||
let new_commitments = vec![Commitment::new(&account_id1, &account2)];
|
||||
let new_commitments = vec![Commitment::new(&account_id2, &account2)];
|
||||
|
||||
let old_commitment = Commitment::new(&account_id2, &account1);
|
||||
let old_commitment = Commitment::new(&account_id1, &account1);
|
||||
let new_nullifiers = vec![(
|
||||
Nullifier::for_account_update(&old_commitment, &nsk1),
|
||||
[0; 32],
|
||||
|
||||
@ -377,13 +377,12 @@ fn compute_circuit_output(
|
||||
let Some(membership_proof_opt) = private_membership_proofs_iter.next() else {
|
||||
panic!("Missing membership proof");
|
||||
};
|
||||
|
||||
// TODO: here is the issue
|
||||
let new_nullifier = compute_nullifier_and_set_digest(
|
||||
membership_proof_opt.as_ref(),
|
||||
&pre_state.account,
|
||||
npk,
|
||||
&pre_state.account_id,
|
||||
nsk,
|
||||
*identifier,
|
||||
);
|
||||
|
||||
let new_nonce = pre_state.account.nonce.private_account_nonce_increment(nsk);
|
||||
@ -465,31 +464,28 @@ fn compute_circuit_output(
|
||||
output
|
||||
}
|
||||
|
||||
// Marvin: todo
|
||||
fn compute_nullifier_and_set_digest(
|
||||
membership_proof_opt: Option<&MembershipProof>,
|
||||
pre_account: &Account,
|
||||
npk: &NullifierPublicKey,
|
||||
account_id: &AccountId,
|
||||
nsk: &NullifierSecretKey,
|
||||
identifier: Identifier,
|
||||
) -> (Nullifier, CommitmentSetDigest) {
|
||||
// TODO: consider rewriting the function to receive account id instead of npk.
|
||||
// NOTE: this does not use the identifier at all.
|
||||
let account_id = AccountId::private_account_id(npk, identifier);
|
||||
membership_proof_opt.as_ref().map_or_else(
|
||||
|| {
|
||||
assert_eq!(
|
||||
*pre_account,
|
||||
Account::default(),
|
||||
"Found new private account with non default values"
|
||||
"Found new private account with non default values$Marvin$"
|
||||
);
|
||||
|
||||
// Compute initialization nullifier
|
||||
let nullifier = Nullifier::for_account_initialization(&account_id);
|
||||
let nullifier = Nullifier::for_account_initialization(account_id);
|
||||
(nullifier, DUMMY_COMMITMENT_HASH)
|
||||
},
|
||||
|membership_proof| {
|
||||
// Compute commitment set digest associated with provided auth path
|
||||
let commitment_pre = Commitment::new(&account_id, pre_account);
|
||||
let commitment_pre = Commitment::new(account_id, pre_account);
|
||||
let set_digest = compute_digest_for_path(&commitment_pre, membership_proof);
|
||||
|
||||
// Compute update nullifier
|
||||
|
||||
@ -114,7 +114,7 @@ impl<BC: BlockSettlementClientTrait, IC: IndexerClientTrait> SequencerCore<BC, I
|
||||
let npk = &init_comm_data.npk;
|
||||
|
||||
let mut acc = init_comm_data.account.clone();
|
||||
let acc_id = &AccountId::private_account_id(npk, Identifier(0_u128));
|
||||
let acc_id = &AccountId::private_account_id(npk, Identifier(0_u128)); //TODO marvin
|
||||
acc.program_owner =
|
||||
nssa::program::Program::authenticated_transfer_program().id();
|
||||
|
||||
|
||||
@ -223,7 +223,8 @@ pub fn initial_state() -> V03State {
|
||||
let initial_commitments: Vec<nssa_core::Commitment> = initial_commitments()
|
||||
.iter()
|
||||
.map(|init_comm_data| {
|
||||
let acc_id = &AccountId::private_account_id(&init_comm_data.npk, init_comm_data.identifier);
|
||||
let acc_id =
|
||||
&AccountId::private_account_id(&init_comm_data.npk, init_comm_data.identifier);
|
||||
|
||||
let mut acc = init_comm_data.account.clone();
|
||||
|
||||
|
||||
@ -27,9 +27,7 @@ use nssa::{
|
||||
},
|
||||
};
|
||||
use nssa_core::{
|
||||
Commitment, MembershipProof, SharedSecretKey,
|
||||
account::{Identifier, Nonce},
|
||||
program::InstructionData,
|
||||
Commitment, MembershipProof, SharedSecretKey, account::Nonce, program::InstructionData,
|
||||
};
|
||||
pub use privacy_preserving_tx::PrivacyPreservingAccount;
|
||||
use sequencer_service_rpc::{RpcClient as _, SequencerClient, SequencerClientBuilder};
|
||||
@ -309,7 +307,7 @@ impl WalletCore {
|
||||
Some(Commitment::new(
|
||||
&AccountId::private_account_id(
|
||||
&bundle.key_chain.nullifier_public_key,
|
||||
Identifier(0_u128),
|
||||
bundle.identifier,
|
||||
),
|
||||
&bundle.account,
|
||||
))
|
||||
@ -398,7 +396,12 @@ impl WalletCore {
|
||||
)?;
|
||||
|
||||
let private_account_keys = acc_manager.private_account_keys();
|
||||
let private_account_identifiers = acc_manager.private_account_identifiers();
|
||||
let private_account_identifiers =
|
||||
acc_manager.private_account_identifiers(&private_account_keys);
|
||||
// TODO: here. This is the function I want to use
|
||||
// Okay. Now I have the "corrected" identifiers but NOT correct account_ids! (Marvin)
|
||||
// -> So, we need to update AccountIds with these identifiers
|
||||
|
||||
let (output, proof) = nssa::privacy_preserving_transaction::circuit::execute_and_prove(
|
||||
pre_states,
|
||||
instruction_data,
|
||||
@ -408,7 +411,7 @@ impl WalletCore {
|
||||
.map(|keys| (keys.npk.clone(), keys.ssk))
|
||||
.collect::<Vec<_>>(),
|
||||
acc_manager.private_account_auth(),
|
||||
private_account_identifiers.clone(),
|
||||
private_account_identifiers.clone(), // TODO: when was this done? Marvin
|
||||
acc_manager.private_account_membership_proofs(),
|
||||
&program.to_owned(),
|
||||
)
|
||||
@ -423,7 +426,7 @@ impl WalletCore {
|
||||
.zip(private_account_identifiers)
|
||||
.map(|(keys, identifier)| {
|
||||
(
|
||||
AccountId::private_account_id(&keys.npk.clone(), identifier),
|
||||
AccountId::private_account_id(&keys.npk.clone(), identifier),
|
||||
keys.vpk.clone(),
|
||||
keys.epk.clone(),
|
||||
)
|
||||
@ -526,11 +529,9 @@ impl WalletCore {
|
||||
|
||||
let affected_accounts = private_account_key_chains
|
||||
.flat_map(|(acc_account_id, key_chain, index)| {
|
||||
// Why index? Marvin
|
||||
let view_tag = EncryptedAccountData::compute_view_tag(
|
||||
&AccountId::private_account_id(
|
||||
&key_chain.nullifier_public_key,
|
||||
Identifier(0_u128),
|
||||
),
|
||||
&acc_account_id,
|
||||
&key_chain.viewing_public_key,
|
||||
);
|
||||
|
||||
|
||||
@ -83,11 +83,11 @@ impl AccountManager {
|
||||
}
|
||||
|
||||
PrivacyPreservingAccount::PrivateForeign { npk, vpk } => {
|
||||
let account_id = AccountId::private_account_id(&npk, Identifier::default()); //TODO: here (Marvin) Should be based on epk
|
||||
let account_id = AccountId::private_account_id(&npk, Identifier::default()); //Okay. This is being used a flag currently (Marvin) trying something
|
||||
let acc = nssa_core::account::Account::default();
|
||||
let auth_acc = AccountWithMetadata::new(acc, false, account_id);
|
||||
let pre = AccountPreparedData {
|
||||
identifier: Identifier::default(), //TODO: here
|
||||
identifier: Identifier::default(), // TODO: ugh. Marvin
|
||||
nsk: None,
|
||||
npk,
|
||||
vpk,
|
||||
@ -153,12 +153,21 @@ impl AccountManager {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn private_account_identifiers(&self) -> Vec<Identifier> {
|
||||
pub fn private_account_identifiers(
|
||||
&self,
|
||||
private_account_keys: &Vec<PrivateAccountKeys>,
|
||||
) -> Vec<Identifier> {
|
||||
self.states
|
||||
.iter()
|
||||
.filter_map(|state| match state {
|
||||
.zip(private_account_keys)
|
||||
.filter_map(|(state, key)| match state {
|
||||
State::Private(pre) => {
|
||||
Some(pre.identifier)
|
||||
if pre.identifier == Identifier::default() {
|
||||
// Some(Identifier::default()) ATA works here ATA issue (Marvin)
|
||||
Some(Identifier::private_identifier(&key.epk, 0)) //TODO: currently using a placeholder index (Marvin)
|
||||
} else {
|
||||
Some(pre.identifier)
|
||||
}
|
||||
}
|
||||
State::Public { .. } => None,
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user