update nonce mechanism

This commit is contained in:
jonesmarvin8 2026-02-12 19:22:03 -05:00
parent cb6fb881ac
commit 77f2fb6994
54 changed files with 276 additions and 280 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,5 @@
use nssa::AccountId;
use nssa_core::account::Nonce;
use crate::{
HashType,
@ -64,7 +65,7 @@ pub fn create_transaction_native_token_transfer(
signing_key: nssa::PrivateKey,
) -> NSSATransaction {
let account_ids = vec![from, to];
let nonces = vec![nonce];
let nonces = vec![Nonce(nonce)];
let program_id = nssa::program::Program::authenticated_transfer_program().id();
let message = nssa::public_transaction::Message::try_new(
program_id,

View File

@ -3,6 +3,7 @@ use nssa::{
program::Program,
public_transaction::{Message, WitnessSet},
};
use nssa_core::account::Nonce;
use wallet::WalletCore;
// Before running this example, compile the `hello_world_with_authorization.rs` guest program with:
@ -62,7 +63,7 @@ async fn main() {
.await
.expect("Node should be reachable to query account data");
let signing_keys = [signing_key];
let message = Message::try_new(program.id(), vec![account_id], nonces, greeting).unwrap();
let message = Message::try_new(program.id(), vec![account_id], nonces.iter().map(|x|Nonce(*x)).collect(), greeting).unwrap();
// Pass the signing key to sign the message. This will be used by the node
// to flag the pre_state as `is_authorized` when executing the program
let witness_set = WitnessSet::for_message(&message, &signing_keys);

View File

@ -33,7 +33,7 @@ pub fn AccountPreview(account_id: AccountId, account: Account) -> impl IntoView
</div>
<div class="account-field">
<span class="field-label">"Nonce: "</span>
<span class="field-value">{nonce.to_string()}</span>
<span class="field-value">{nonce.0.to_string()}</span>
</div>
<div class="account-field">
<span class="field-label">"Data: "</span>

View File

@ -101,7 +101,7 @@ pub fn AccountPage() -> impl IntoView {
let account_id_str = format_utils::format_account_id(&acc_id);
let program_id = format_utils::format_program_id(&program_owner);
let balance_str = balance.to_string();
let nonce_str = nonce.to_string();
let nonce_str = nonce.0.to_string();
let data_len = data.0.len();
view! {
<div class="account-detail">

View File

@ -130,7 +130,7 @@ pub fn TransactionPage() -> impl IntoView {
<span class="hash">{account_id_str}</span>
</A>
<span class="nonce">
" (nonce: " {nonce.to_string()} ")"
" (nonce: " {nonce.0.to_string()} ")"
</span>
</div>
}
@ -204,7 +204,7 @@ pub fn TransactionPage() -> impl IntoView {
<span class="hash">{account_id_str}</span>
</A>
<span class="nonce">
" (nonce: " {nonce.to_string()} ")"
" (nonce: " {nonce.0.to_string()} ")"
</span>
</div>
}

View File

@ -34,7 +34,7 @@ impl From<nssa_core::account::Account> for Account {
program_owner,
balance,
data: data.into(),
nonce,
nonce: Nonce(nonce.0),
}
}
}
@ -54,7 +54,7 @@ impl TryFrom<Account> for nssa_core::account::Account {
program_owner,
balance,
data: data.try_into()?,
nonce,
nonce: nssa_core::account::Nonce(nonce.0),
})
}
}
@ -232,7 +232,7 @@ impl From<nssa::public_transaction::Message> for PublicMessage {
Self {
program_id,
account_ids: account_ids.into_iter().map(Into::into).collect(),
nonces,
nonces: nonces.iter().map(|x|Nonce(x.0)).collect(),
instruction_data,
}
}
@ -249,7 +249,7 @@ impl From<PublicMessage> for nssa::public_transaction::Message {
Self::new_preserialized(
program_id,
account_ids.into_iter().map(Into::into).collect(),
nonces,
nonces.iter().map(|x|nssa_core::account::Nonce(x.0)).collect(),
instruction_data,
)
}
@ -267,7 +267,7 @@ impl From<nssa::privacy_preserving_transaction::message::Message> for PrivacyPre
} = value;
Self {
public_account_ids: public_account_ids.into_iter().map(Into::into).collect(),
nonces,
nonces: nonces.iter().map(|x|Nonce(x.0)).collect(),
public_post_states: public_post_states.into_iter().map(Into::into).collect(),
encrypted_private_post_states: encrypted_private_post_states
.into_iter()
@ -296,7 +296,7 @@ impl TryFrom<PrivacyPreservingMessage> for nssa::privacy_preserving_transaction:
} = value;
Ok(Self {
public_account_ids: public_account_ids.into_iter().map(Into::into).collect(),
nonces,
nonces: nonces.iter().map(|x|nssa_core::account::Nonce(x.0)).collect(),
public_post_states: public_post_states
.into_iter()
.map(TryInto::try_into)

View File

@ -9,7 +9,8 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "convert")]
mod convert;
pub type Nonce = u128;
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
pub struct Nonce(pub u128);
pub type ProgramId = [u32; 8];

View File

@ -4,7 +4,7 @@ use anyhow::{Context, Result};
use indexer_service::{BackoffConfig, BedrockClientConfig, ChannelId, IndexerConfig};
use key_protocol::key_management::KeyChain;
use nssa::{Account, AccountId, PrivateKey, PublicKey};
use nssa_core::{account::Data, program::DEFAULT_PROGRAM_ID};
use nssa_core::{account::{Data, Nonce}, program::DEFAULT_PROGRAM_ID};
use sequencer_core::config::{
AccountInitialData, BedrockConfig, CommitmentsInitialData, SequencerConfig,
};
@ -156,7 +156,7 @@ impl InitialData {
balance: 10_000,
data: Data::default(),
program_owner: DEFAULT_PROGRAM_ID,
nonce: 0,
nonce: Nonce(0),
},
),
(
@ -165,7 +165,7 @@ impl InitialData {
balance: 20_000,
data: Data::default(),
program_owner: DEFAULT_PROGRAM_ID,
nonce: 0,
nonce: Nonce(0),
},
),
],

View File

@ -20,7 +20,7 @@ async fn get_existing_account() -> Result<()> {
);
assert_eq!(account.balance, 10000);
assert!(account.data.is_empty());
assert_eq!(account.nonce, 0);
assert_eq!(account.nonce.0, 0);
info!("Successfully retrieved account with correct details");

View File

@ -235,7 +235,7 @@ async fn initialize_public_account() -> Result<()> {
Program::authenticated_transfer_program().id()
);
assert_eq!(account.balance, 0);
assert_eq!(account.nonce, 1);
assert_eq!(account.nonce.0, 1);
assert!(account.data.is_empty());
info!("Successfully initialized public account");

View File

