mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-02 21:33:09 +00:00
Merge branch 'Pravdyvy/wallet-pinata-private' into Pravdyvy/token-program-private
This commit is contained in:
commit
8e3fb2f67b
@ -13,7 +13,7 @@ use log::info;
|
||||
use nssa::{Account, Address};
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use nssa_core::Commitment;
|
||||
use nssa_core::{Commitment, MembershipProof};
|
||||
|
||||
use crate::cli::WalletSubcommand;
|
||||
use crate::{
|
||||
@ -135,16 +135,17 @@ impl WalletCore {
|
||||
Ok(NSSATransaction::try_from(&pub_tx)?)
|
||||
}
|
||||
|
||||
pub async fn check_private_account_initialized(&self, addr: &Address) -> bool {
|
||||
pub async fn check_private_account_initialized(
|
||||
&self,
|
||||
addr: &Address,
|
||||
) -> Result<Option<MembershipProof>> {
|
||||
if let Some(acc_comm) = self.get_private_account_commitment(addr) {
|
||||
matches!(
|
||||
self.sequencer_client
|
||||
.get_proof_for_commitment(acc_comm)
|
||||
.await,
|
||||
Ok(Some(_))
|
||||
)
|
||||
self.sequencer_client
|
||||
.get_proof_for_commitment(acc_comm)
|
||||
.await
|
||||
.map_err(anyhow::Error::from)
|
||||
} else {
|
||||
false
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
@ -691,16 +692,17 @@ pub async fn execute_subcommand(command: Command) -> Result<SubcommandReturnValu
|
||||
let pinata_addr = pinata_addr.parse().unwrap();
|
||||
let winner_addr = winner_addr.parse().unwrap();
|
||||
|
||||
let winner_intialized = wallet_core
|
||||
let winner_initialization = wallet_core
|
||||
.check_private_account_initialized(&winner_addr)
|
||||
.await;
|
||||
.await?;
|
||||
|
||||
let (res, [secret_winner]) = if winner_intialized {
|
||||
let (res, [secret_winner]) = if let Some(winner_proof) = winner_initialization {
|
||||
wallet_core
|
||||
.claim_pinata_private_owned_account_already_initialized(
|
||||
pinata_addr,
|
||||
winner_addr,
|
||||
solution,
|
||||
winner_proof,
|
||||
)
|
||||
.await?
|
||||
} else {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use common::{ExecutionFailureKind, sequencer_client::json::SendTxResponse};
|
||||
use key_protocol::key_management::ephemeral_key_holder::EphemeralKeyHolder;
|
||||
use nssa::{Address, privacy_preserving_transaction::circuit};
|
||||
use nssa_core::{Commitment, SharedSecretKey, account::AccountWithMetadata};
|
||||
use nssa_core::{MembershipProof, SharedSecretKey, account::AccountWithMetadata};
|
||||
|
||||
use crate::{WalletCore, helperfunctions::produce_random_nonces};
|
||||
|
||||
@ -29,6 +29,7 @@ impl WalletCore {
|
||||
pinata_addr: Address,
|
||||
winner_addr: Address,
|
||||
solution: u128,
|
||||
winner_proof: MembershipProof,
|
||||
) -> Result<(SendTxResponse, [SharedSecretKey; 1]), ExecutionFailureKind> {
|
||||
let Some((winner_keys, winner_acc)) = self
|
||||
.storage
|
||||
@ -46,8 +47,6 @@ impl WalletCore {
|
||||
|
||||
let program = nssa::program::Program::pinata();
|
||||
|
||||
let winner_commitment = Commitment::new(&winner_npk, &winner_acc);
|
||||
|
||||
let pinata_pre = AccountWithMetadata::new(pinata_acc.clone(), false, pinata_addr);
|
||||
let winner_pre = AccountWithMetadata::new(winner_acc.clone(), true, &winner_npk);
|
||||
|
||||
@ -62,11 +61,7 @@ impl WalletCore {
|
||||
&[(winner_npk.clone(), shared_secret_winner.clone())],
|
||||
&[(
|
||||
winner_keys.private_key_holder.nullifier_secret_key,
|
||||
self.sequencer_client
|
||||
.get_proof_for_commitment(winner_commitment)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap(),
|
||||
winner_proof,
|
||||
)],
|
||||
&program,
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user