diff --git a/artifacts/program_methods/amm.bin b/artifacts/program_methods/amm.bin
index 72bab162..e9e758c2 100644
Binary files a/artifacts/program_methods/amm.bin and b/artifacts/program_methods/amm.bin differ
diff --git a/artifacts/program_methods/authenticated_transfer.bin b/artifacts/program_methods/authenticated_transfer.bin
index 5fd291d7..dd111e37 100644
Binary files a/artifacts/program_methods/authenticated_transfer.bin and b/artifacts/program_methods/authenticated_transfer.bin differ
diff --git a/artifacts/program_methods/pinata.bin b/artifacts/program_methods/pinata.bin
index 7d98f6bb..c7aeee91 100644
Binary files a/artifacts/program_methods/pinata.bin and b/artifacts/program_methods/pinata.bin differ
diff --git a/artifacts/program_methods/pinata_token.bin b/artifacts/program_methods/pinata_token.bin
index 51692ae1..7f0e95b8 100644
Binary files a/artifacts/program_methods/pinata_token.bin and b/artifacts/program_methods/pinata_token.bin differ
diff --git a/artifacts/program_methods/privacy_preserving_circuit.bin b/artifacts/program_methods/privacy_preserving_circuit.bin
index 28bbaba4..05311bb8 100644
Binary files a/artifacts/program_methods/privacy_preserving_circuit.bin and b/artifacts/program_methods/privacy_preserving_circuit.bin differ
diff --git a/artifacts/program_methods/token.bin b/artifacts/program_methods/token.bin
index b26e52cd..caf216f8 100644
Binary files a/artifacts/program_methods/token.bin and b/artifacts/program_methods/token.bin differ
diff --git a/artifacts/test_program_methods/burner.bin b/artifacts/test_program_methods/burner.bin
index e2c3bdf1..1e375475 100644
Binary files a/artifacts/test_program_methods/burner.bin and b/artifacts/test_program_methods/burner.bin differ
diff --git a/artifacts/test_program_methods/chain_caller.bin b/artifacts/test_program_methods/chain_caller.bin
index f02b0621..3b7c0b39 100644
Binary files a/artifacts/test_program_methods/chain_caller.bin and b/artifacts/test_program_methods/chain_caller.bin differ
diff --git a/artifacts/test_program_methods/changer_claimer.bin b/artifacts/test_program_methods/changer_claimer.bin
index 6c929b34..1a5d6684 100644
Binary files a/artifacts/test_program_methods/changer_claimer.bin and b/artifacts/test_program_methods/changer_claimer.bin differ
diff --git a/artifacts/test_program_methods/claimer.bin b/artifacts/test_program_methods/claimer.bin
index c7885bba..b4860f56 100644
Binary files a/artifacts/test_program_methods/claimer.bin and b/artifacts/test_program_methods/claimer.bin differ
diff --git a/artifacts/test_program_methods/data_changer.bin b/artifacts/test_program_methods/data_changer.bin
index a45a027f..ac40692f 100644
Binary files a/artifacts/test_program_methods/data_changer.bin and b/artifacts/test_program_methods/data_changer.bin differ
diff --git a/artifacts/test_program_methods/extra_output.bin b/artifacts/test_program_methods/extra_output.bin
index c149d572..a9464cda 100644
Binary files a/artifacts/test_program_methods/extra_output.bin and b/artifacts/test_program_methods/extra_output.bin differ
diff --git a/artifacts/test_program_methods/malicious_authorization_changer.bin b/artifacts/test_program_methods/malicious_authorization_changer.bin
index 2aa1b518..cb1f1023 100644
Binary files a/artifacts/test_program_methods/malicious_authorization_changer.bin and b/artifacts/test_program_methods/malicious_authorization_changer.bin differ
diff --git a/artifacts/test_program_methods/minter.bin b/artifacts/test_program_methods/minter.bin
index 9b454fc2..cbc9f392 100644
Binary files a/artifacts/test_program_methods/minter.bin and b/artifacts/test_program_methods/minter.bin differ
diff --git a/artifacts/test_program_methods/missing_output.bin b/artifacts/test_program_methods/missing_output.bin
index eb41b0af..b1cf1d2b 100644
Binary files a/artifacts/test_program_methods/missing_output.bin and b/artifacts/test_program_methods/missing_output.bin differ
diff --git a/artifacts/test_program_methods/modified_transfer.bin b/artifacts/test_program_methods/modified_transfer.bin
index c424767b..b4a5d79d 100644
Binary files a/artifacts/test_program_methods/modified_transfer.bin and b/artifacts/test_program_methods/modified_transfer.bin differ
diff --git a/artifacts/test_program_methods/nonce_changer.bin b/artifacts/test_program_methods/nonce_changer.bin
index e1f1284e..e2244310 100644
Binary files a/artifacts/test_program_methods/nonce_changer.bin and b/artifacts/test_program_methods/nonce_changer.bin differ
diff --git a/artifacts/test_program_methods/noop.bin b/artifacts/test_program_methods/noop.bin
index 60ab5423..3d8a2b7d 100644
Binary files a/artifacts/test_program_methods/noop.bin and b/artifacts/test_program_methods/noop.bin differ
diff --git a/artifacts/test_program_methods/program_owner_changer.bin b/artifacts/test_program_methods/program_owner_changer.bin
index 06e83e8a..80b98160 100644
Binary files a/artifacts/test_program_methods/program_owner_changer.bin and b/artifacts/test_program_methods/program_owner_changer.bin differ
diff --git a/artifacts/test_program_methods/simple_balance_transfer.bin b/artifacts/test_program_methods/simple_balance_transfer.bin
index 8c6dbde7..071e0bd3 100644
Binary files a/artifacts/test_program_methods/simple_balance_transfer.bin and b/artifacts/test_program_methods/simple_balance_transfer.bin differ
diff --git a/common/src/test_utils.rs b/common/src/test_utils.rs
index 09651c18..432bdc40 100644
--- a/common/src/test_utils.rs
+++ b/common/src/test_utils.rs
@@ -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,
diff --git a/examples/program_deployment/src/bin/run_hello_world_with_authorization.rs b/examples/program_deployment/src/bin/run_hello_world_with_authorization.rs
index 5e7df2d2..f38443ac 100644
--- a/examples/program_deployment/src/bin/run_hello_world_with_authorization.rs
+++ b/examples/program_deployment/src/bin/run_hello_world_with_authorization.rs
@@ -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,13 @@ 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);
diff --git a/explorer_service/src/components/account_preview.rs b/explorer_service/src/components/account_preview.rs
index bbe59c0f..c40391a8 100644
--- a/explorer_service/src/components/account_preview.rs
+++ b/explorer_service/src/components/account_preview.rs
@@ -31,7 +31,7 @@ pub fn AccountPreview(account_id: AccountId, account: Account) -> impl IntoView
"Nonce: "
- {nonce.to_string()}
+ {nonce.0.to_string()}
"Data: "
diff --git a/explorer_service/src/pages/account_page.rs b/explorer_service/src/pages/account_page.rs
index 4c0af1ac..69afd006 100644
--- a/explorer_service/src/pages/account_page.rs
+++ b/explorer_service/src/pages/account_page.rs
@@ -94,7 +94,7 @@ pub fn AccountPage() -> impl IntoView {
let account_id_str = acc_id.to_string();
let program_id = program_owner.to_string();
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! {
diff --git a/explorer_service/src/pages/transaction_page.rs b/explorer_service/src/pages/transaction_page.rs
index d0f1b4da..ad9bb45d 100644
--- a/explorer_service/src/pages/transaction_page.rs
+++ b/explorer_service/src/pages/transaction_page.rs
@@ -124,7 +124,7 @@ pub fn TransactionPage() -> impl IntoView {
{account_id_str}
- " (nonce: " {nonce.to_string()} ")"
+ " (nonce: " {nonce.0.to_string()} ")"
}
@@ -198,7 +198,7 @@ pub fn TransactionPage() -> impl IntoView {
{account_id_str}
- " (nonce: " {nonce.to_string()} ")"
+ " (nonce: " {nonce.0.to_string()} ")"
}
diff --git a/indexer/service/protocol/src/convert.rs b/indexer/service/protocol/src/convert.rs
index 1de28aa3..130468ff 100644
--- a/indexer/service/protocol/src/convert.rs
+++ b/indexer/service/protocol/src/convert.rs
@@ -46,7 +46,7 @@ impl From for Account {
program_owner: program_owner.into(),
balance,
data: data.into(),
- nonce,
+ nonce: Nonce(nonce.0),
}
}
}
@@ -66,7 +66,7 @@ impl TryFrom for nssa_core::account::Account {
program_owner: program_owner.into(),
balance,
data: data.try_into()?,
- nonce,
+ nonce: nssa_core::account::Nonce(nonce.0),
})
}
}
@@ -244,7 +244,7 @@ impl From for PublicMessage {
Self {
program_id: program_id.into(),
account_ids: account_ids.into_iter().map(Into::into).collect(),
- nonces,
+ nonces: nonces.iter().map(|x| Nonce(x.0)).collect(),
instruction_data,
}
}
@@ -261,7 +261,10 @@ impl From for nssa::public_transaction::Message {
Self::new_preserialized(
program_id.into(),
account_ids.into_iter().map(Into::into).collect(),
- nonces,
+ nonces
+ .iter()
+ .map(|x| nssa_core::account::Nonce(x.0))
+ .collect(),
instruction_data,
)
}
@@ -279,7 +282,7 @@ impl From 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()
@@ -308,7 +311,10 @@ impl TryFrom 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)
diff --git a/indexer/service/protocol/src/lib.rs b/indexer/service/protocol/src/lib.rs
index 8fdd3289..47acabc1 100644
--- a/indexer/service/protocol/src/lib.rs
+++ b/indexer/service/protocol/src/lib.rs
@@ -14,7 +14,8 @@ use serde_with::{DeserializeFromStr, SerializeDisplay};
#[cfg(feature = "convert")]
mod convert;
-pub type Nonce = u128;
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
+pub struct Nonce(pub u128);
#[derive(
Debug, Copy, Clone, PartialEq, Eq, Hash, SerializeDisplay, DeserializeFromStr, JsonSchema,
diff --git a/integration_tests/src/config.rs b/integration_tests/src/config.rs
index 9d69fe22..f23c9825 100644
--- a/integration_tests/src/config.rs
+++ b/integration_tests/src/config.rs
@@ -4,7 +4,10 @@ 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 +159,7 @@ impl InitialData {
balance: 10_000,
data: Data::default(),
program_owner: DEFAULT_PROGRAM_ID,
- nonce: 0,
+ nonce: Nonce(0),
},
),
(
@@ -165,7 +168,7 @@ impl InitialData {
balance: 20_000,
data: Data::default(),
program_owner: DEFAULT_PROGRAM_ID,
- nonce: 0,
+ nonce: Nonce(0),
},
),
],
diff --git a/integration_tests/tests/account.rs b/integration_tests/tests/account.rs
index ec53da78..f0a2f9a8 100644
--- a/integration_tests/tests/account.rs
+++ b/integration_tests/tests/account.rs
@@ -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");
diff --git a/integration_tests/tests/auth_transfer/public.rs b/integration_tests/tests/auth_transfer/public.rs
index da30fe5a..354f4723 100644
--- a/integration_tests/tests/auth_transfer/public.rs
+++ b/integration_tests/tests/auth_transfer/public.rs
@@ -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");
diff --git a/integration_tests/tests/program_deployment.rs b/integration_tests/tests/program_deployment.rs
index 098083d2..6a40e56c 100644
--- a/integration_tests/tests/program_deployment.rs
+++ b/integration_tests/tests/program_deployment.rs
@@ -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");
diff --git a/integration_tests/tests/tps.rs b/integration_tests/tests/tps.rs
index 2c58721e..1c85dc2d 100644
--- a/integration_tests/tests/tps.rs
+++ b/integration_tests/tests/tps.rs
@@ -15,7 +15,7 @@ use nssa::{
};
use nssa_core::{
MembershipProof, NullifierPublicKey,
- account::{AccountWithMetadata, data::Data},
+ account::{AccountWithMetadata, Nonce, data::Data},
encryption::ViewingPublicKey,
};
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),
diff --git a/integration_tests/tests/wallet_ffi.rs b/integration_tests/tests/wallet_ffi.rs
index e57e6b13..fbf12a87 100644
--- a/integration_tests/tests/wallet_ffi.rs
+++ b/integration_tests/tests/wallet_ffi.rs
@@ -10,7 +10,7 @@ use anyhow::Result;
use integration_tests::{BlockingTestContext, TIME_TO_WAIT_FOR_BLOCK_SECONDS};
use log::info;
use nssa::{Account, AccountId, PrivateKey, PublicKey, program::Program};
-use nssa_core::program::DEFAULT_PROGRAM_ID;
+use nssa_core::{account::Nonce, program::DEFAULT_PROGRAM_ID};
use tempfile::tempdir;
use wallet::WalletCore;
use wallet_ffi::{
@@ -487,7 +487,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);
@@ -523,7 +523,7 @@ fn test_wallet_ffi_get_account_private() -> Result<()> {
);
assert_eq!(account.balance, 10000);
assert!(account.data.is_empty());
- assert_eq!(account.nonce, 0);
+ assert_eq!(account.nonce, Nonce(0));
unsafe {
wallet_ffi_free_account_data((&mut out_account) as *mut FfiAccount);
diff --git a/nssa/core/src/account.rs b/nssa/core/src/account.rs
index 9bcdcd4b..e50de749 100644
--- a/nssa/core/src/account.rs
+++ b/nssa/core/src/account.rs
@@ -3,14 +3,52 @@ use std::{fmt::Display, str::FromStr};
use base58::{FromBase58, ToBase58};
use borsh::{BorshDeserialize, BorshSerialize};
pub use data::Data;
+use risc0_zkvm::sha::{Impl, 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: [u8; 64] = [0u8; 64];
+ bytes[..32].copy_from_slice(&npk.0);
+ let result: [u8; 32] = Impl::hash_bytes(&bytes).as_bytes().try_into().unwrap();
+ let result = result.first_chunk::<16>().unwrap();
+
+ Nonce(u128::from_le_bytes(*result))
+ }
+
+ pub fn private_account_nonce_increment(self, nsk: &NullifierSecretKey) -> Nonce {
+ let mut bytes: [u8; 64] = [0u8; 64];
+ bytes[..32].copy_from_slice(nsk);
+ bytes[32..48].copy_from_slice(&self.0.to_le_bytes());
+ let result: [u8; 32] = Impl::hash_bytes(&bytes).as_bytes().try_into().unwrap();
+ let result = result.first_chunk::<16>().unwrap();
+
+ Nonce(u128::from_le_bytes(*result))
+ }
+}
/// Account to be used both in public and private contexts
#[derive(
@@ -123,7 +161,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 +188,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);
@@ -197,4 +235,21 @@ mod tests {
let expected_account_id = AccountId::new([0; 32]);
assert!(default_account_id == expected_account_id);
}
+
+ #[test]
+ fn initialize_private_nonce() {
+ let npk = NullifierPublicKey([42; 32]);
+ let nonce = Nonce::default().private_account_nonce_init(&npk);
+ let expected_nonce = Nonce(37937661125547691021612781941709513486);
+ assert_eq!(nonce, expected_nonce);
+ }
+
+ #[test]
+ fn increment_private_nonce() {
+ let nsk: NullifierSecretKey = [42u8; 32];
+ let nonce =
+ Nonce(37937661125547691021612781941709513486).private_account_nonce_increment(&nsk);
+ let expected_nonce = Nonce(327300903218789900388409116014290259894);
+ assert_eq!(nonce, expected_nonce);
+ }
}
diff --git a/nssa/core/src/circuit_io.rs b/nssa/core/src/circuit_io.rs
index dedcf780..8893cd2d 100644
--- a/nssa/core/src/circuit_io.rs
+++ b/nssa/core/src/circuit_io.rs
@@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
use crate::{
Commitment, CommitmentSetDigest, MembershipProof, Nullifier, NullifierPublicKey,
NullifierSecretKey, SharedSecretKey,
- account::{Account, AccountWithMetadata, Nonce},
+ account::{Account, AccountWithMetadata},
encryption::Ciphertext,
program::{ProgramId, ProgramOutput},
};
@@ -18,8 +18,6 @@ pub struct PrivacyPreservingCircuitInput {
/// - `1` - private account with authentication
/// - `2` - private account without authentication
pub visibility_mask: Vec,
- /// Nonces of private accounts.
- pub private_account_nonces: Vec,
/// Public keys of private accounts.
pub private_account_keys: Vec<(NullifierPublicKey, SharedSecretKey)>,
/// Nullifier secret keys for authorized private accounts.
@@ -55,7 +53,7 @@ mod tests {
use super::*;
use crate::{
Commitment, Nullifier, NullifierPublicKey,
- account::{Account, AccountId, AccountWithMetadata},
+ account::{Account, AccountId, AccountWithMetadata, Nonce},
};
#[test]
@@ -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(
diff --git a/nssa/core/src/commitment.rs b/nssa/core/src/commitment.rs
index b08e3005..9a5bce2d 100644
--- a/nssa/core/src/commitment.rs
+++ b/nssa/core/src/commitment.rs
@@ -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()
diff --git a/nssa/core/src/encoding.rs b/nssa/core/src/encoding.rs
index 34be3782..cb80a9a9 100644
--- a/nssa/core/src/encoding.rs
+++ b/nssa/core/src/encoding.rs
@@ -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 {
- 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)?;
@@ -161,13 +161,14 @@ impl AccountId {
#[cfg(test)]
mod tests {
use super::*;
+ use crate::account::Nonce;
#[test]
fn test_enconding() {
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 +226,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();
diff --git a/nssa/core/src/program.rs b/nssa/core/src/program.rs
index a6a04425..5b907d6e 100644
--- a/nssa/core/src/program.rs
+++ b/nssa/core/src/program.rs
@@ -328,6 +328,7 @@ impl WrappedBalanceSum {
#[cfg(test)]
mod tests {
use super::*;
+ use crate::account::Nonce;
#[test]
fn test_post_state_new_with_claim_constructor() {
@@ -335,7 +336,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 +351,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 +366,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());
diff --git a/nssa/src/privacy_preserving_transaction/circuit.rs b/nssa/src/privacy_preserving_transaction/circuit.rs
index 9a28badd..5cd9c1bf 100644
--- a/nssa/src/privacy_preserving_transaction/circuit.rs
+++ b/nssa/src/privacy_preserving_transaction/circuit.rs
@@ -59,7 +59,6 @@ pub fn execute_and_prove(
pre_states: Vec,
instruction_data: InstructionData,
visibility_mask: Vec,
- private_account_nonces: Vec,
private_account_keys: Vec<(NullifierPublicKey, SharedSecretKey)>,
private_account_nsks: Vec,
private_account_membership_proofs: Vec