@ -58,7 +58,7 @@ async fn deploy_and_execute_program() -> Result<()> {
assert_eq!(post_state_account.program_owner, data_changer.id());
assert_eq!(post_state_account.balance, 0);
assert_eq!(post_state_account.data.as_ref(), &[0]);
assert_eq!(post_state_account.nonce, 0);
assert_eq!(post_state_account.nonce.0, 0);
info!("Successfully deployed and executed program");

View File

@ -15,7 +15,7 @@ use nssa::{
};
use nssa_core::{
MembershipProof, NullifierPublicKey,
account::{AccountWithMetadata, data::Data},
account::{AccountWithMetadata, data::Data, Nonce},
encryption::IncomingViewingPublicKey,
};
use tokio::test;
@ -135,7 +135,7 @@ impl TpsTestManager {
let message = putx::Message::try_new(
program.id(),
[pair[0].1, pair[1].1].to_vec(),
[0u128].to_vec(),
[Nonce(0u128)].to_vec(),
amount,
)
.unwrap();
@ -164,7 +164,7 @@ impl TpsTestManager {
let key_chain = KeyChain::new_os_random();
let account = Account {
balance: 100,
nonce: 0xdeadbeef,
nonce: Nonce(0xdeadbeef),
program_owner: Program::authenticated_transfer_program().id(),
data: Data::default(),
};
@ -198,7 +198,7 @@ fn build_privacy_transaction() -> PrivacyPreservingTransaction {
let sender_pre = AccountWithMetadata::new(
Account {
balance: 100,
nonce: 0xdeadbeef,
nonce: Nonce(0xdeadbeef),
program_owner: program.id(),
data: Data::default(),
},
@ -232,7 +232,6 @@ fn build_privacy_transaction() -> PrivacyPreservingTransaction {
vec![sender_pre, recipient_pre],
Program::serialize_instruction(balance_to_move).unwrap(),
vec![1, 2],
vec![0xdeadbeef1, 0xdeadbeef2],
vec![
(sender_npk.clone(), sender_ss),
(recipient_npk.clone(), recipient_ss),

View File

@ -373,7 +373,7 @@ fn test_wallet_ffi_get_account_public() -> Result<()> {
);
assert_eq!(account.balance, 10000);
assert!(account.data.is_empty());
assert_eq!(account.nonce, 0);
assert_eq!(account.nonce.0, 0);
unsafe {
wallet_ffi_free_account_data((&mut out_account) as *mut FfiAccount);

View File

@ -3,14 +3,43 @@ use std::{fmt::Display, str::FromStr};
use base58::{FromBase58, ToBase58};
use borsh::{BorshDeserialize, BorshSerialize};
pub use data::Data;
use risc0_zkvm::{guest::sha::guest::Impl, sha::Sha256};
use serde::{Deserialize, Serialize};
use serde_with::{DeserializeFromStr, SerializeDisplay};
use crate::program::ProgramId;
use crate::{NullifierPublicKey, NullifierSecretKey, program::ProgramId};
pub mod data;
pub type Nonce = u128;
#[derive(Copy, Debug, Default, Clone, Eq, PartialEq, Serialize, Deserialize, BorshDeserialize, BorshSerialize)]
pub struct Nonce(pub u128);
impl Nonce {
pub fn public_account_nonce_increment(mut self) {
self.0 += 1;
}
pub fn private_account_nonce_init(self, npk: &NullifierPublicKey) -> Nonce {
let mut bytes = Vec::new();
bytes.extend_from_slice(&npk.to_byte_array());
let bytes = Impl::hash_bytes(&bytes).as_bytes();
let bytes = bytes.first_chunk::<16>().unwrap();
Nonce(u128::from_le_bytes(*bytes))
}
pub fn private_account_nonce_increment(self, nsk: &NullifierSecretKey) -> Nonce {
let mut bytes = Vec::new();
bytes.extend_from_slice(nsk);
let bytes = Impl::hash_bytes(&bytes).as_bytes();
let bytes = bytes.first_chunk::<16>().unwrap();
Nonce(u128::from_le_bytes(*bytes))
}
}
/// Account to be used both in public and private contexts
#[derive(
@ -123,7 +152,7 @@ mod tests {
fn test_zero_nonce_account_data_creation() {
let new_acc = Account::default();
assert_eq!(new_acc.nonce, 0);
assert_eq!(new_acc.nonce.0, 0);
}
#[test]
@ -150,7 +179,7 @@ mod tests {
.to_vec()
.try_into()
.unwrap(),
nonce: 0xdeadbeef,
nonce: Nonce(0xdeadbeef),
};
let fingerprint = AccountId::new([8; 32]);
let new_acc_with_metadata = AccountWithMetadata::new(account.clone(), true, fingerprint);

View File

@ -18,8 +18,6 @@ pub struct PrivacyPreservingCircuitInput {
/// - `1` - private account with authentication
/// - `2` - private account without authentication
pub visibility_mask: Vec<u8>,
/// Nonces of private accounts.
pub private_account_nonces: Vec<Nonce>,
/// Public keys of private accounts.
pub private_account_keys: Vec<(NullifierPublicKey, SharedSecretKey)>,
/// Nullifier secret keys for authorized private accounts.
@ -67,7 +65,7 @@ mod tests {
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
balance: 12345678901234567890,
data: b"test data".to_vec().try_into().unwrap(),
nonce: 18446744073709551614,
nonce: Nonce(18446744073709551614),
},
true,
AccountId::new([0; 32]),
@ -77,7 +75,7 @@ mod tests {
program_owner: [9, 9, 9, 8, 8, 8, 7, 7],
balance: 123123123456456567112,
data: b"test data".to_vec().try_into().unwrap(),
nonce: 9999999999999999999999,
nonce: Nonce(9999999999999999999999),
},
false,
AccountId::new([1; 32]),
@ -87,7 +85,7 @@ mod tests {
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
balance: 100,
data: b"post state data".to_vec().try_into().unwrap(),
nonce: 18446744073709551615,
nonce: Nonce(18446744073709551615),
}],
ciphertexts: vec![Ciphertext(vec![255, 255, 1, 1, 2, 2])],
new_commitments: vec![Commitment::new(

View File

@ -47,7 +47,7 @@ impl Commitment {
this.extend_from_slice(&word.to_le_bytes());
}
this.extend_from_slice(&account.balance.to_le_bytes());
this.extend_from_slice(&account.nonce.to_le_bytes());
this.extend_from_slice(&account.nonce.0.to_le_bytes());
let hashed_data: [u8; 32] = Impl::hash_bytes(&account.data)
.as_bytes()
.try_into()

View File

@ -23,7 +23,7 @@ impl Account {
bytes.extend_from_slice(&word.to_le_bytes());
}
bytes.extend_from_slice(&self.balance.to_le_bytes());
bytes.extend_from_slice(&self.nonce.to_le_bytes());
bytes.extend_from_slice(&self.nonce.0.to_le_bytes());
let data_length: u32 = self.data.len() as u32;
bytes.extend_from_slice(&data_length.to_le_bytes());
bytes.extend_from_slice(self.data.as_ref());
@ -32,7 +32,7 @@ impl Account {
#[cfg(feature = "host")]
pub fn from_cursor(cursor: &mut Cursor<&[u8]>) -> Result<Self, NssaCoreError> {
use crate::account::data::Data;
use crate::account::{Nonce, data::Data};
let mut u32_bytes = [0u8; 4];
let mut u128_bytes = [0u8; 16];
@ -50,7 +50,7 @@ impl Account {
// nonce
cursor.read_exact(&mut u128_bytes)?;
let nonce = u128::from_le_bytes(u128_bytes);
let nonce = Nonce(u128::from_le_bytes(u128_bytes));
// data
let data = Data::from_cursor(cursor)?;
@ -160,6 +160,8 @@ impl AccountId {
#[cfg(test)]
mod tests {
use crate::account::Nonce;
use super::*;
#[test]
@ -167,7 +169,7 @@ mod tests {
let account = Account {
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
balance: 123456789012345678901234567890123456,
nonce: 42,
nonce: Nonce(42),
data: b"hola mundo".to_vec().try_into().unwrap(),
};
@ -225,10 +227,12 @@ mod tests {
#[cfg(feature = "host")]
#[test]
fn test_account_to_bytes_roundtrip() {
use crate::account::Nonce;
let account = Account {
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
balance: 123456789012345678901234567890123456,
nonce: 42,
nonce: Nonce(42),
data: b"hola mundo".to_vec().try_into().unwrap(),
};
let bytes = account.to_bytes();

View File

@ -327,6 +327,8 @@ impl WrappedBalanceSum {
#[cfg(test)]
mod tests {
use crate::account::Nonce;
use super::*;
#[test]
@ -335,7 +337,7 @@ mod tests {
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
balance: 1337,
data: vec![0xde, 0xad, 0xbe, 0xef].try_into().unwrap(),
nonce: 10,
nonce: Nonce(10),
};
let account_post_state = AccountPostState::new_claimed(account.clone());
@ -350,7 +352,7 @@ mod tests {
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
balance: 1337,
data: vec![0xde, 0xad, 0xbe, 0xef].try_into().unwrap(),
nonce: 10,
nonce: Nonce(10),
};
let account_post_state = AccountPostState::new(account.clone());
@ -365,7 +367,7 @@ mod tests {
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
balance: 1337,
data: vec![0xde, 0xad, 0xbe, 0xef].try_into().unwrap(),
nonce: 10,
nonce: Nonce(10),
};
let mut account_post_state = AccountPostState::new(account.clone());

View File

@ -59,7 +59,6 @@ pub fn execute_and_prove(
pre_states: Vec<AccountWithMetadata>,
instruction_data: InstructionData,
visibility_mask: Vec<u8>,
private_account_nonces: Vec<u128>,
private_account_keys: Vec<(NullifierPublicKey, SharedSecretKey)>,
private_account_nsks: Vec<NullifierSecretKey>,
private_account_membership_proofs: Vec<Option<MembershipProof>>,
@ -116,7 +115,6 @@ pub fn execute_and_prove(
let circuit_input = PrivacyPreservingCircuitInput {
program_outputs,
visibility_mask,
private_account_nonces,
private_account_keys,
private_account_nsks,
private_account_membership_proofs,
@ -171,7 +169,7 @@ impl Proof {
mod tests {
use nssa_core::{
Commitment, DUMMY_COMMITMENT_HASH, EncryptionScheme, Nullifier,
account::{Account, AccountId, AccountWithMetadata, data::Data},
account::{Account, AccountId, AccountWithMetadata, Nonce, data::Data},
};
use super::*;
@ -209,14 +207,14 @@ mod tests {
let expected_sender_post = Account {
program_owner: program.id(),
balance: 100 - balance_to_move,
nonce: 0,
nonce: Nonce(0),
data: Data::default(),
};
let expected_recipient_post = Account {
program_owner: program.id(),
balance: balance_to_move,
nonce: 0xdeadbeef,
nonce: Nonce(0xdeadbeef),
data: Data::default(),
};
@ -229,7 +227,6 @@ mod tests {
vec![sender, recipient],
Program::serialize_instruction(balance_to_move).unwrap(),
vec![0, 2],
vec![0xdeadbeef],
vec![(recipient_keys.npk(), shared_secret)],
vec![],
vec![None],
@ -266,7 +263,7 @@ mod tests {
let sender_pre = AccountWithMetadata::new(
Account {
balance: 100,
nonce: 0xdeadbeef,
nonce: Nonce(0xdeadbeef),
program_owner: program.id(),
data: Data::default(),
},
@ -301,13 +298,13 @@ mod tests {
let expected_private_account_1 = Account {
program_owner: program.id(),
balance: 100 - balance_to_move,
nonce: 0xdeadbeef1,
nonce: Nonce(0xdeadbeef1),
..Default::default()
};
let expected_private_account_2 = Account {
program_owner: program.id(),
balance: balance_to_move,
nonce: 0xdeadbeef2,
nonce: Nonce(0xdeadbeef2),
..Default::default()
};
let expected_new_commitments = vec![
@ -325,7 +322,6 @@ mod tests {
vec![sender_pre.clone(), recipient],
Program::serialize_instruction(balance_to_move).unwrap(),
vec![1, 2],
vec![0xdeadbeef1, 0xdeadbeef2],
vec![
(sender_keys.npk(), shared_secret_1),
(recipient_keys.npk(), shared_secret_2),

View File

@ -93,7 +93,7 @@ impl Message {
pub mod tests {
use nssa_core::{
Commitment, EncryptionScheme, Nullifier, NullifierPublicKey, SharedSecretKey,
account::Account,
account::{Account, Nonce},
encryption::{EphemeralPublicKey, IncomingViewingPublicKey},
};
use sha2::{Digest, Sha256};
@ -115,7 +115,7 @@ pub mod tests {
let public_account_ids = vec![AccountId::new([1; 32])];
let nonces = vec![1, 2, 3];
let nonces = vec![Nonce(1), Nonce(2), Nonce(3)];
let public_post_states = vec![Account::default()];

View File

@ -222,6 +222,7 @@ impl PublicTransaction {
#[cfg(test)]
pub mod tests {
use nssa_core::account::Nonce;
use sha2::{Digest, digest::FixedOutput};
use crate::{
@ -247,7 +248,7 @@ pub mod tests {
fn transaction_for_tests() -> PublicTransaction {
let (key1, key2, addr1, addr2) = keys_for_tests();
let nonces = vec![0, 0];
let nonces = vec![Nonce(0), Nonce(0)];
let instruction = 1337;
let message = Message::try_new(
Program::authenticated_transfer_program().id(),
@ -325,7 +326,7 @@ pub mod tests {
fn test_account_id_list_cant_have_duplicates() {
let (key1, _, addr1, _) = keys_for_tests();
let state = state_for_tests();
let nonces = vec![0, 0];
let nonces = vec![Nonce(0), Nonce(0)];
let instruction = 1337;
let message = Message::try_new(
Program::authenticated_transfer_program().id(),
@ -345,7 +346,7 @@ pub mod tests {
fn test_number_of_nonces_must_match_number_of_signatures() {
let (key1, key2, addr1, addr2) = keys_for_tests();
let state = state_for_tests();
let nonces = vec![0];
let nonces = vec![Nonce(0)];
let instruction = 1337;
let message = Message::try_new(
Program::authenticated_transfer_program().id(),
@ -365,7 +366,7 @@ pub mod tests {
fn test_all_signatures_must_be_valid() {
let (key1, key2, addr1, addr2) = keys_for_tests();
let state = state_for_tests();
let nonces = vec![0, 0];
let nonces = vec![Nonce(0), Nonce(0)];
let instruction = 1337;
let message = Message::try_new(
Program::authenticated_transfer_program().id(),
@ -386,7 +387,7 @@ pub mod tests {
fn test_nonces_must_match_the_state_current_nonces() {
let (key1, key2, addr1, addr2) = keys_for_tests();
let state = state_for_tests();
let nonces = vec![0, 1];
let nonces = vec![Nonce(0), Nonce(1)];
let instruction = 1337;
let message = Message::try_new(
Program::authenticated_transfer_program().id(),
@ -406,7 +407,7 @@ pub mod tests {
fn test_program_id_must_belong_to_bulitin_program_ids() {
let (key1, key2, addr1, addr2) = keys_for_tests();
let state = state_for_tests();
let nonces = vec![0, 0];
let nonces = vec![Nonce(0), Nonce(0)];
let instruction = 1337;
let unknown_program_id = [0xdeadbeef; 8];
let message =

View File

@ -51,6 +51,8 @@ impl WitnessSet {
#[cfg(test)]
mod tests {
use nssa_core::account::Nonce;
use super::*;
use crate::AccountId;
@ -62,7 +64,7 @@ mod tests {
let pubkey2 = PublicKey::new_from_private_key(&key2);
let addr1 = AccountId::from(&pubkey1);
let addr2 = AccountId::from(&pubkey2);
let nonces = vec![1, 2];
let nonces = vec![Nonce(1), Nonce(2)];
let instruction = vec![1, 2, 3, 4];
let message = Message::try_new([0; 8], vec![addr1, addr2], nonces, instruction).unwrap();

View File

@ -3,7 +3,7 @@ use std::collections::{BTreeSet, HashMap, HashSet};
use borsh::{BorshDeserialize, BorshSerialize};
use nssa_core::{
Commitment, CommitmentSetDigest, DUMMY_COMMITMENT, MembershipProof, Nullifier,
account::{Account, AccountId},
account::{Account, AccountId, Nonce},
program::ProgramId,
};
@ -166,7 +166,7 @@ impl V02State {
for account_id in tx.signer_account_ids() {
let current_account = self.get_account_by_id_mut(account_id);
current_account.nonce += 1;
current_account.nonce.0 += 1;
}
Ok(())
@ -202,7 +202,7 @@ impl V02State {
// 5. Increment nonces for public signers
for account_id in tx.signer_account_ids() {
let current_account = self.get_account_by_id_mut(account_id);
current_account.nonce += 1;
current_account.nonce.0 += 1;
}
Ok(())
@ -286,7 +286,7 @@ impl V02State {
balance: 1500,
// Difficulty: 3
data: vec![3; 33].try_into().expect("should fit"),
nonce: 0,
nonce: Nonce(0),
},
);
}
@ -344,7 +344,7 @@ pub mod tests {
balance: u128,
) -> PublicTransaction {
let account_ids = vec![from, to];
let nonces = vec![nonce];
let nonces = vec![Nonce(nonce)];
let program_id = Program::authenticated_transfer_program().id();
let message =
public_transaction::Message::try_new(program_id, account_ids, nonces, balance).unwrap();
@ -458,8 +458,8 @@ pub mod tests {
assert_eq!(state.get_account_by_id(from).balance, 95);
assert_eq!(state.get_account_by_id(to).balance, 5);
assert_eq!(state.get_account_by_id(from).nonce, 1);
assert_eq!(state.get_account_by_id(to).nonce, 0);
assert_eq!(state.get_account_by_id(from).nonce.0, 1);
assert_eq!(state.get_account_by_id(to).nonce.0, 0);
}
#[test]
@ -480,8 +480,8 @@ pub mod tests {
assert!(matches!(result, Err(NssaError::ProgramExecutionFailed(_))));
assert_eq!(state.get_account_by_id(from).balance, 100);
assert_eq!(state.get_account_by_id(to).balance, 0);
assert_eq!(state.get_account_by_id(from).nonce, 0);
assert_eq!(state.get_account_by_id(to).nonce, 0);
assert_eq!(state.get_account_by_id(from).nonce.0, 0);
assert_eq!(state.get_account_by_id(to).nonce.0, 0);
}
#[test]
@ -503,8 +503,8 @@ pub mod tests {
assert_eq!(state.get_account_by_id(from).balance, 192);
assert_eq!(state.get_account_by_id(to).balance, 108);
assert_eq!(state.get_account_by_id(from).nonce, 1);
assert_eq!(state.get_account_by_id(to).nonce, 0);
assert_eq!(state.get_account_by_id(from).nonce.0, 1);
assert_eq!(state.get_account_by_id(to).nonce.0, 0);
}
#[test]
@ -527,9 +527,9 @@ pub mod tests {
assert_eq!(state.get_account_by_id(account_id1).balance, 95);
assert_eq!(state.get_account_by_id(account_id2).balance, 2);
assert_eq!(state.get_account_by_id(account_id3).balance, 3);
assert_eq!(state.get_account_by_id(account_id1).nonce, 1);
assert_eq!(state.get_account_by_id(account_id2).nonce, 1);
assert_eq!(state.get_account_by_id(account_id3).nonce, 0);
assert_eq!(state.get_account_by_id(account_id1).nonce.0, 1);
assert_eq!(state.get_account_by_id(account_id2).nonce.0, 1);
assert_eq!(state.get_account_by_id(account_id3).nonce.0, 0);
}
impl V02State {
@ -560,7 +560,7 @@ pub mod tests {
..Account::default()
};
let account_with_default_values_except_nonce = Account {
nonce: 37,
nonce: Nonce(37),
..Account::default()
};
let account_with_default_values_except_data = Account {
@ -915,7 +915,6 @@ pub mod tests {
vec![sender, recipient],
Program::serialize_instruction(balance_to_move).unwrap(),
vec![0, 2],
vec![0xdeadbeef],
vec![(recipient_keys.npk(), shared_secret)],
vec![],
vec![None],
@ -962,7 +961,6 @@ pub mod tests {
vec![sender_pre, recipient_pre],
Program::serialize_instruction(balance_to_move).unwrap(),
vec![1, 2],
new_nonces.to_vec(),
vec![
(sender_keys.npk(), shared_secret_1),
(recipient_keys.npk(), shared_secret_2),
@ -1015,7 +1013,6 @@ pub mod tests {
vec![sender_pre, recipient_pre],
Program::serialize_instruction(balance_to_move).unwrap(),
vec![1, 0],
vec![new_nonce],
vec![(sender_keys.npk(), shared_secret)],
vec![sender_keys.nsk],
vec![state.get_proof_for_commitment(&sender_commitment)],
@ -1056,7 +1053,7 @@ pub mod tests {
let expected_sender_post = {
let mut this = state.get_account_by_id(sender_keys.account_id());
this.balance -= balance_to_move;
this.nonce += 1;
this.nonce.0 += 1;
this
};
@ -1083,7 +1080,7 @@ pub mod tests {
let sender_private_account = Account {
program_owner: Program::authenticated_transfer_program().id(),
balance: 100,
nonce: 0xdeadbeef,
nonce: Nonce(0xdeadbeef),
data: Data::default(),
};
let recipient_keys = test_private_account_keys_2();
@ -1098,7 +1095,7 @@ pub mod tests {
&sender_private_account,
&recipient_keys,
balance_to_move,
[0xcafecafe, 0xfecafeca],
[Nonce(0xcafecafe), Nonce(0xfecafeca)],
&state,
);
@ -1106,7 +1103,7 @@ pub mod tests {
&sender_keys.npk(),
&Account {
program_owner: Program::authenticated_transfer_program().id(),
nonce: 0xcafecafe,
nonce: Nonce(0), //TODO update
balance: sender_private_account.balance - balance_to_move,
data: Data::default(),
},
@ -1120,7 +1117,7 @@ pub mod tests {
&recipient_keys.npk(),
&Account {
program_owner: Program::authenticated_transfer_program().id(),
nonce: 0xfecafeca,
nonce: Nonce(0),
balance: balance_to_move,
..Account::default()
},
@ -1149,7 +1146,7 @@ pub mod tests {
let sender_private_account = Account {
program_owner: Program::authenticated_transfer_program().id(),
balance: 100,
nonce: 0xdeadbeef,
nonce: Nonce(0xdeadbeef),
data: Data::default(),
};
let recipient_keys = test_public_account_keys_1();
@ -1173,7 +1170,7 @@ pub mod tests {
&sender_private_account,
&recipient_keys.account_id(),
balance_to_move,
0xcafecafe,
Nonce(0xcafecafe),
&state,
);
@ -1181,7 +1178,7 @@ pub mod tests {
&sender_keys.npk(),
&Account {
program_owner: Program::authenticated_transfer_program().id(),
nonce: 0xcafecafe,
nonce: Nonce(0xcafecafe),
balance: sender_private_account.balance - balance_to_move,
data: Data::default(),
},
@ -1230,7 +1227,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1257,7 +1253,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1284,7 +1279,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1311,7 +1305,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1340,7 +1333,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.to_owned().into(),
);
@ -1367,7 +1359,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1403,7 +1394,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1430,7 +1420,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1466,7 +1455,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1504,7 +1492,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1529,12 +1516,11 @@ pub mod tests {
AccountWithMetadata::new(Account::default(), false, &recipient_keys.npk());
// Setting only one nonce for an execution with two private accounts.
let private_account_nonces = [0xdeadbeef1];
let private_account_nonces = [Nonce(0xdeadbeef1)];
let result = execute_and_prove(
vec![private_account_1, private_account_2],
Program::serialize_instruction(10u128).unwrap(),
vec![1, 2],
private_account_nonces.to_vec(),
vec![
(
sender_keys.npk(),
@ -1578,7 +1564,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10u128).unwrap(),
vec![1, 2],
vec![0xdeadbeef1, 0xdeadbeef2],
private_account_keys.to_vec(),
vec![sender_keys.nsk],
vec![Some((0, vec![]))],
@ -1611,7 +1596,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10u128).unwrap(),
vec![1, 2],
vec![0xdeadbeef1, 0xdeadbeef2],
vec![
(
sender_keys.npk(),
@ -1653,7 +1637,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10u128).unwrap(),
vec![1, 2],
vec![0xdeadbeef1, 0xdeadbeef2],
vec![
(
sender_keys.npk(),
@ -1711,7 +1694,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10u128).unwrap(),
vec![1, 2],
vec![0xdeadbeef1, 0xdeadbeef2],
private_account_keys.to_vec(),
private_account_nsks.to_vec(),
private_account_membership_proofs.to_vec(),
@ -1749,7 +1731,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10u128).unwrap(),
vec![1, 2],
vec![0xdeadbeef1, 0xdeadbeef2],
vec![
(
sender_keys.npk(),
@ -1797,7 +1778,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10u128).unwrap(),
vec![1, 2],
vec![0xdeadbeef1, 0xdeadbeef2],
vec![
(
sender_keys.npk(),
@ -1844,7 +1824,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10u128).unwrap(),
vec![1, 2],
vec![0xdeadbeef1, 0xdeadbeef2],
vec![
(
sender_keys.npk(),
@ -1880,7 +1859,7 @@ pub mod tests {
let private_account_2 = AccountWithMetadata::new(
Account {
// Non default nonce
nonce: 0xdeadbeef,
nonce: Nonce(0xdeadbeef),
..Account::default()
},
false,
@ -1891,7 +1870,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10u128).unwrap(),
vec![1, 2],
vec![0xdeadbeef1, 0xdeadbeef2],
vec![
(
sender_keys.npk(),
@ -1936,7 +1914,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10u128).unwrap(),
vec![1, 2],
vec![0xdeadbeef1, 0xdeadbeef2],
vec![
(
sender_keys.npk(),
@ -1978,7 +1955,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -2004,12 +1980,11 @@ pub mod tests {
// Setting three new private account nonces for a circuit execution with only two private
// accounts.
let private_account_nonces = [0xdeadbeef1, 0xdeadbeef2, 0xdeadbeef3];
let private_account_nonces = [Nonce(0xdeadbeef1), Nonce(0xdeadbeef2), Nonce(0xdeadbeef3)];
let result = execute_and_prove(
vec![private_account_1, private_account_2],
Program::serialize_instruction(10u128).unwrap(),
vec![1, 2],
private_account_nonces.to_vec(),
vec![
(
sender_keys.npk(),
@ -2065,7 +2040,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10u128).unwrap(),
vec![1, 2],
vec![0xdeadbeef1, 0xdeadbeef2],
private_account_keys.to_vec(),
vec![sender_keys.nsk],
vec![Some((0, vec![]))],
@ -2101,7 +2075,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10u128).unwrap(),
visibility_mask.to_vec(),
vec![0xdeadbeef1, 0xdeadbeef2],
vec![
(
sender_keys.npk(),
@ -2126,7 +2099,7 @@ pub mod tests {
let sender_private_account = Account {
program_owner: Program::authenticated_transfer_program().id(),
balance: 100,
nonce: 0xdeadbeef,
nonce: Nonce(0xdeadbeef),
data: Data::default(),
};
let recipient_keys = test_private_account_keys_2();
@ -2141,7 +2114,7 @@ pub mod tests {
&sender_private_account,
&recipient_keys,
balance_to_move,
[0xcafecafe, 0xfecafeca],
[Nonce(0xcafecafe), Nonce(0xfecafeca)],
&state,
);
@ -2152,7 +2125,7 @@ pub mod tests {
let sender_private_account = Account {
program_owner: Program::authenticated_transfer_program().id(),
balance: 100 - balance_to_move,
nonce: 0xcafecafe,
nonce: Nonce(0xcafecafe),
data: Data::default(),
};
@ -2161,7 +2134,7 @@ pub mod tests {
&sender_private_account,
&recipient_keys,
balance_to_move,
[0x1234, 0x5678],
[Nonce(0x1234), Nonce(0x5678)],
&state,
);
@ -2197,7 +2170,6 @@ pub mod tests {
vec![private_account_1.clone(), private_account_1],
Program::serialize_instruction(100u128).unwrap(),
visibility_mask.to_vec(),
vec![0xdeadbeef1, 0xdeadbeef2],
vec![
(sender_keys.npk(), shared_secret),
(sender_keys.npk(), shared_secret),
@ -2234,7 +2206,7 @@ pub mod tests {
};
let message =
public_transaction::Message::try_new(program.id(), vec![from, to], vec![0], amount)
public_transaction::Message::try_new(program.id(), vec![from, to], vec![Nonce(0)], amount)
.unwrap();
let witness_set = public_transaction::WitnessSet::for_message(&message, &[&from_key]);
let tx = PublicTransaction::new(message, witness_set);
@ -2275,7 +2247,7 @@ pub mod tests {
program.id(),
vec![to, from], // The chain_caller program permutes the account order in the chain
// call
vec![0],
vec![Nonce(0)],
instruction,
)
.unwrap();
@ -2314,7 +2286,7 @@ pub mod tests {
program.id(),
vec![to, from], // The chain_caller program permutes the account order in the chain
// call
vec![0],
vec![Nonce(0)],
instruction,
)
.unwrap();
@ -2576,7 +2548,7 @@ pub mod tests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::user_token_a_holding_init(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2588,7 +2560,7 @@ pub mod tests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::user_token_b_holding_init(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2608,7 +2580,7 @@ pub mod tests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2621,7 +2593,7 @@ pub mod tests {
total_supply: BalanceForTests::token_a_supply(),
metadata_id: None,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2634,7 +2606,7 @@ pub mod tests {
total_supply: BalanceForTests::token_b_supply(),
metadata_id: None,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2647,7 +2619,7 @@ pub mod tests {
total_supply: BalanceForTests::token_lp_supply(),
metadata_id: None,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2659,7 +2631,7 @@ pub mod tests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::vault_a_balance_init(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2671,7 +2643,7 @@ pub mod tests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::vault_b_balance_init(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2683,7 +2655,7 @@ pub mod tests {
definition_id: IdForTests::token_lp_definition_id(),
balance: BalanceForTests::user_token_lp_holding_init(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2695,7 +2667,7 @@ pub mod tests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::vault_a_balance_swap_1(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2707,7 +2679,7 @@ pub mod tests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::vault_b_balance_swap_1(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2727,7 +2699,7 @@ pub mod tests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2739,7 +2711,7 @@ pub mod tests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::user_token_a_holding_swap_1(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2751,7 +2723,7 @@ pub mod tests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::user_token_b_holding_swap_1(),
}),
nonce: 1,
nonce: Nonce(1),
}
}
@ -2763,7 +2735,7 @@ pub mod tests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::vault_a_balance_swap_2(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2775,7 +2747,7 @@ pub mod tests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::vault_b_balance_swap_2(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2795,7 +2767,7 @@ pub mod tests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2807,7 +2779,7 @@ pub mod tests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::user_token_a_holding_swap_2(),
}),
nonce: 1,
nonce: Nonce(1),
}
}
@ -2819,7 +2791,7 @@ pub mod tests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::user_token_b_holding_swap_2(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2831,7 +2803,7 @@ pub mod tests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::vault_a_balance_add(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2843,7 +2815,7 @@ pub mod tests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::vault_b_balance_add(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2863,7 +2835,7 @@ pub mod tests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2875,7 +2847,7 @@ pub mod tests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::user_token_a_holding_add(),
}),
nonce: 1,
nonce: Nonce(1),
}
}
@ -2887,7 +2859,7 @@ pub mod tests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::user_token_b_holding_add(),
}),
nonce: 1,
nonce: Nonce(1),
}
}
@ -2899,7 +2871,7 @@ pub mod tests {
definition_id: IdForTests::token_lp_definition_id(),
balance: BalanceForTests::user_token_lp_holding_add(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2912,7 +2884,7 @@ pub mod tests {
total_supply: BalanceForTests::token_lp_supply_add(),
metadata_id: None,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2924,7 +2896,7 @@ pub mod tests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::vault_a_balance_remove(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2936,7 +2908,7 @@ pub mod tests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::vault_b_balance_remove(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2956,7 +2928,7 @@ pub mod tests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2968,7 +2940,7 @@ pub mod tests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::user_token_a_holding_remove(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2980,7 +2952,7 @@ pub mod tests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::user_token_b_holding_remove(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -2992,7 +2964,7 @@ pub mod tests {
definition_id: IdForTests::token_lp_definition_id(),
balance: BalanceForTests::user_token_lp_holding_remove(),
}),
nonce: 1,
nonce: Nonce(1),
}
}
@ -3005,7 +2977,7 @@ pub mod tests {
total_supply: BalanceForTests::token_lp_supply_remove(),
metadata_id: None,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -3018,7 +2990,7 @@ pub mod tests {
total_supply: 0,
metadata_id: None,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -3030,7 +3002,7 @@ pub mod tests {
definition_id: IdForTests::token_a_definition_id(),
balance: 0,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -3042,7 +3014,7 @@ pub mod tests {
definition_id: IdForTests::token_b_definition_id(),
balance: 0,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -3062,7 +3034,7 @@ pub mod tests {
fees: 0u128,
active: false,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -3074,7 +3046,7 @@ pub mod tests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::user_token_a_holding_new_definition(),
}),
nonce: 1,
nonce: Nonce(1),
}
}
@ -3086,7 +3058,7 @@ pub mod tests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::user_token_b_holding_new_definition(),
}),
nonce: 1,
nonce: Nonce(1),
}
}
@ -3098,7 +3070,7 @@ pub mod tests {
definition_id: IdForTests::token_lp_definition_id(),
balance: BalanceForTests::user_token_a_holding_new_definition(),
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -3111,7 +3083,7 @@ pub mod tests {
total_supply: BalanceForTests::vault_a_balance_init(),
metadata_id: None,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -3131,7 +3103,7 @@ pub mod tests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
}
}
@ -3143,7 +3115,7 @@ pub mod tests {
definition_id: IdForTests::token_lp_definition_id(),
balance: 0,
}),
nonce: 0,
nonce: Nonce(0),
}
}
}
@ -3230,7 +3202,7 @@ pub mod tests {
IdForTests::user_token_b_id(),
IdForTests::user_token_lp_id(),
],
vec![0],
vec![Nonce(0)],
instruction,
)
.unwrap();
@ -3307,7 +3279,7 @@ pub mod tests {
IdForTests::user_token_b_id(),
IdForTests::user_token_lp_id(),
],
vec![0, 0],
vec![Nonce(0), Nonce(0)],
instruction,
)
.unwrap();
@ -3391,7 +3363,7 @@ pub mod tests {
IdForTests::user_token_b_id(),
IdForTests::user_token_lp_id(),
],
vec![0, 0],
vec![Nonce(0), Nonce(0)],
instruction,
)
.unwrap();
@ -3463,7 +3435,7 @@ pub mod tests {
IdForTests::user_token_b_id(),
IdForTests::user_token_lp_id(),
],
vec![0, 0],
vec![Nonce(0), Nonce(0)],
instruction,
)
.unwrap();
@ -3526,7 +3498,7 @@ pub mod tests {
IdForTests::user_token_b_id(),
IdForTests::user_token_lp_id(),
],
vec![0, 0],
vec![Nonce(0), Nonce(0)],
instruction,
)
.unwrap();
@ -3586,7 +3558,7 @@ pub mod tests {
IdForTests::user_token_a_id(),
IdForTests::user_token_b_id(),
],
vec![0],
vec![Nonce(0)],
instruction,
)
.unwrap();
@ -3636,7 +3608,7 @@ pub mod tests {
IdForTests::user_token_a_id(),
IdForTests::user_token_b_id(),
],
vec![0],
vec![Nonce(0)],
instruction,
)
.unwrap();
@ -3751,7 +3723,7 @@ pub mod tests {
chain_caller.id(),
vec![to, from], // The chain_caller program permutes the account order in the chain
// call
vec![0],
vec![Nonce(0)],
instruction,
)
.unwrap();
@ -3821,8 +3793,8 @@ pub mod tests {
dependencies.insert(auth_transfers.id(), auth_transfers);
let program_with_deps = ProgramWithDependencies::new(chain_caller, dependencies);
let from_new_nonce = 0xdeadbeef1;
let to_new_nonce = 0xdeadbeef2;
let from_new_nonce = Nonce(0xdeadbeef1);
let to_new_nonce = Nonce(0xdeadbeef2);
let from_expected_post = Account {
balance: initial_balance - number_of_calls as u128 * amount,
@ -3843,7 +3815,6 @@ pub mod tests {
vec![to_account, from_account],
Program::serialize_instruction(instruction).unwrap(),
vec![1, 1],
vec![from_new_nonce, to_new_nonce],
vec![(from_keys.npk(), to_ss), (to_keys.npk(), from_ss)],
vec![from_keys.nsk, to_keys.nsk],
vec![
@ -4039,14 +4010,14 @@ pub mod tests {
let expected_sender_post = {
let mut this = state.get_account_by_id(sender_id);
this.balance = sender_init_balance;
this.nonce = 0;
this.nonce = Nonce(0);
this
};
let expected_recipient_post = {
let mut this = state.get_account_by_id(sender_id);
this.balance = recipient_init_balance;
this.nonce = 0;
this.nonce = Nonce(0);
this
};
@ -4075,14 +4046,13 @@ pub mod tests {
// Balance to initialize the account with (0 for a new account)
let balance: u128 = 0;
let nonce = 0xdeadbeef1;
let nonce = Nonce(0xdeadbeef1);
// Execute and prove the circuit with the authorized account but no commitment proof
let (output, proof) = execute_and_prove(
vec![authorized_account],
Program::serialize_instruction(balance).unwrap(),
vec![1],
vec![nonce],
vec![(private_keys.npk(), shared_secret)],
vec![private_keys.nsk],
vec![None],
@ -4128,14 +4098,13 @@ pub mod tests {
let epk = EphemeralPublicKey::from_scalar(esk);
let balance: u128 = 0;
let nonce = 0xdeadbeef1;
let nonce = Nonce(0xdeadbeef1);
// Step 2: Execute claimer program to claim the account with authentication
let (output, proof) = execute_and_prove(
vec![authorized_account.clone()],
Program::serialize_instruction(balance).unwrap(),
vec![1],
vec![nonce],
vec![(private_keys.npk(), shared_secret)],
vec![private_keys.nsk],
vec![None],
@ -4176,14 +4145,13 @@ pub mod tests {
let esk2 = [4; 32];
let shared_secret2 = SharedSecretKey::new(&esk2, &private_keys.ivk());
let nonce2 = 0xdeadbeef2;
let nonce2 = Nonce(0xdeadbeef2);
// Step 3: Try to execute noop program with authentication but without initialization
let res = execute_and_prove(
vec![account_metadata],
Program::serialize_instruction(()).unwrap(),
vec![1],
vec![nonce2],
vec![(private_keys.npk(), shared_secret2)],
vec![private_keys.nsk],
vec![None],
@ -4253,7 +4221,6 @@ pub mod tests {
vec![private_account],
Program::serialize_instruction(instruction).unwrap(),
vec![1],
vec![2],
vec![(
sender_keys.npk(),
SharedSecretKey::new(&[3; 32], &sender_keys.ivk()),
@ -4281,7 +4248,6 @@ pub mod tests {
vec![private_account],
Program::serialize_instruction(instruction).unwrap(),
vec![1],
vec![2],
vec![(
sender_keys.npk(),
SharedSecretKey::new(&[3; 32], &sender_keys.ivk()),
@ -4333,14 +4299,13 @@ pub mod tests {
dependencies.insert(auth_transfers.id(), auth_transfers);
let program_with_deps = ProgramWithDependencies::new(malicious_program, dependencies);
let recipient_new_nonce = 0xdeadbeef1;
let recipient_new_nonce = Nonce(0xdeadbeef1);
// Act - execute the malicious program - this should fail during proving
let result = execute_and_prove(
vec![sender_account, recipient_account],
Program::serialize_instruction(instruction).unwrap(),
vec![0, 1],
vec![recipient_new_nonce],
vec![(recipient_keys.npk(), recipient)],
vec![recipient_keys.nsk],
vec![state.get_proof_for_commitment(&recipient_commitment)],

View File

@ -20,7 +20,6 @@ fn main() {
let PrivacyPreservingCircuitInput {
program_outputs,
visibility_mask,
private_account_nonces,
private_account_keys,
private_account_nsks,
private_account_membership_proofs,
@ -32,7 +31,6 @@ fn main() {
let output = compute_circuit_output(
execution_state,
&visibility_mask,
&private_account_nonces,
&private_account_keys,
&private_account_nsks,
&private_account_membership_proofs,
@ -223,7 +221,6 @@ impl ExecutionState {
fn compute_circuit_output(
execution_state: ExecutionState,
visibility_mask: &[u8],
private_account_nonces: &[Nonce],
private_account_keys: &[(NullifierPublicKey, SharedSecretKey)],
private_account_nsks: &[NullifierSecretKey],
private_account_membership_proofs: &[Option<MembershipProof>],
@ -243,7 +240,6 @@ fn compute_circuit_output(
"Invalid visibility mask length"
);
let mut private_nonces_iter = private_account_nonces.iter();
let mut private_keys_iter = private_account_keys.iter();
let mut private_nsks_iter = private_account_nsks.iter();
let mut private_membership_proofs_iter = private_account_membership_proofs.iter();
@ -269,7 +265,7 @@ fn compute_circuit_output(
"AccountId mismatch"
);
let new_nullifier = if visibility_mask == 1 {
let (new_nullifier, new_nonce) = if visibility_mask == 1 {
// Private account with authentication
let Some(nsk) = private_nsks_iter.next() else {
@ -293,12 +289,17 @@ fn compute_circuit_output(
panic!("Missing membership proof");
};
compute_nullifier_and_set_digest(
let new_nullifier = compute_nullifier_and_set_digest(
membership_proof_opt.as_ref(),
&pre_state.account,
npk,
nsk,
)
);
let new_nonce = pre_state.account.nonce.private_account_nonce_increment(&nsk);
(new_nullifier, new_nonce)
} else {
// Private account without authentication
@ -323,16 +324,17 @@ fn compute_circuit_output(
);
let nullifier = Nullifier::for_account_initialization(npk);
(nullifier, DUMMY_COMMITMENT_HASH)
let new_nonce = Nonce::default().private_account_nonce_init(npk);
((nullifier, DUMMY_COMMITMENT_HASH), new_nonce)
};
output.new_nullifiers.push(new_nullifier);
// Update post-state with new nonce
let mut post_with_updated_nonce = post_state;
let Some(new_nonce) = private_nonces_iter.next() else {
panic!("Missing private account nonce");
};
post_with_updated_nonce.nonce = *new_nonce;
post_with_updated_nonce.nonce = new_nonce; //*new_nonce;
// Compute commitment
let commitment_post = Commitment::new(npk, &post_with_updated_nonce);
@ -353,7 +355,8 @@ fn compute_circuit_output(
}
}
assert!(private_nonces_iter.next().is_none(), "Too many nonces");
//TODO delete
//assert!(private_nonces_iter.next().is_none(), "Too many nonces");
assert!(
private_keys_iter.next().is_none(),

View File

@ -7,7 +7,7 @@ use amm_core::{
compute_pool_pda, compute_vault_pda, compute_vault_pda_seed,
};
use nssa_core::{
account::{Account, AccountId, AccountWithMetadata, Data},
account::{Account, AccountId, AccountWithMetadata, Data, Nonce},
program::{ChainedCall, ProgramId},
};
use token_core::{TokenDefinition, TokenHolding};
@ -410,7 +410,7 @@ impl AccountForTests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::user_token_a_balance(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::user_token_a_id(),
@ -426,7 +426,7 @@ impl AccountForTests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::user_token_b_balance(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::user_token_b_id(),
@ -442,7 +442,7 @@ impl AccountForTests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::vault_a_reserve_init(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::vault_a_id(),
@ -458,7 +458,7 @@ impl AccountForTests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::vault_b_reserve_init(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::vault_b_id(),
@ -474,7 +474,7 @@ impl AccountForTests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::vault_a_reserve_high(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::vault_a_id(),
@ -490,7 +490,7 @@ impl AccountForTests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::vault_b_reserve_high(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::vault_b_id(),
@ -506,7 +506,7 @@ impl AccountForTests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::vault_a_reserve_low(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::vault_a_id(),
@ -522,7 +522,7 @@ impl AccountForTests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::vault_b_reserve_low(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::vault_b_id(),
@ -538,7 +538,7 @@ impl AccountForTests {
definition_id: IdForTests::token_a_definition_id(),
balance: 0,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::vault_a_id(),
@ -554,7 +554,7 @@ impl AccountForTests {
definition_id: IdForTests::token_b_definition_id(),
balance: 0,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::vault_b_id(),
@ -571,7 +571,7 @@ impl AccountForTests {
total_supply: BalanceForTests::vault_a_reserve_init(),
metadata_id: None,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::token_lp_definition_id(),
@ -588,7 +588,7 @@ impl AccountForTests {
total_supply: BalanceForTests::vault_a_reserve_init(),
metadata_id: None,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::vault_a_id(),
@ -604,7 +604,7 @@ impl AccountForTests {
definition_id: IdForTests::token_lp_definition_id(),
balance: 0,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::user_token_lp_id(),
@ -620,7 +620,7 @@ impl AccountForTests {
definition_id: IdForTests::token_lp_definition_id(),
balance: BalanceForTests::user_token_lp_balance(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::user_token_lp_id(),
@ -644,7 +644,7 @@ impl AccountForTests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -668,7 +668,7 @@ impl AccountForTests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -692,7 +692,7 @@ impl AccountForTests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -716,7 +716,7 @@ impl AccountForTests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -740,7 +740,7 @@ impl AccountForTests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -764,7 +764,7 @@ impl AccountForTests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -788,7 +788,7 @@ impl AccountForTests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -812,7 +812,7 @@ impl AccountForTests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -836,7 +836,7 @@ impl AccountForTests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -860,7 +860,7 @@ impl AccountForTests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -884,7 +884,7 @@ impl AccountForTests {
fees: 0u128,
active: false,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -908,7 +908,7 @@ impl AccountForTests {
fees: 0u128,
active: false,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: AccountId::new([4; 32]),
@ -924,7 +924,7 @@ impl AccountForTests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::vault_a_reserve_init(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: AccountId::new([4; 32]),
@ -940,7 +940,7 @@ impl AccountForTests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::vault_b_reserve_init(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: AccountId::new([4; 32]),
@ -964,7 +964,7 @@ impl AccountForTests {
fees: 0u128,
active: true,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),

View File

@ -1,6 +1,6 @@
#![cfg(test)]
use nssa_core::account::{Account, AccountId, AccountWithMetadata, Data};
use nssa_core::account::{Account, AccountId, AccountWithMetadata, Data, Nonce};
use token_core::{
MetadataStandard, NewTokenDefinition, NewTokenMetadata, TokenDefinition, TokenHolding,
};
@ -32,7 +32,7 @@ impl AccountForTests {
total_supply: BalanceForTests::init_supply(),
metadata_id: None,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -49,7 +49,7 @@ impl AccountForTests {
total_supply: BalanceForTests::init_supply(),
metadata_id: None,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: false,
account_id: IdForTests::pool_definition_id(),
@ -65,7 +65,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id_diff(),
balance: BalanceForTests::holding_balance(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -81,7 +81,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::holding_balance(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -97,7 +97,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::holding_balance(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: false,
account_id: IdForTests::holding_id(),
@ -113,7 +113,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::init_supply(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: false,
account_id: IdForTests::holding_id(),
@ -130,7 +130,7 @@ impl AccountForTests {
total_supply: BalanceForTests::init_supply_burned(),
metadata_id: None,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -146,7 +146,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::holding_balance_burned(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: false,
account_id: IdForTests::holding_id(),
@ -170,7 +170,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::mint_success(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: false,
account_id: IdForTests::holding_id(),
@ -186,7 +186,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::holding_balance_mint(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -203,7 +203,7 @@ impl AccountForTests {
total_supply: BalanceForTests::init_supply_mint(),
metadata_id: None,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -219,7 +219,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::mint_overflow(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -236,7 +236,7 @@ impl AccountForTests {
printable_supply: BalanceForTests::printable_copies(),
metadata_id: AccountId::new([0; 32]),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -260,7 +260,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::init_supply(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -277,7 +277,7 @@ impl AccountForTests {
total_supply: BalanceForTests::init_supply(),
metadata_id: None,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -293,7 +293,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::init_supply(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -309,7 +309,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::init_supply(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::holding_id_2(),
@ -325,7 +325,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::recipient_post_transfer(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::holding_id_2(),
@ -341,7 +341,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::sender_post_transfer(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -357,7 +357,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
print_balance: BalanceForTests::printable_copies(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -373,7 +373,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
print_balance: 1,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -389,7 +389,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
print_balance: BalanceForTests::printable_copies() - 1,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -405,7 +405,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
owned: true,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: false,
account_id: IdForTests::holding_id(),
@ -421,7 +421,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
print_balance: BalanceForTests::printable_copies(),
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::holding_id_2(),
@ -437,7 +437,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
print_balance: 0,
}),
nonce: 0,
nonce: Nonce(0),
},
is_authorized: true,
account_id: IdForTests::holding_id(),

View File

@ -221,7 +221,7 @@ impl<BC: BlockSettlementClientTrait, IC: IndexerClientTrait> JsonHandler<BC, IC>
account_ids
.into_iter()
.map(|account_id| state.state().get_account_by_id(account_id).nonce)
.map(|account_id| state.state().get_account_by_id(account_id).nonce.0)
.collect()
};

View File

@ -12,7 +12,7 @@ fn main() {
let account_pre = &pre.account;
let mut account_post = account_pre.clone();
account_post.nonce += 1;
account_post.nonce.0 +=1;
write_nssa_outputs(
instruction_words,

View File

@ -218,7 +218,7 @@ impl From<nssa::Account> for FfiAccount {
balance: value.balance.into(),
data,
data_len,
nonce: value.nonce.into(),
nonce: value.nonce.0.into(),
}
}
}
@ -239,7 +239,7 @@ impl TryFrom<&FfiAccount> for nssa::Account {
program_owner: value.program_owner.data,
balance: value.balance.into(),
data,
nonce: value.nonce.into(),
nonce: nssa_core::account::Nonce(value.nonce.into()),
})
}
}

View File

@ -115,12 +115,6 @@ pub fn produce_data_for_storage(
}
}
pub(crate) fn produce_random_nonces(size: usize) -> Vec<Nonce> {
let mut result = vec![[0; 16]; size];
result.iter_mut().for_each(|bytes| OsRng.fill_bytes(bytes));
result.into_iter().map(Nonce::from_le_bytes).collect()
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AccountPrivacyKind {
Public,
@ -162,7 +156,7 @@ impl From<Account> for HumanReadableAccount {
balance: account.balance,
program_owner_b64,
data_b64,
nonce: account.nonce,
nonce: account.nonce.0,
}
}
}

View File

@ -22,7 +22,7 @@ use tokio::io::AsyncWriteExt;
use crate::{
config::{PersistentStorage, WalletConfigOverrides},
helperfunctions::{produce_data_for_storage, produce_random_nonces},
helperfunctions::{produce_data_for_storage},
poller::TxPoller,
};
@ -326,7 +326,6 @@ impl WalletCore {
pre_states,
instruction_data,
acc_manager.visibility_mask().to_vec(),
produce_random_nonces(private_account_keys.len()),
private_account_keys
.iter()
.map(|keys| (keys.npk.clone(), keys.ssk))

View File

@ -80,7 +80,7 @@ impl Amm<'_> {
let message = nssa::public_transaction::Message::try_new(
program.id(),
account_ids,
nonces,
nonces.iter().map(|x|nssa_core::account::Nonce(*x)).collect(),
instruction,
)
.unwrap();
@ -187,7 +187,7 @@ impl Amm<'_> {
let message = nssa::public_transaction::Message::try_new(
program.id(),
account_ids,
nonces,
nonces.iter().map(|x|nssa_core::account::Nonce(*x)).collect(),
instruction,
)
.unwrap();
@ -274,7 +274,7 @@ impl Amm<'_> {
let message = nssa::public_transaction::Message::try_new(
program.id(),
account_ids,
nonces,
nonces.iter().map(|x|nssa_core::account::Nonce(*x)).collect(),
instruction,
)
.unwrap();
@ -356,7 +356,7 @@ impl Amm<'_> {
let message = nssa::public_transaction::Message::try_new(
program.id(),
account_ids,
nonces,
nonces.iter().map(|x|nssa_core::account::Nonce(*x)).collect(),
instruction,
)
.unwrap();

View File

@ -26,7 +26,8 @@ impl NativeTokenTransfer<'_> {
let account_ids = vec![from, to];
let program_id = Program::authenticated_transfer_program().id();
let message =
Message::try_new(program_id, account_ids, nonces, balance_to_move).unwrap();
Message::try_new(program_id, account_ids,
nonces.iter().map(|x|nssa_core::account::Nonce(*x)).collect(), balance_to_move).unwrap();
let signing_key = self.0.storage.user_data.get_pub_account_signing_key(from);
@ -55,7 +56,7 @@ impl NativeTokenTransfer<'_> {
let instruction: u128 = 0;
let account_ids = vec![from];
let program_id = Program::authenticated_transfer_program().id();
let message = Message::try_new(program_id, account_ids, nonces, instruction).unwrap();
let message = Message::try_new(program_id, account_ids, nonces.iter().map(|x|nssa_core::account::Nonce(*x)).collect(), instruction).unwrap();
let signing_key = self.0.storage.user_data.get_pub_account_signing_key(from);

View File

@ -139,7 +139,7 @@ impl Token<'_> {
let message = nssa::public_transaction::Message::try_new(
program_id,
account_ids,
nonces,
nonces.iter().map(|x|nssa_core::account::Nonce(*x)).collect(),
instruction,
)
.unwrap();
@ -338,7 +338,7 @@ impl Token<'_> {
let message = nssa::public_transaction::Message::try_new(
Program::token().id(),
account_ids,
nonces,
nonces.iter().map(|x|nssa_core::account::Nonce(*x)).collect(),
instruction,
)
.expect("Instruction should serialize");
@ -470,7 +470,7 @@ impl Token<'_> {
let message = nssa::public_transaction::Message::try_new(
Program::token().id(),
account_ids,
nonces,
nonces.iter().map(|x|nssa_core::account::Nonce(*x)).collect(),
instruction,
)
.unwrap();