Merge branch 'main' into Pravdyvy/hardcoded-initial-state

This commit is contained in:
Pravdyvy 2026-03-19 19:02:19 +02:00
commit dc3650edd7
67 changed files with 1197 additions and 731 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -68,7 +68,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.into()];
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,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);

View File

@ -11,50 +11,50 @@
"channel_id": "0101010101010101010101010101010101010101010101010101010101010101",
"initial_accounts": [
{
"account_id": "6iArKUXxhUJqS7kCaPNhwMWt3ro71PDyBj7jwAyE2VQV",
"account_id": "CbgR6tj5kWx5oziiFptM7jMvrQeYY3Mzaao6ciuhSr2r",
"balance": 10000
},
{
"account_id": "7wHg9sbJwc6h3NP1S9bekfAzB8CHifEcxKswCKUt3YQo",
"account_id": "2RHZhw9h534Zr3eq2RGhQete2Hh667foECzXPmSkGni2",
"balance": 20000
}
],
"initial_commitments": [
{
"npk":[
177,
64,
1,
"npk": [
139,
19,
158,
11,
87,
38,
254,
159,
155,
231,
165,
1,
94,
64,
137,
243,
76,
249,
101,
251,
129,
33,
101,
189,
30,
42,
11,
191,
34,
103,
186,
227,
230
] ,
85,
206,
132,
228,
220,
114,
145,
89,
113,
156,
238,
142,
242,
74,
182,
91,
43,
100,
6,
190,
31,
15,
31,
88,
96,
204
],
"account": {
"program_owner": [
0,
@ -73,38 +73,38 @@
},
{
"npk": [
32,
67,
72,
164,
106,
53,
66,
239,
141,
15,
52,
230,
136,
177,
2,
236,
207,
243,
173,
134,
135,
210,
143,
87,
232,
33,
223,
54,
226,
10,
71,
215,
128,
194,
120,
113,
224,
4,
165
254,
143,
172,
24,
244,
243,
208,
65,
112,
118,
70,
217,
240,
69,
100,
129,
3,
121,
25,
213,
132,
42,
45
],
"account": {
"program_owner": [
@ -157,4 +157,4 @@
37,
37
]
}
}

View File

@ -1,5 +1,7 @@
//! Conversions between `indexer_service_protocol` types and `nssa/nssa_core` types.
use nssa_core::account::Nonce;
use crate::{
Account, AccountId, BedrockStatus, Block, BlockBody, BlockHeader, Ciphertext, Commitment,
CommitmentSetDigest, Data, EncryptedAccountData, EphemeralPublicKey, HashType, MantleMsgId,
@ -52,7 +54,7 @@ impl From<nssa_core::account::Account> for Account {
program_owner: program_owner.into(),
balance,
data: data.into(),
nonce,
nonce: nonce.0,
}
}
}
@ -72,7 +74,7 @@ impl TryFrom<Account> for nssa_core::account::Account {
program_owner: program_owner.into(),
balance,
data: data.try_into()?,
nonce,
nonce: Nonce(nonce),
})
}
}
@ -250,7 +252,7 @@ impl From<nssa::public_transaction::Message> for PublicMessage {
Self {
program_id: program_id.into(),
account_ids: account_ids.into_iter().map(Into::into).collect(),
nonces,
nonces: nonces.iter().map(|x| x.0).collect(),
instruction_data,
}
}
@ -267,7 +269,10 @@ impl From<PublicMessage> 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))
.collect(),
instruction_data,
)
}
@ -285,7 +290,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| 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()
@ -314,7 +319,10 @@ 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))
.collect(),
public_post_states: public_post_states
.into_iter()
.map(TryInto::try_into)

View File

@ -60,11 +60,11 @@ impl InitialData {
let mut private_charlie_key_chain = KeyChain::new_os_random();
let mut private_charlie_account_id =
AccountId::from(&private_charlie_key_chain.nullifer_public_key);
AccountId::from(&private_charlie_key_chain.nullifier_public_key);
let mut private_david_key_chain = KeyChain::new_os_random();
let mut private_david_account_id =
AccountId::from(&private_david_key_chain.nullifer_public_key);
AccountId::from(&private_david_key_chain.nullifier_public_key);
// Ensure consistent ordering
if private_charlie_account_id > private_david_account_id {
@ -87,7 +87,7 @@ impl InitialData {
balance: 10_000,
data: Data::default(),
program_owner: DEFAULT_PROGRAM_ID,
nonce: 0,
nonce: 0_u128.into(),
},
),
(
@ -96,7 +96,7 @@ impl InitialData {
balance: 20_000,
data: Data::default(),
program_owner: DEFAULT_PROGRAM_ID,
nonce: 0,
nonce: 0_u128.into(),
},
),
],
@ -121,7 +121,7 @@ impl InitialData {
self.private_accounts
.iter()
.map(|(key_chain, account)| PrivateAccountPublicInitialData {
npk: key_chain.nullifer_public_key.clone(),
npk: key_chain.nullifier_public_key.clone(),
account: account.clone(),
})
.collect()
@ -139,7 +139,7 @@ impl InitialData {
})
})
.chain(self.private_accounts.iter().map(|(key_chain, account)| {
let account_id = AccountId::from(&key_chain.nullifer_public_key);
let account_id = AccountId::from(&key_chain.nullifier_public_key);
InitialAccountData::Private(Box::new(PrivateAccountPrivateInitialData {
account_id,
account: account.clone(),

View File

@ -30,7 +30,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

@ -175,7 +175,7 @@ async fn private_transfer_to_owned_account_using_claiming_path() -> Result<()> {
let command = Command::AuthTransfer(AuthTransferSubcommand::Send {
from: format_private_account_id(from),
to: None,
to_npk: Some(hex::encode(to_keys.nullifer_public_key.0)),
to_npk: Some(hex::encode(to_keys.nullifier_public_key.0)),
to_vpk: Some(hex::encode(to_keys.viewing_public_key.0)),
amount: 100,
});
@ -335,7 +335,7 @@ async fn private_transfer_to_owned_account_continuous_run_path() -> Result<()> {
let command = Command::AuthTransfer(AuthTransferSubcommand::Send {
from: format_private_account_id(from),
to: None,
to_npk: Some(hex::encode(to_keys.nullifer_public_key.0)),
to_npk: Some(hex::encode(to_keys.nullifier_public_key.0)),
to_vpk: Some(hex::encode(to_keys.viewing_public_key.0)),
amount: 100,
});

View File

@ -241,7 +241,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

@ -70,7 +70,7 @@ async fn sync_private_account_with_non_zero_chain_index() -> Result<()> {
let command = Command::AuthTransfer(AuthTransferSubcommand::Send {
from: format_private_account_id(from),
to: None,
to_npk: Some(hex::encode(to_keys.nullifer_public_key.0)),
to_npk: Some(hex::encode(to_keys.nullifier_public_key.0)),
to_vpk: Some(hex::encode(to_keys.viewing_public_key.0)),
amount: 100,
});

View File

@ -63,7 +63,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

@ -1123,7 +1123,7 @@ async fn token_claiming_path_with_private_accounts() -> Result<()> {
let subcommand = TokenProgramAgnosticSubcommand::Mint {
definition: format_private_account_id(definition_account_id),
holder: None,
holder_npk: Some(hex::encode(holder_keys.nullifer_public_key.0)),
holder_npk: Some(hex::encode(holder_keys.nullifier_public_key.0)),
holder_vpk: Some(hex::encode(holder_keys.viewing_public_key.0)),
amount: mint_amount,
};

View File

@ -27,7 +27,7 @@ use nssa::{
};
use nssa_core::{
MembershipProof, NullifierPublicKey,
account::{AccountWithMetadata, data::Data},
account::{AccountWithMetadata, Nonce, data::Data},
encryption::ViewingPublicKey,
};
use tokio::test;
@ -78,7 +78,7 @@ impl TpsTestManager {
let message = putx::Message::try_new(
program.id(),
[pair[0].1, pair[1].1].to_vec(),
[0_u128].to_vec(),
[Nonce(0_u128)].to_vec(),
amount,
)
.unwrap();
@ -107,7 +107,7 @@ impl TpsTestManager {
let key_chain = KeyChain::new_os_random();
let account = Account {
balance: 100,
nonce: 0xdead_beef,
nonce: Nonce(0xdead_beef),
program_owner: Program::authenticated_transfer_program().id(),
data: Data::default(),
};
@ -216,7 +216,7 @@ fn build_privacy_transaction() -> PrivacyPreservingTransaction {
let sender_pre = AccountWithMetadata::new(
Account {
balance: 100,
nonce: 0xdead_beef,
nonce: Nonce(0xdead_beef),
program_owner: program.id(),
data: Data::default(),
},
@ -250,7 +250,6 @@ fn build_privacy_transaction() -> PrivacyPreservingTransaction {
vec![sender_pre, recipient_pre],
Program::serialize_instruction(balance_to_move).unwrap(),
vec![1, 2],
vec![0xdead_beef1, 0xdead_beef2],
vec![
(sender_npk.clone(), sender_ss),
(recipient_npk.clone(), recipient_ss),

View File

@ -491,7 +491,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(&raw mut out_account);
@ -528,7 +528,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, 0_u128.into());
unsafe {
wallet_ffi_free_account_data(&raw mut out_account);
@ -606,7 +606,7 @@ fn test_wallet_ffi_get_private_account_keys() -> Result<()> {
.unwrap()
.0;
let expected_npk = &key_chain.nullifer_public_key;
let expected_npk = &key_chain.nullifier_public_key;
let expected_vpk = &key_chain.viewing_public_key;
assert_eq!(&keys.npk(), expected_npk);

View File

@ -39,7 +39,7 @@ impl KeyNode for ChildKeysPrivate {
value: (
KeyChain {
secret_spending_key: ssk,
nullifer_public_key: npk,
nullifier_public_key: npk,
viewing_public_key: vpk,
private_key_holder: PrivateKeyHolder {
nullifier_secret_key: nsk,
@ -54,10 +54,7 @@ impl KeyNode for ChildKeysPrivate {
}
fn nth_child(&self, cci: u32) -> Self {
#[expect(
clippy::arithmetic_side_effects,
reason = "Multiplying finite field scalars gives no unexpected side effects"
)]
#[expect(clippy::arithmetic_side_effects, reason = "TODO: fix later")]
let parent_pt =
Scalar::from_repr(self.value.0.private_key_holder.nullifier_secret_key.into())
.expect("Key generated as scalar, must be valid representation")
@ -67,7 +64,8 @@ impl KeyNode for ChildKeysPrivate {
input.extend_from_slice(b"LEE_seed_priv");
input.extend_from_slice(&parent_pt.to_bytes());
input.extend_from_slice(&cci.to_le_bytes());
#[expect(clippy::big_endian_bytes, reason = "BIP-032 uses big endian")]
input.extend_from_slice(&cci.to_be_bytes());
let hash_value = hmac_sha512::HMAC::mac(input, self.ccc);
@ -90,7 +88,7 @@ impl KeyNode for ChildKeysPrivate {
value: (
KeyChain {
secret_spending_key: ssk,
nullifer_public_key: npk,
nullifier_public_key: npk,
viewing_public_key: vpk,
private_key_holder: PrivateKeyHolder {
nullifier_secret_key: nsk,
@ -113,18 +111,26 @@ impl KeyNode for ChildKeysPrivate {
}
fn account_id(&self) -> nssa::AccountId {
nssa::AccountId::from(&self.value.0.nullifer_public_key)
nssa::AccountId::from(&self.value.0.nullifier_public_key)
}
}
impl<'keys> From<&'keys ChildKeysPrivate> for &'keys (KeyChain, nssa::Account) {
fn from(value: &'keys ChildKeysPrivate) -> Self {
#[expect(
clippy::single_char_lifetime_names,
reason = "TODO add meaningful name"
)]
impl<'a> From<&'a ChildKeysPrivate> for &'a (KeyChain, nssa::Account) {
fn from(value: &'a ChildKeysPrivate) -> Self {
&value.value
}
}
impl<'keys> From<&'keys mut ChildKeysPrivate> for &'keys mut (KeyChain, nssa::Account) {
fn from(value: &'keys mut ChildKeysPrivate) -> Self {
#[expect(
clippy::single_char_lifetime_names,
reason = "TODO add meaningful name"
)]
impl<'a> From<&'a mut ChildKeysPrivate> for &'a mut (KeyChain, nssa::Account) {
fn from(value: &'a mut ChildKeysPrivate) -> Self {
&mut value.value
}
}
@ -166,7 +172,7 @@ mod tests {
7, 123, 125, 191, 233, 183, 201, 4, 20, 214, 155, 210, 45, 234, 27, 240, 194, 111, 97,
247, 155, 113, 122, 246, 192, 0, 70, 61, 76, 71, 70, 2,
]);
let expected_vsk: ViewingSecretKey = [
let expected_vsk = [
155, 90, 54, 75, 228, 130, 68, 201, 129, 251, 180, 195, 250, 64, 34, 230, 241, 204,
216, 50, 149, 156, 10, 67, 208, 74, 9, 10, 47, 59, 50, 202,
];
@ -179,7 +185,7 @@ mod tests {
assert!(expected_ssk == keys.value.0.secret_spending_key);
assert!(expected_ccc == keys.ccc);
assert!(expected_nsk == keys.value.0.private_key_holder.nullifier_secret_key);
assert!(expected_npk == keys.value.0.nullifer_public_key);
assert!(expected_npk == keys.value.0.nullifier_public_key);
assert!(expected_vsk == keys.value.0.private_key_holder.viewing_secret_key);
assert!(expected_vpk_as_bytes == keys.value.0.viewing_public_key.to_bytes());
}
@ -197,31 +203,31 @@ mod tests {
let child_node = ChildKeysPrivate::nth_child(&root_node, 42_u32);
let expected_ccc: [u8; 32] = [
145, 59, 225, 32, 54, 168, 14, 45, 60, 253, 57, 202, 31, 86, 142, 234, 51, 57, 154, 88,
132, 200, 92, 191, 220, 144, 42, 184, 108, 35, 226, 146,
27, 73, 133, 213, 214, 63, 217, 184, 164, 17, 172, 140, 223, 95, 255, 157, 11, 0, 58,
53, 82, 147, 121, 120, 199, 50, 30, 28, 103, 24, 121, 187,
];
let expected_nsk: NullifierSecretKey = [
19, 100, 119, 73, 191, 225, 234, 219, 129, 88, 40, 229, 63, 225, 189, 136, 69, 172,
221, 186, 147, 83, 150, 207, 70, 17, 228, 70, 113, 87, 227, 31,
124, 61, 40, 92, 33, 135, 3, 41, 200, 234, 3, 69, 102, 184, 57, 191, 106, 151, 194,
192, 103, 132, 141, 112, 249, 108, 192, 117, 24, 48, 70, 216,
];
let expected_npk = nssa_core::NullifierPublicKey([
133, 235, 223, 151, 12, 69, 26, 222, 60, 125, 235, 125, 167, 212, 201, 168, 101, 242,
111, 239, 1, 228, 12, 252, 146, 53, 75, 17, 187, 255, 122, 181,
116, 231, 246, 189, 145, 240, 37, 59, 219, 223, 216, 246, 116, 171, 223, 55, 197, 200,
134, 192, 221, 40, 218, 167, 239, 5, 11, 95, 147, 247, 162, 226,
]);
let expected_vsk: ViewingSecretKey = [
218, 219, 193, 132, 160, 6, 178, 194, 139, 248, 199, 81, 17, 133, 37, 201, 58, 104, 49,
222, 187, 46, 156, 93, 14, 118, 209, 243, 38, 101, 77, 45,
33, 155, 68, 60, 102, 70, 47, 105, 194, 129, 44, 26, 143, 198, 44, 244, 185, 31, 236,
252, 205, 89, 138, 107, 39, 38, 154, 73, 109, 166, 41, 114,
];
let expected_vpk_as_bytes: [u8; 33] = [
3, 164, 65, 167, 88, 167, 179, 51, 159, 27, 241, 174, 77, 174, 142, 106, 128, 96, 69,
74, 117, 231, 42, 193, 235, 153, 206, 116, 102, 7, 101, 192, 45,
2, 78, 213, 113, 117, 105, 162, 248, 175, 68, 128, 232, 106, 204, 208, 159, 11, 78, 48,
244, 127, 112, 46, 0, 93, 184, 1, 77, 132, 160, 75, 152, 88,
];
assert!(expected_ccc == child_node.ccc);
assert!(expected_nsk == child_node.value.0.private_key_holder.nullifier_secret_key);
assert!(expected_npk == child_node.value.0.nullifer_public_key);
assert!(expected_npk == child_node.value.0.nullifier_public_key);
assert!(expected_vsk == child_node.value.0.private_key_holder.viewing_secret_key);
assert!(expected_vpk_as_bytes == child_node.value.0.viewing_public_key.to_bytes());
}

View File

@ -13,17 +13,25 @@ pub struct ChildKeysPublic {
}
impl ChildKeysPublic {
#[expect(clippy::big_endian_bytes, reason = "BIP-032 uses big endian")]
fn compute_hash_value(&self, cci: u32) -> [u8; 64] {
let mut hash_input = vec![];
if 2_u32.pow(31) > cci {
// Non-harden
hash_input.extend_from_slice(self.cpk.value());
if ((2_u32).pow(31)).cmp(&cci) == std::cmp::Ordering::Greater {
// Non-harden.
// BIP-032 compatibility requires 1-byte header from the public_key;
// Not stored in `self.cpk.value()`.
let sk = secp256k1::SecretKey::from_byte_array(*self.csk.value())
.expect("32 bytes, within curve order");
let pk = secp256k1::PublicKey::from_secret_key(&secp256k1::Secp256k1::new(), &sk);
hash_input.extend_from_slice(&secp256k1::PublicKey::serialize(&pk));
} else {
// Harden
// Harden.
hash_input.extend_from_slice(&[0_u8]);
hash_input.extend_from_slice(self.csk.value());
}
hash_input.extend_from_slice(&cci.to_le_bytes());
hash_input.extend_from_slice(&cci.to_be_bytes());
hmac_sha512::HMAC::mac(hash_input, self.ccc)
}
@ -55,11 +63,13 @@ impl KeyNode for ChildKeysPublic {
)
.unwrap();
let csk = nssa::PrivateKey::try_new(
csk.add_tweak(&Scalar::from_le_bytes(*self.csk.value()).unwrap())
let csk = nssa::PrivateKey::try_new({
let scalar = Scalar::from_be_bytes(*self.csk.value()).unwrap();
csk.add_tweak(&scalar)
.expect("Expect a valid Scalar")
.secret_bytes(),
)
.secret_bytes()
})
.unwrap();
assert!(
@ -94,8 +104,12 @@ impl KeyNode for ChildKeysPublic {
}
}
impl<'keys> From<&'keys ChildKeysPublic> for &'keys nssa::PrivateKey {
fn from(value: &'keys ChildKeysPublic) -> Self {
#[expect(
clippy::single_char_lifetime_names,
reason = "TODO add meaningful name"
)]
impl<'a> From<&'a ChildKeysPublic> for &'a nssa::PrivateKey {
fn from(value: &'a ChildKeysPublic) -> Self {
&value.csk
}
}
@ -126,6 +140,7 @@ mod tests {
202, 148, 181, 228, 35, 222, 58, 84, 156, 24, 146, 86,
])
.unwrap();
let expected_cpk: PublicKey = PublicKey::try_new([
219, 141, 130, 105, 11, 203, 187, 124, 112, 75, 223, 22, 11, 164, 153, 127, 59, 247,
244, 166, 75, 66, 242, 224, 35, 156, 161, 75, 41, 51, 76, 245,
@ -149,26 +164,20 @@ mod tests {
let cci = (2_u32).pow(31) + 13;
let child_keys = ChildKeysPublic::nth_child(&root_keys, cci);
print!(
"{} {}",
child_keys.csk.value()[0],
child_keys.csk.value()[1]
);
let expected_ccc = [
126, 175, 244, 41, 41, 173, 134, 103, 139, 140, 195, 86, 194, 147, 116, 48, 71, 107,
253, 235, 114, 139, 60, 115, 226, 205, 215, 248, 240, 190, 196, 6,
149, 226, 13, 4, 194, 12, 69, 29, 9, 234, 209, 119, 98, 4, 128, 91, 37, 103, 192, 31,
130, 126, 123, 20, 90, 34, 173, 209, 101, 248, 155, 36,
];
let expected_csk: PrivateKey = PrivateKey::try_new([
128, 148, 53, 165, 222, 155, 163, 108, 186, 182, 124, 67, 90, 86, 59, 123, 95, 224,
171, 4, 51, 131, 254, 57, 241, 178, 82, 161, 204, 206, 79, 107,
9, 65, 33, 228, 25, 82, 219, 117, 91, 217, 11, 223, 144, 85, 246, 26, 123, 216, 107,
213, 33, 52, 188, 22, 198, 246, 71, 46, 245, 174, 16, 47,
])
.unwrap();
let expected_cpk: PublicKey = PublicKey::try_new([
149, 240, 55, 15, 178, 67, 245, 254, 44, 141, 95, 223, 238, 62, 85, 11, 248, 9, 11, 40,
69, 211, 116, 13, 189, 35, 8, 95, 233, 154, 129, 58,
142, 143, 238, 159, 105, 165, 224, 252, 108, 62, 53, 209, 176, 219, 249, 38, 90, 241,
201, 81, 194, 146, 236, 5, 83, 152, 238, 243, 138, 16, 229, 15,
])
.unwrap();
@ -189,26 +198,20 @@ mod tests {
let cci = 13;
let child_keys = ChildKeysPublic::nth_child(&root_keys, cci);
print!(
"{} {}",
child_keys.csk.value()[0],
child_keys.csk.value()[1]
);
let expected_ccc = [
50, 29, 113, 102, 49, 130, 64, 0, 247, 95, 135, 187, 118, 162, 65, 65, 194, 53, 189,
242, 66, 178, 168, 2, 51, 193, 155, 72, 209, 2, 207, 251,
79, 228, 242, 119, 211, 203, 198, 175, 95, 36, 4, 234, 139, 45, 137, 138, 54, 211, 187,
16, 28, 79, 80, 232, 216, 101, 145, 19, 101, 220, 217, 141,
];
let expected_csk: PrivateKey = PrivateKey::try_new([
162, 32, 211, 190, 180, 74, 151, 246, 189, 93, 8, 57, 182, 239, 125, 245, 192, 255, 24,
186, 251, 23, 194, 186, 252, 121, 190, 54, 147, 199, 1, 109,
185, 147, 32, 242, 145, 91, 123, 77, 42, 33, 134, 84, 12, 165, 117, 70, 158, 201, 95,
153, 14, 12, 92, 235, 128, 156, 194, 169, 68, 35, 165, 127,
])
.unwrap();
let expected_cpk: PublicKey = PublicKey::try_new([
183, 48, 207, 170, 221, 111, 118, 9, 40, 67, 123, 162, 159, 169, 34, 157, 23, 37, 232,
102, 231, 187, 199, 191, 205, 146, 159, 22, 79, 100, 10, 223,
119, 16, 145, 121, 97, 244, 186, 35, 136, 34, 140, 171, 206, 139, 11, 208, 207, 121,
158, 45, 28, 22, 140, 98, 161, 179, 212, 173, 238, 220, 2, 34,
])
.unwrap();
@ -230,19 +233,19 @@ mod tests {
let child_keys = ChildKeysPublic::nth_child(&root_keys, cci);
let expected_ccc = [
101, 15, 69, 152, 144, 22, 105, 89, 175, 21, 13, 50, 160, 167, 93, 80, 94, 99, 192,
252, 1, 126, 196, 217, 149, 164, 60, 75, 237, 90, 104, 83,
221, 208, 47, 189, 174, 152, 33, 25, 151, 114, 233, 191, 57, 15, 40, 140, 46, 87, 126,
58, 215, 40, 246, 111, 166, 113, 183, 145, 173, 11, 27, 182,
];
let expected_csk: PrivateKey = PrivateKey::try_new([
46, 196, 131, 199, 190, 180, 250, 222, 41, 188, 221, 156, 255, 239, 251, 207, 239, 202,
166, 216, 107, 236, 195, 48, 167, 69, 97, 13, 132, 117, 76, 89,
223, 29, 87, 189, 126, 24, 117, 225, 190, 57, 0, 143, 207, 168, 231, 139, 170, 192, 81,
254, 126, 10, 115, 42, 141, 157, 70, 171, 199, 231, 198, 132,
])
.unwrap();
let expected_cpk: PublicKey = PublicKey::try_new([
93, 151, 154, 238, 175, 198, 53, 146, 255, 43, 37, 52, 214, 165, 69, 161, 38, 20, 68,
166, 143, 80, 149, 216, 124, 203, 240, 114, 168, 111, 33, 83,
96, 123, 245, 51, 214, 216, 215, 205, 70, 145, 105, 221, 166, 169, 122, 27, 94, 112,
228, 110, 249, 177, 85, 173, 180, 248, 185, 199, 112, 246, 83, 33,
])
.unwrap();

View File

@ -16,7 +16,7 @@ pub type PublicAccountSigningKey = [u8; 32];
pub struct KeyChain {
pub secret_spending_key: SecretSpendingKey,
pub private_key_holder: PrivateKeyHolder,
pub nullifer_public_key: NullifierPublicKey,
pub nullifier_public_key: NullifierPublicKey,
pub viewing_public_key: ViewingPublicKey,
}
@ -30,13 +30,13 @@ impl KeyChain {
let private_key_holder = secret_spending_key.produce_private_key_holder(None);
let nullifer_public_key = private_key_holder.generate_nullifier_public_key();
let nullifier_public_key = private_key_holder.generate_nullifier_public_key();
let viewing_public_key = private_key_holder.generate_viewing_public_key();
Self {
secret_spending_key,
private_key_holder,
nullifer_public_key,
nullifier_public_key,
viewing_public_key,
}
}
@ -50,13 +50,13 @@ impl KeyChain {
let private_key_holder = secret_spending_key.produce_private_key_holder(None);
let nullifer_public_key = private_key_holder.generate_nullifier_public_key();
let nullifier_public_key = private_key_holder.generate_nullifier_public_key();
let viewing_public_key = private_key_holder.generate_viewing_public_key();
Self {
secret_spending_key,
private_key_holder,
nullifer_public_key,
nullifier_public_key,
viewing_public_key,
}
}
@ -93,7 +93,7 @@ mod tests {
// Check that key holder fields are initialized with expected types
assert_ne!(
account_id_key_holder.nullifer_public_key.as_ref(),
account_id_key_holder.nullifier_public_key.as_ref(),
&[0_u8; 32]
);
}
@ -119,7 +119,7 @@ mod tests {
let utxo_secret_key_holder = top_secret_key_holder.produce_private_key_holder(None);
let nullifer_public_key = utxo_secret_key_holder.generate_nullifier_public_key();
let nullifier_public_key = utxo_secret_key_holder.generate_nullifier_public_key();
let viewing_public_key = utxo_secret_key_holder.generate_viewing_public_key();
let pub_account_signing_key = nssa::PrivateKey::new_os_random();
@ -150,7 +150,7 @@ mod tests {
println!("Account {:?}", account.value().to_base58());
println!(
"Nulifier public key {:?}",
hex::encode(nullifer_public_key.to_byte_array())
hex::encode(nullifier_public_key.to_byte_array())
);
println!(
"Viewing public key {:?}",
@ -183,7 +183,7 @@ mod tests {
fn non_trivial_chain_index() {
let keys = account_with_chain_index_2_for_tests();
let eph_key_holder = EphemeralKeyHolder::new(&keys.nullifer_public_key);
let eph_key_holder = EphemeralKeyHolder::new(&keys.nullifier_public_key);
let key_sender = eph_key_holder.calculate_shared_secret_sender(&keys.viewing_public_key);
let key_receiver = keys.calculate_shared_secret_receiver(

View File

@ -78,6 +78,7 @@ impl SeedHolder {
impl SecretSpendingKey {
#[must_use]
#[expect(clippy::big_endian_bytes, reason = "BIP-032 uses big endian")]
pub fn generate_nullifier_secret_key(&self, index: Option<u32>) -> NullifierSecretKey {
const PREFIX: &[u8; 8] = b"LEE/keys";
const SUFFIX_1: &[u8; 1] = &[1];
@ -92,13 +93,14 @@ impl SecretSpendingKey {
hasher.update(PREFIX);
hasher.update(self.0);
hasher.update(SUFFIX_1);
hasher.update(index.to_le_bytes());
hasher.update(index.to_be_bytes());
hasher.update(SUFFIX_2);
<NullifierSecretKey>::from(hasher.finalize_fixed())
}
#[must_use]
#[expect(clippy::big_endian_bytes, reason = "BIP-032 uses big endian")]
pub fn generate_viewing_secret_key(&self, index: Option<u32>) -> ViewingSecretKey {
const PREFIX: &[u8; 8] = b"LEE/keys";
const SUFFIX_1: &[u8; 1] = &[2];
@ -113,7 +115,7 @@ impl SecretSpendingKey {
hasher.update(PREFIX);
hasher.update(self.0);
hasher.update(SUFFIX_1);
hasher.update(index.to_le_bytes());
hasher.update(index.to_be_bytes());
hasher.update(SUFFIX_2);
hasher.finalize_fixed().into()

View File

@ -46,7 +46,7 @@ impl NSSAUserData {
) -> bool {
let mut check_res = true;
for (account_id, (key, _)) in accounts_keys_map {
let expected_account_id = nssa::AccountId::from(&key.nullifer_public_key);
let expected_account_id = nssa::AccountId::from(&key.nullifier_public_key);
if expected_account_id != *account_id {
println!("{expected_account_id}, {account_id}");
check_res = false;

View File

@ -6,14 +6,89 @@ use std::{
use base58::{FromBase58 as _, ToBase58 as _};
use borsh::{BorshDeserialize, BorshSerialize};
pub use data::Data;
use risc0_zkvm::sha::{Impl, Sha256 as _};
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)]
pub struct Nonce(pub u128);
impl Nonce {
pub const fn public_account_nonce_increment(&mut self) {
self.0 = self
.0
.checked_add(1)
.expect("Overflow when incrementing nonce");
}
#[must_use]
pub fn private_account_nonce_init(npk: &NullifierPublicKey) -> Self {
let mut bytes: [u8; 64] = [0_u8; 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();
Self(u128::from_le_bytes(*result))
}
#[must_use]
pub fn private_account_nonce_increment(self, nsk: &NullifierSecretKey) -> Self {
let mut bytes: [u8; 64] = [0_u8; 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();
Self(u128::from_le_bytes(*result))
}
}
impl From<u128> for Nonce {
fn from(value: u128) -> Self {
Self(value)
}
}
impl From<Nonce> for u128 {
fn from(value: Nonce) -> Self {
value.0
}
}
impl Serialize for Nonce {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
Serialize::serialize(&self.0, serializer)
}
}
impl<'de> Deserialize<'de> for Nonce {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
Ok(<u128 as Deserialize>::deserialize(deserializer)?.into())
}
}
impl BorshSerialize for Nonce {
fn serialize<W: std::io::Write>(&self, writer: &mut W) -> std::io::Result<()> {
BorshSerialize::serialize(&self.0, writer)
}
}
impl BorshDeserialize for Nonce {
fn deserialize_reader<R: std::io::Read>(reader: &mut R) -> std::io::Result<Self> {
Ok(<u128 as BorshDeserialize>::deserialize_reader(reader)?.into())
}
}
pub type Balance = u128;
/// Account to be used both in public and private contexts.
@ -154,7 +229,7 @@ mod tests {
fn zero_nonce_account_data_creation() {
let new_acc = Account::default();
assert_eq!(new_acc.nonce, 0);
assert_eq!(new_acc.nonce.0, 0);
}
#[test]
@ -181,7 +256,7 @@ mod tests {
.to_vec()
.try_into()
.unwrap(),
nonce: 0xdead_beef,
nonce: Nonce(0xdead_beef),
};
let fingerprint = AccountId::new([8; 32]);
let new_acc_with_metadata = AccountWithMetadata::new(account.clone(), true, fingerprint);
@ -228,4 +303,52 @@ 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::private_account_nonce_init(&npk);
let expected_nonce = Nonce(37_937_661_125_547_691_021_612_781_941_709_513_486);
assert_eq!(nonce, expected_nonce);
}
#[test]
fn increment_private_nonce() {
let nsk: NullifierSecretKey = [42_u8; 32];
let nonce = Nonce(37_937_661_125_547_691_021_612_781_941_709_513_486)
.private_account_nonce_increment(&nsk);
let expected_nonce = Nonce(327_300_903_218_789_900_388_409_116_014_290_259_894);
assert_eq!(nonce, expected_nonce);
}
#[test]
fn increment_public_nonce() {
let value = 42_u128;
let mut nonce = Nonce(value);
nonce.public_account_nonce_increment();
let expected_nonce = Nonce(value + 1);
assert_eq!(nonce, expected_nonce);
}
#[test]
fn serde_roundtrip_for_nonce() {
let nonce: Nonce = 7_u128.into();
let serde_serialized_nonce = serde_json::to_vec(&nonce).unwrap();
let nonce_restored = serde_json::from_slice(&serde_serialized_nonce).unwrap();
assert_eq!(nonce, nonce_restored);
}
#[test]
fn borsh_roundtrip_for_nonce() {
let nonce: Nonce = 7_u128.into();
let borsh_serialized_nonce = borsh::to_vec(&nonce).unwrap();
let nonce_restored = borsh::from_slice(&borsh_serialized_nonce).unwrap();
assert_eq!(nonce, nonce_restored);
}
}

View File

@ -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<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.
@ -57,7 +55,7 @@ mod tests {
use super::*;
use crate::{
Commitment, Nullifier, NullifierPublicKey,
account::{Account, AccountId, AccountWithMetadata},
account::{Account, AccountId, AccountWithMetadata, Nonce},
};
#[test]
@ -69,7 +67,7 @@ mod tests {
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
balance: 12_345_678_901_234_567_890,
data: b"test data".to_vec().try_into().unwrap(),
nonce: 0xFFFF_FFFF_FFFF_FFFE,
nonce: Nonce(0xFFFF_FFFF_FFFF_FFFE),
},
true,
AccountId::new([0; 32]),
@ -79,7 +77,7 @@ mod tests {
program_owner: [9, 9, 9, 8, 8, 8, 7, 7],
balance: 123_123_123_456_456_567_112,
data: b"test data".to_vec().try_into().unwrap(),
nonce: 9_999_999_999_999_999_999_999,
nonce: Nonce(9_999_999_999_999_999_999_999),
},
false,
AccountId::new([1; 32]),
@ -89,7 +87,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: 0xFFFF_FFFF_FFFF_FFFF,
nonce: Nonce(0xFFFF_FFFF_FFFF_FFFF),
}],
ciphertexts: vec![Ciphertext(vec![255, 255, 1, 1, 2, 2])],
new_commitments: vec![Commitment::new(

View File

@ -61,7 +61,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

@ -25,8 +25,8 @@ 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());
let data_length: u32 = u32::try_from(self.data.len()).expect("data length fits in u32");
bytes.extend_from_slice(&self.nonce.0.to_le_bytes());
let data_length: u32 = u32::try_from(self.data.len()).expect("Invalid u32");
bytes.extend_from_slice(&data_length.to_le_bytes());
bytes.extend_from_slice(self.data.as_ref());
bytes
@ -35,7 +35,7 @@ impl Account {
/// Deserializes an account from a cursor.
#[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 = [0_u8; 4];
let mut u128_bytes = [0_u8; 16];
@ -53,7 +53,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)?;
@ -189,7 +189,7 @@ mod tests {
let account = Account {
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
balance: 123_456_789_012_345_678_901_234_567_890_123_456,
nonce: 42,
nonce: 42_u128.into(),
data: b"hola mundo".to_vec().try_into().unwrap(),
};
@ -250,7 +250,7 @@ mod tests {
let account = Account {
program_owner: [1, 2, 3, 4, 5, 6, 7, 8],
balance: 123_456_789_012_345_678_901_234_567_890_123_456,
nonce: 42,
nonce: 42_u128.into(),
data: b"hola mundo".to_vec().try_into().unwrap(),
};
let bytes = account.to_bytes();

View File

@ -348,7 +348,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: 10_u128.into(),
};
let account_post_state = AccountPostState::new_claimed(account.clone());
@ -363,7 +363,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: 10_u128.into(),
};
let account_post_state = AccountPostState::new(account.clone());
@ -378,7 +378,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: 10_u128.into(),
};
let mut account_post_state = AccountPostState::new(account.clone());

View File

@ -63,12 +63,11 @@ impl From<Program> for ProgramWithDependencies {
/// Generates a proof of the execution of a NSSA program inside the privacy preserving execution
/// circuit.
#[expect(clippy::too_many_arguments, reason = "TODO: fix later")]
/// TODO: too many parameters.
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>>,
@ -127,7 +126,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,
@ -177,7 +175,7 @@ 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::*;
@ -215,14 +213,14 @@ mod tests {
let expected_sender_post = Account {
program_owner: program.id(),
balance: 100 - balance_to_move,
nonce: 0,
nonce: Nonce::default(),
data: Data::default(),
};
let expected_recipient_post = Account {
program_owner: program.id(),
balance: balance_to_move,
nonce: 0xdead_beef,
nonce: Nonce::private_account_nonce_init(&recipient_keys.npk()),
data: Data::default(),
};
@ -235,7 +233,6 @@ mod tests {
vec![sender, recipient],
Program::serialize_instruction(balance_to_move).unwrap(),
vec![0, 2],
vec![0xdead_beef],
vec![(recipient_keys.npk(), shared_secret)],
vec![],
vec![None],
@ -269,10 +266,11 @@ mod tests {
let sender_keys = test_private_account_keys_1();
let recipient_keys = test_private_account_keys_2();
let sender_nonce = Nonce(0xdead_beef);
let sender_pre = AccountWithMetadata::new(
Account {
balance: 100,
nonce: 0xdead_beef,
nonce: sender_nonce,
program_owner: program.id(),
data: Data::default(),
},
@ -307,13 +305,13 @@ mod tests {
let expected_private_account_1 = Account {
program_owner: program.id(),
balance: 100 - balance_to_move,
nonce: 0xdead_beef1,
nonce: sender_nonce.private_account_nonce_increment(&sender_keys.nsk),
..Default::default()
};
let expected_private_account_2 = Account {
program_owner: program.id(),
balance: balance_to_move,
nonce: 0xdead_beef2,
nonce: Nonce::private_account_nonce_init(&recipient_keys.npk()),
..Default::default()
};
let expected_new_commitments = vec![
@ -331,7 +329,6 @@ mod tests {
vec![sender_pre, recipient],
Program::serialize_instruction(balance_to_move).unwrap(),
vec![1, 2],
vec![0xdead_beef1, 0xdead_beef2],
vec![
(sender_keys.npk(), shared_secret_1),
(recipient_keys.npk(), shared_secret_2),

View File

@ -140,7 +140,7 @@ pub mod tests {
let public_account_ids = vec![AccountId::new([1; 32])];
let nonces = vec![1, 2, 3];
let nonces = vec![1_u128.into(), 2_u128.into(), 3_u128.into()];
let public_post_states = vec![Account::default()];

View File

@ -269,7 +269,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![0_u128.into(), 0_u128.into()];
let instruction = 1337;
let message = Message::try_new(
Program::authenticated_transfer_program().id(),
@ -347,7 +347,7 @@ pub mod tests {
fn 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![0_u128.into(), 0_u128.into()];
let instruction = 1337;
let message = Message::try_new(
Program::authenticated_transfer_program().id(),
@ -367,7 +367,7 @@ pub mod tests {
fn 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![0_u128.into()];
let instruction = 1337;
let message = Message::try_new(
Program::authenticated_transfer_program().id(),
@ -387,7 +387,7 @@ pub mod tests {
fn 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![0_u128.into(), 0_u128.into()];
let instruction = 1337;
let message = Message::try_new(
Program::authenticated_transfer_program().id(),
@ -408,7 +408,7 @@ pub mod tests {
fn 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![0_u128.into(), 1_u128.into()];
let instruction = 1337;
let message = Message::try_new(
Program::authenticated_transfer_program().id(),
@ -428,7 +428,7 @@ pub mod tests {
fn 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![0_u128.into(), 0_u128.into()];
let instruction = 1337;
let unknown_program_id = [0xdead_beef; 8];
let message =

View File

@ -67,7 +67,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![1_u128.into(), 2_u128.into()];
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,
};
@ -172,10 +172,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 = current_account
.nonce
.checked_add(1)
.ok_or(NssaError::MaxAccountNonceReached)?;
current_account.nonce.public_account_nonce_increment();
}
Ok(())
@ -215,10 +212,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 = current_account
.nonce
.checked_add(1)
.ok_or(NssaError::MaxAccountNonceReached)?;
current_account.nonce.public_account_nonce_increment();
}
Ok(())
@ -303,7 +297,7 @@ impl V02State {
balance: 1_500_000,
// Difficulty: 3
data: vec![3; 33].try_into().expect("should fit"),
nonce: 0,
nonce: Nonce::default(),
},
);
}
@ -389,7 +383,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 {
@ -463,7 +457,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();
@ -577,8 +571,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, Nonce(1));
assert_eq!(state.get_account_by_id(to).nonce, Nonce(0));
}
#[test]
@ -599,8 +593,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, Nonce(0));
assert_eq!(state.get_account_by_id(to).nonce, Nonce(0));
}
#[test]
@ -622,8 +616,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, Nonce(1));
assert_eq!(state.get_account_by_id(to).nonce, Nonce(0));
}
#[test]
@ -646,9 +640,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, Nonce(1));
assert_eq!(state.get_account_by_id(account_id2).nonce, Nonce(1));
assert_eq!(state.get_account_by_id(account_id3).nonce, Nonce(0));
}
#[test]
@ -942,7 +936,6 @@ pub mod tests {
vec![sender, recipient],
Program::serialize_instruction(balance_to_move).unwrap(),
vec![0, 2],
vec![0xdead_beef],
vec![(recipient_keys.npk(), shared_secret)],
vec![],
vec![None],
@ -967,7 +960,6 @@ pub mod tests {
sender_private_account: &Account,
recipient_keys: &TestPrivateKeys,
balance_to_move: u128,
new_nonces: [Nonce; 2],
state: &V02State,
) -> PrivacyPreservingTransaction {
let program = Program::authenticated_transfer_program();
@ -989,7 +981,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),
@ -1021,7 +1012,6 @@ pub mod tests {
sender_private_account: &Account,
recipient_account_id: &AccountId,
balance_to_move: u128,
new_nonce: Nonce,
state: &V02State,
) -> PrivacyPreservingTransaction {
let program = Program::authenticated_transfer_program();
@ -1042,7 +1032,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)],
@ -1083,7 +1072,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.public_account_nonce_increment();
this
};
@ -1107,10 +1096,12 @@ pub mod tests {
#[test]
fn transition_from_privacy_preserving_transaction_private() {
let sender_keys = test_private_account_keys_1();
let sender_nonce = Nonce(0xdead_beef);
let sender_private_account = Account {
program_owner: Program::authenticated_transfer_program().id(),
balance: 100,
nonce: 0xdead_beef,
nonce: sender_nonce,
data: Data::default(),
};
let recipient_keys = test_private_account_keys_2();
@ -1125,7 +1116,6 @@ pub mod tests {
&sender_private_account,
&recipient_keys,
balance_to_move,
[0xcafe_cafe, 0xfeca_feca],
&state,
);
@ -1133,7 +1123,7 @@ pub mod tests {
&sender_keys.npk(),
&Account {
program_owner: Program::authenticated_transfer_program().id(),
nonce: 0xcafe_cafe,
nonce: sender_nonce.private_account_nonce_increment(&sender_keys.nsk),
balance: sender_private_account.balance - balance_to_move,
data: Data::default(),
},
@ -1147,7 +1137,7 @@ pub mod tests {
&recipient_keys.npk(),
&Account {
program_owner: Program::authenticated_transfer_program().id(),
nonce: 0xfeca_feca,
nonce: Nonce::private_account_nonce_init(&recipient_keys.npk()),
balance: balance_to_move,
..Account::default()
},
@ -1173,10 +1163,12 @@ pub mod tests {
#[test]
fn transition_from_privacy_preserving_transaction_deshielded() {
let sender_keys = test_private_account_keys_1();
let sender_nonce = Nonce(0xdead_beef);
let sender_private_account = Account {
program_owner: Program::authenticated_transfer_program().id(),
balance: 100,
nonce: 0xdead_beef,
nonce: sender_nonce,
data: Data::default(),
};
let recipient_keys = test_public_account_keys_1();
@ -1200,7 +1192,6 @@ pub mod tests {
&sender_private_account,
&recipient_keys.account_id(),
balance_to_move,
0xcafe_cafe,
&state,
);
@ -1208,7 +1199,7 @@ pub mod tests {
&sender_keys.npk(),
&Account {
program_owner: Program::authenticated_transfer_program().id(),
nonce: 0xcafe_cafe,
nonce: sender_nonce.private_account_nonce_increment(&sender_keys.nsk),
balance: sender_private_account.balance - balance_to_move,
data: Data::default(),
},
@ -1257,7 +1248,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1284,7 +1274,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1311,7 +1300,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1338,7 +1326,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1373,7 +1360,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1400,7 +1386,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1436,7 +1421,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1463,7 +1447,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1499,7 +1482,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1537,7 +1519,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -1561,13 +1542,10 @@ pub mod tests {
let private_account_2 =
AccountWithMetadata::new(Account::default(), false, &recipient_keys.npk());
// Setting only one nonce for an execution with two private accounts.
let private_account_nonces = [0xdead_beef1];
let result = execute_and_prove(
vec![private_account_1, private_account_2],
Program::serialize_instruction(10_u128).unwrap(),
vec![1, 2],
private_account_nonces.to_vec(),
vec![
(
sender_keys.npk(),
@ -1611,7 +1589,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10_u128).unwrap(),
vec![1, 2],
vec![0xdead_beef1, 0xdead_beef2],
private_account_keys.to_vec(),
vec![sender_keys.nsk],
vec![Some((0, vec![]))],
@ -1644,7 +1621,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10_u128).unwrap(),
vec![1, 2],
vec![0xdead_beef1, 0xdead_beef2],
vec![
(
sender_keys.npk(),
@ -1686,7 +1662,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10_u128).unwrap(),
vec![1, 2],
vec![0xdead_beef1, 0xdead_beef2],
vec![
(
sender_keys.npk(),
@ -1744,7 +1719,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10_u128).unwrap(),
vec![1, 2],
vec![0xdead_beef1, 0xdead_beef2],
private_account_keys.to_vec(),
private_account_nsks.to_vec(),
private_account_membership_proofs.to_vec(),
@ -1782,7 +1756,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10_u128).unwrap(),
vec![1, 2],
vec![0xdead_beef1, 0xdead_beef2],
vec![
(
sender_keys.npk(),
@ -1829,7 +1802,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10_u128).unwrap(),
vec![1, 2],
vec![0xdead_beef1, 0xdead_beef2],
vec![
(
sender_keys.npk(),
@ -1876,7 +1848,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10_u128).unwrap(),
vec![1, 2],
vec![0xdead_beef1, 0xdead_beef2],
vec![
(
sender_keys.npk(),
@ -1912,7 +1883,7 @@ pub mod tests {
let private_account_2 = AccountWithMetadata::new(
Account {
// Non default nonce
nonce: 0xdead_beef,
nonce: Nonce(0xdead_beef),
..Account::default()
},
false,
@ -1923,7 +1894,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10_u128).unwrap(),
vec![1, 2],
vec![0xdead_beef1, 0xdead_beef2],
vec![
(
sender_keys.npk(),
@ -1968,7 +1938,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10_u128).unwrap(),
vec![1, 2],
vec![0xdead_beef1, 0xdead_beef2],
vec![
(
sender_keys.npk(),
@ -2010,7 +1979,6 @@ pub mod tests {
vec![],
vec![],
vec![],
vec![],
&program.into(),
);
@ -2034,14 +2002,10 @@ pub mod tests {
let private_account_2 =
AccountWithMetadata::new(Account::default(), false, &recipient_keys.npk());
// Setting three new private account nonces for a circuit execution with only two private
// accounts.
let private_account_nonces = [0xdead_beef1, 0xdead_beef2, 0xdead_beef3];
let result = execute_and_prove(
vec![private_account_1, private_account_2],
Program::serialize_instruction(10_u128).unwrap(),
vec![1, 2],
private_account_nonces.to_vec(),
vec![
(
sender_keys.npk(),
@ -2097,7 +2061,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10_u128).unwrap(),
vec![1, 2],
vec![0xdead_beef1, 0xdead_beef2],
private_account_keys.to_vec(),
vec![sender_keys.nsk],
vec![Some((0, vec![]))],
@ -2133,7 +2096,6 @@ pub mod tests {
vec![private_account_1, private_account_2],
Program::serialize_instruction(10_u128).unwrap(),
visibility_mask.to_vec(),
vec![0xdead_beef1, 0xdead_beef2],
vec![
(
sender_keys.npk(),
@ -2155,10 +2117,12 @@ pub mod tests {
#[test]
fn private_accounts_can_only_be_initialized_once() {
let sender_keys = test_private_account_keys_1();
let sender_nonce = Nonce(0xdead_beef);
let sender_private_account = Account {
program_owner: Program::authenticated_transfer_program().id(),
balance: 100,
nonce: 0xdead_beef,
nonce: sender_nonce,
data: Data::default(),
};
let recipient_keys = test_private_account_keys_2();
@ -2167,13 +2131,13 @@ pub mod tests {
.with_private_account(&sender_keys, &sender_private_account);
let balance_to_move = 37;
let balance_to_move_2 = 30;
let tx = private_balance_transfer_for_tests(
&sender_keys,
&sender_private_account,
&recipient_keys,
balance_to_move,
[0xcafe_cafe, 0xfeca_feca],
&state,
);
@ -2183,8 +2147,8 @@ pub mod tests {
let sender_private_account = Account {
program_owner: Program::authenticated_transfer_program().id(),
balance: 100 - balance_to_move,
nonce: 0xcafe_cafe,
balance: 100,
nonce: sender_nonce,
data: Data::default(),
};
@ -2192,8 +2156,7 @@ pub mod tests {
&sender_keys,
&sender_private_account,
&recipient_keys,
balance_to_move,
[0x1234, 0x5678],
balance_to_move_2,
&state,
);
@ -2229,7 +2192,6 @@ pub mod tests {
vec![private_account_1.clone(), private_account_1],
Program::serialize_instruction(100_u128).unwrap(),
visibility_mask.to_vec(),
vec![0xdead_beef1, 0xdead_beef2],
vec![
(sender_keys.npk(), shared_secret),
(sender_keys.npk(), shared_secret),
@ -2265,9 +2227,13 @@ pub mod tests {
..Account::default()
};
let message =
public_transaction::Message::try_new(program.id(), vec![from, to], vec![0], amount)
.unwrap();
let message = 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);
@ -2307,7 +2273,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();
@ -2347,7 +2313,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();
@ -2444,7 +2410,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();
@ -2514,8 +2480,8 @@ pub mod tests {
dependencies.insert(auth_transfers.id(), auth_transfers);
let program_with_deps = ProgramWithDependencies::new(chain_caller, dependencies);
let from_new_nonce = 0xdead_beef1;
let to_new_nonce = 0xdead_beef2;
let from_new_nonce = Nonce::default().private_account_nonce_increment(&from_keys.nsk);
let to_new_nonce = Nonce::default().private_account_nonce_increment(&to_keys.nsk);
let from_expected_post = Account {
balance: initial_balance - u128::from(number_of_calls) * amount,
@ -2536,7 +2502,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![
@ -2732,14 +2697,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
};
@ -2768,14 +2733,11 @@ pub mod tests {
// Balance to initialize the account with (0 for a new account)
let balance: u128 = 0;
let nonce = 0xdead_beef1;
// 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],
@ -2821,14 +2783,12 @@ pub mod tests {
let epk = EphemeralPublicKey::from_scalar(esk);
let balance: u128 = 0;
let nonce = 0xdead_beef1;
// 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],
@ -2869,14 +2829,11 @@ pub mod tests {
let esk2 = [4; 32];
let shared_secret2 = SharedSecretKey::new(&esk2, &private_keys.vpk());
let nonce2 = 0xdead_beef2;
// 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],
@ -2946,7 +2903,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.vpk()),
@ -2974,7 +2930,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.vpk()),
@ -3026,14 +2981,11 @@ pub mod tests {
dependencies.insert(auth_transfers.id(), auth_transfers);
let program_with_deps = ProgramWithDependencies::new(malicious_program, dependencies);
let recipient_new_nonce = 0xdead_beef1;
// 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

@ -200,7 +200,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>],
@ -220,7 +219,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();
@ -246,7 +244,7 @@ fn compute_circuit_output(
"AccountId mismatch"
);
let new_nullifier = if account_visibility_mask == 1 {
let (new_nullifier, new_nonce) = if account_visibility_mask == 1 {
// Private account with authentication
let Some(nsk) = private_nsks_iter.next() else {
@ -270,12 +268,16 @@ 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
@ -300,16 +302,16 @@ fn compute_circuit_output(
);
let nullifier = Nullifier::for_account_initialization(npk);
(nullifier, DUMMY_COMMITMENT_HASH)
let new_nonce = Nonce::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;
// Compute commitment
let commitment_post = Commitment::new(npk, &post_with_updated_nonce);
@ -332,8 +334,6 @@ fn compute_circuit_output(
}
}
assert!(private_nonces_iter.next().is_none(), "Too many nonces");
assert!(
private_keys_iter.next().is_none(),
"Too many private account keys"
@ -386,7 +386,6 @@ fn main() {
let PrivacyPreservingCircuitInput {
program_outputs,
visibility_mask,
private_account_nonces,
private_account_keys,
private_account_nsks,
private_account_membership_proofs,
@ -398,7 +397,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,

View File

@ -446,7 +446,7 @@ impl AccountWithMetadataForTests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::user_token_a_balance(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::user_token_a_id(),
@ -462,7 +462,7 @@ impl AccountWithMetadataForTests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::user_token_b_balance(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::user_token_b_id(),
@ -478,7 +478,7 @@ impl AccountWithMetadataForTests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::vault_a_reserve_init(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::vault_a_id(),
@ -494,7 +494,7 @@ impl AccountWithMetadataForTests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::vault_b_reserve_init(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::vault_b_id(),
@ -510,7 +510,7 @@ impl AccountWithMetadataForTests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::vault_a_reserve_high(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::vault_a_id(),
@ -526,7 +526,7 @@ impl AccountWithMetadataForTests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::vault_b_reserve_high(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::vault_b_id(),
@ -542,7 +542,7 @@ impl AccountWithMetadataForTests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::vault_a_reserve_low(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::vault_a_id(),
@ -558,7 +558,7 @@ impl AccountWithMetadataForTests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::vault_b_reserve_low(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::vault_b_id(),
@ -574,7 +574,7 @@ impl AccountWithMetadataForTests {
definition_id: IdForTests::token_a_definition_id(),
balance: 0,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::vault_a_id(),
@ -590,7 +590,7 @@ impl AccountWithMetadataForTests {
definition_id: IdForTests::token_b_definition_id(),
balance: 0,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::vault_b_id(),
@ -607,7 +607,7 @@ impl AccountWithMetadataForTests {
total_supply: BalanceForTests::lp_supply_init(),
metadata_id: None,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::token_lp_definition_id(),
@ -624,7 +624,7 @@ impl AccountWithMetadataForTests {
total_supply: BalanceForTests::lp_supply_init(),
metadata_id: None,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::vault_a_id(),
@ -640,7 +640,7 @@ impl AccountWithMetadataForTests {
definition_id: IdForTests::token_lp_definition_id(),
balance: 0,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::user_token_lp_id(),
@ -656,7 +656,7 @@ impl AccountWithMetadataForTests {
definition_id: IdForTests::token_lp_definition_id(),
balance: BalanceForTests::user_token_lp_balance(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::user_token_lp_id(),
@ -680,7 +680,7 @@ impl AccountWithMetadataForTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -704,7 +704,7 @@ impl AccountWithMetadataForTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -728,7 +728,7 @@ impl AccountWithMetadataForTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -752,7 +752,7 @@ impl AccountWithMetadataForTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -776,7 +776,7 @@ impl AccountWithMetadataForTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -800,7 +800,7 @@ impl AccountWithMetadataForTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -824,7 +824,7 @@ impl AccountWithMetadataForTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -848,7 +848,7 @@ impl AccountWithMetadataForTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -872,7 +872,7 @@ impl AccountWithMetadataForTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -896,7 +896,7 @@ impl AccountWithMetadataForTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -920,7 +920,7 @@ impl AccountWithMetadataForTests {
fees: 0_u128,
active: false,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -944,7 +944,7 @@ impl AccountWithMetadataForTests {
fees: 0_u128,
active: false,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: AccountId::new([4; 32]),
@ -960,7 +960,7 @@ impl AccountWithMetadataForTests {
definition_id: IdForTests::token_a_definition_id(),
balance: BalanceForTests::vault_a_reserve_init(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: AccountId::new([4; 32]),
@ -976,7 +976,7 @@ impl AccountWithMetadataForTests {
definition_id: IdForTests::token_b_definition_id(),
balance: BalanceForTests::vault_b_reserve_init(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: AccountId::new([4; 32]),
@ -1000,7 +1000,7 @@ impl AccountWithMetadataForTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -1239,7 +1239,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_a_definition_id(),
balance: BalanceForExeTests::user_token_a_holding_init(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1251,7 +1251,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_b_definition_id(),
balance: BalanceForExeTests::user_token_b_holding_init(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1271,7 +1271,7 @@ impl AccountsForExeTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1284,7 +1284,7 @@ impl AccountsForExeTests {
total_supply: BalanceForExeTests::token_a_supply(),
metadata_id: None,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1297,7 +1297,7 @@ impl AccountsForExeTests {
total_supply: BalanceForExeTests::token_b_supply(),
metadata_id: None,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1310,7 +1310,7 @@ impl AccountsForExeTests {
total_supply: BalanceForExeTests::token_lp_supply(),
metadata_id: None,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1322,7 +1322,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_a_definition_id(),
balance: BalanceForExeTests::vault_a_balance_init(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1334,7 +1334,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_b_definition_id(),
balance: BalanceForExeTests::vault_b_balance_init(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1346,7 +1346,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_lp_definition_id(),
balance: BalanceForExeTests::user_token_lp_holding_init(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1358,7 +1358,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_a_definition_id(),
balance: BalanceForExeTests::vault_a_balance_swap_1(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1370,7 +1370,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_b_definition_id(),
balance: BalanceForExeTests::vault_b_balance_swap_1(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1390,7 +1390,7 @@ impl AccountsForExeTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1402,7 +1402,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_a_definition_id(),
balance: BalanceForExeTests::user_token_a_holding_swap_1(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1414,7 +1414,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_b_definition_id(),
balance: BalanceForExeTests::user_token_b_holding_swap_1(),
}),
nonce: 1,
nonce: 1_u128.into(),
}
}
@ -1426,7 +1426,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_a_definition_id(),
balance: BalanceForExeTests::vault_a_balance_swap_2(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1438,7 +1438,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_b_definition_id(),
balance: BalanceForExeTests::vault_b_balance_swap_2(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1458,7 +1458,7 @@ impl AccountsForExeTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1470,7 +1470,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_a_definition_id(),
balance: BalanceForExeTests::user_token_a_holding_swap_2(),
}),
nonce: 1,
nonce: 1_u128.into(),
}
}
@ -1482,7 +1482,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_b_definition_id(),
balance: BalanceForExeTests::user_token_b_holding_swap_2(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1494,7 +1494,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_a_definition_id(),
balance: BalanceForExeTests::vault_a_balance_add(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1506,7 +1506,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_b_definition_id(),
balance: BalanceForExeTests::vault_b_balance_add(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1526,7 +1526,7 @@ impl AccountsForExeTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1538,7 +1538,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_a_definition_id(),
balance: BalanceForExeTests::user_token_a_holding_add(),
}),
nonce: 1,
nonce: 1_u128.into(),
}
}
@ -1550,7 +1550,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_b_definition_id(),
balance: BalanceForExeTests::user_token_b_holding_add(),
}),
nonce: 1,
nonce: 1_u128.into(),
}
}
@ -1562,7 +1562,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_lp_definition_id(),
balance: BalanceForExeTests::user_token_lp_holding_add(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1575,7 +1575,7 @@ impl AccountsForExeTests {
total_supply: BalanceForExeTests::token_lp_supply_add(),
metadata_id: None,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1587,7 +1587,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_a_definition_id(),
balance: BalanceForExeTests::vault_a_balance_remove(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1599,7 +1599,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_b_definition_id(),
balance: BalanceForExeTests::vault_b_balance_remove(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1619,7 +1619,7 @@ impl AccountsForExeTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1631,7 +1631,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_a_definition_id(),
balance: BalanceForExeTests::user_token_a_holding_remove(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1643,7 +1643,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_b_definition_id(),
balance: BalanceForExeTests::user_token_b_holding_remove(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1655,7 +1655,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_lp_definition_id(),
balance: BalanceForExeTests::user_token_lp_holding_remove(),
}),
nonce: 1,
nonce: 1_u128.into(),
}
}
@ -1668,7 +1668,7 @@ impl AccountsForExeTests {
total_supply: BalanceForExeTests::token_lp_supply_remove(),
metadata_id: None,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1681,7 +1681,7 @@ impl AccountsForExeTests {
total_supply: 0,
metadata_id: None,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1693,7 +1693,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_a_definition_id(),
balance: 0,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1705,7 +1705,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_b_definition_id(),
balance: 0,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1725,7 +1725,7 @@ impl AccountsForExeTests {
fees: 0_u128,
active: false,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1737,7 +1737,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_a_definition_id(),
balance: BalanceForExeTests::user_token_a_holding_new_definition(),
}),
nonce: 1,
nonce: 1_u128.into(),
}
}
@ -1749,7 +1749,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_b_definition_id(),
balance: BalanceForExeTests::user_token_b_holding_new_definition(),
}),
nonce: 1,
nonce: 1_u128.into(),
}
}
@ -1761,7 +1761,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_lp_definition_id(),
balance: BalanceForExeTests::lp_supply_init(),
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1774,7 +1774,7 @@ impl AccountsForExeTests {
total_supply: BalanceForExeTests::lp_supply_init(),
metadata_id: None,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1794,7 +1794,7 @@ impl AccountsForExeTests {
fees: 0_u128,
active: true,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
@ -1806,7 +1806,7 @@ impl AccountsForExeTests {
definition_id: IdForExeTests::token_lp_definition_id(),
balance: 0,
}),
nonce: 0,
nonce: 0_u128.into(),
}
}
}
@ -2730,7 +2730,7 @@ fn simple_amm_remove() {
IdForExeTests::user_token_b_id(),
IdForExeTests::user_token_lp_id(),
],
vec![0],
vec![0_u128.into()],
instruction,
)
.unwrap();
@ -2808,7 +2808,7 @@ fn simple_amm_new_definition_inactive_initialized_pool_and_uninit_user_lp() {
IdForExeTests::user_token_b_id(),
IdForExeTests::user_token_lp_id(),
],
vec![0, 0],
vec![0_u128.into(), 0_u128.into()],
instruction,
)
.unwrap();
@ -2893,7 +2893,7 @@ fn simple_amm_new_definition_inactive_initialized_pool_init_user_lp() {
IdForExeTests::user_token_b_id(),
IdForExeTests::user_token_lp_id(),
],
vec![0, 0],
vec![0_u128.into(), 0_u128.into()],
instruction,
)
.unwrap();
@ -2966,7 +2966,7 @@ fn simple_amm_new_definition_uninitialized_pool() {
IdForExeTests::user_token_b_id(),
IdForExeTests::user_token_lp_id(),
],
vec![0, 0],
vec![0_u128.into(), 0_u128.into()],
instruction,
)
.unwrap();
@ -3029,7 +3029,7 @@ fn simple_amm_add() {
IdForExeTests::user_token_b_id(),
IdForExeTests::user_token_lp_id(),
],
vec![0, 0],
vec![0_u128.into(), 0_u128.into()],
instruction,
)
.unwrap();
@ -3090,7 +3090,7 @@ fn simple_amm_swap_1() {
IdForExeTests::user_token_a_id(),
IdForExeTests::user_token_b_id(),
],
vec![0],
vec![0_u128.into()],
instruction,
)
.unwrap();
@ -3141,7 +3141,7 @@ fn simple_amm_swap_2() {
IdForExeTests::user_token_a_id(),
IdForExeTests::user_token_b_id(),
],
vec![0],
vec![0_u128.into()],
instruction,
)
.unwrap();

View File

@ -37,7 +37,7 @@ impl AccountForTests {
total_supply: BalanceForTests::init_supply(),
metadata_id: None,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -54,7 +54,7 @@ impl AccountForTests {
total_supply: BalanceForTests::init_supply(),
metadata_id: None,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: false,
account_id: IdForTests::pool_definition_id(),
@ -70,7 +70,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id_diff(),
balance: BalanceForTests::holding_balance(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -86,7 +86,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::holding_balance(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -102,7 +102,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::holding_balance(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: false,
account_id: IdForTests::holding_id(),
@ -118,7 +118,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::init_supply(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: false,
account_id: IdForTests::holding_id(),
@ -135,7 +135,7 @@ impl AccountForTests {
total_supply: BalanceForTests::init_supply_burned(),
metadata_id: None,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -151,7 +151,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::holding_balance_burned(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: false,
account_id: IdForTests::holding_id(),
@ -175,7 +175,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::mint_success(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: false,
account_id: IdForTests::holding_id(),
@ -191,7 +191,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::holding_balance_mint(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -208,7 +208,7 @@ impl AccountForTests {
total_supply: BalanceForTests::init_supply_mint(),
metadata_id: None,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -224,7 +224,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::mint_overflow(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -241,7 +241,7 @@ impl AccountForTests {
printable_supply: BalanceForTests::printable_copies(),
metadata_id: AccountId::new([0; 32]),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -265,7 +265,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::init_supply(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -282,7 +282,7 @@ impl AccountForTests {
total_supply: BalanceForTests::init_supply(),
metadata_id: None,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::pool_definition_id(),
@ -298,7 +298,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::init_supply(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -314,7 +314,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::init_supply(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::holding_id_2(),
@ -330,7 +330,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::recipient_post_transfer(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::holding_id_2(),
@ -346,7 +346,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
balance: BalanceForTests::sender_post_transfer(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -362,7 +362,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
print_balance: BalanceForTests::printable_copies(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -378,7 +378,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
print_balance: 1,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -394,7 +394,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
print_balance: BalanceForTests::printable_copies() - 1,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::holding_id(),
@ -410,7 +410,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
owned: true,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: false,
account_id: IdForTests::holding_id(),
@ -426,7 +426,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
print_balance: BalanceForTests::printable_copies(),
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::holding_id_2(),
@ -442,7 +442,7 @@ impl AccountForTests {
definition_id: IdForTests::pool_definition_id(),
print_balance: 0,
}),
nonce: 0,
nonce: 0_u128.into(),
},
is_authorized: true,
account_id: IdForTests::holding_id(),

View File

@ -233,7 +233,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

@ -20,50 +20,50 @@
"indexer_rpc_url": "ws://localhost:8779",
"initial_accounts": [
{
"account_id": "6iArKUXxhUJqS7kCaPNhwMWt3ro71PDyBj7jwAyE2VQV",
"account_id": "CbgR6tj5kWx5oziiFptM7jMvrQeYY3Mzaao6ciuhSr2r",
"balance": 10000
},
{
"account_id": "7wHg9sbJwc6h3NP1S9bekfAzB8CHifEcxKswCKUt3YQo",
"account_id": "2RHZhw9h534Zr3eq2RGhQete2Hh667foECzXPmSkGni2",
"balance": 20000
}
],
"initial_commitments": [
{
"npk":[
177,
64,
1,
"npk": [
139,
19,
158,
11,
87,
38,
254,
159,
155,
231,
165,
1,
94,
64,
137,
243,
76,
249,
101,
251,
129,
33,
101,
189,
30,
42,
11,
191,
34,
103,
186,
227,
230
] ,
85,
206,
132,
228,
220,
114,
145,
89,
113,
156,
238,
142,
242,
74,
182,
91,
43,
100,
6,
190,
31,
15,
31,
88,
96,
204
],
"account": {
"program_owner": [
0,
@ -82,38 +82,38 @@
},
{
"npk": [
32,
67,
72,
164,
106,
53,
66,
239,
141,
15,
52,
230,
136,
177,
2,
236,
207,
243,
173,
134,
135,
210,
143,
87,
232,
33,
223,
54,
226,
10,
71,
215,
128,
194,
120,
113,
224,
4,
165
254,
143,
172,
24,
244,
243,
208,
65,
112,
118,
70,
217,
240,
69,
100,
129,
3,
121,
25,
213,
132,
42,
45
],
"account": {
"program_owner": [
@ -166,4 +166,4 @@
37,
37
]
}
}

View File

@ -20,49 +20,49 @@
"indexer_rpc_url": "ws://localhost:8779",
"initial_accounts": [
{
"account_id": "6iArKUXxhUJqS7kCaPNhwMWt3ro71PDyBj7jwAyE2VQV",
"account_id": "CbgR6tj5kWx5oziiFptM7jMvrQeYY3Mzaao6ciuhSr2r",
"balance": 10000
},
{
"account_id": "7wHg9sbJwc6h3NP1S9bekfAzB8CHifEcxKswCKUt3YQo",
"account_id": "2RHZhw9h534Zr3eq2RGhQete2Hh667foECzXPmSkGni2",
"balance": 20000
}
],
"initial_commitments": [
{
"npk": [
63,
202,
178,
139,
19,
158,
11,
155,
231,
183,
82,
237,
212,
216,
221,
215,
255,
153,
101,
177,
161,
254,
210,
128,
122,
54,
190,
230,
151,
183,
64,
225,
229,
113,
1,
85,
206,
132,
228,
97
220,
114,
145,
89,
113,
156,
238,
142,
242,
74,
182,
91,
43,
100,
6,
190,
31,
15,
31,
88,
96,
204
],
"account": {
"program_owner": [
@ -82,38 +82,38 @@
},
{
"npk": [
192,
251,
166,
243,
167,
236,
84,
249,
35,
136,
130,
173,
134,
33,
223,
54,
226,
10,
71,
215,
254,
143,
172,
219,
225,
161,
139,
229,
89,
243,
125,
194,
213,
209,
30,
23,
174,
100,
24,
244,
124,
74,
140,
47
243,
208,
65,
112,
118,
70,
217,
240,
69,
100,
129,
3,
121,
25,
213,
132,
42,
45
],
"account": {
"program_owner": [

View File

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

View File

@ -126,7 +126,7 @@ pub fn initial_priv_accounts_private_keys() -> Vec<PrivateAccountPrivateInitialD
nullifier_secret_key: NSK_PRIV_ACC_A,
viewing_secret_key: VSK_PRIV_ACC_A,
},
nullifer_public_key: NullifierPublicKey(NPK_PRIV_ACC_A),
nullifier_public_key: NullifierPublicKey(NPK_PRIV_ACC_A),
viewing_public_key: Secp256k1Point(VPK_PRIV_ACC_A.to_vec()),
};
@ -136,28 +136,28 @@ pub fn initial_priv_accounts_private_keys() -> Vec<PrivateAccountPrivateInitialD
nullifier_secret_key: NSK_PRIV_ACC_B,
viewing_secret_key: VSK_PRIV_ACC_B,
},
nullifer_public_key: NullifierPublicKey(NPK_PRIV_ACC_B),
nullifier_public_key: NullifierPublicKey(NPK_PRIV_ACC_B),
viewing_public_key: Secp256k1Point(VPK_PRIV_ACC_B.to_vec()),
};
vec![
PrivateAccountPrivateInitialData {
account_id: AccountId::from(&key_chain_1.nullifer_public_key),
account_id: AccountId::from(&key_chain_1.nullifier_public_key),
account: Account {
program_owner: DEFAULT_PROGRAM_OWNER,
balance: PRIV_ACC_A_INITIAL_BALANCE,
data: Data::default(),
nonce: 0,
nonce: 0.into(),
},
key_chain: key_chain_1,
},
PrivateAccountPrivateInitialData {
account_id: AccountId::from(&key_chain_2.nullifer_public_key),
account_id: AccountId::from(&key_chain_2.nullifier_public_key),
account: Account {
program_owner: DEFAULT_PROGRAM_OWNER,
balance: PRIV_ACC_B_INITIAL_BALANCE,
data: Data::default(),
nonce: 0,
nonce: 0.into(),
},
key_chain: key_chain_2,
},
@ -169,7 +169,7 @@ pub fn initial_commitments() -> Vec<PrivateAccountPublicInitialData> {
initial_priv_accounts_private_keys()
.into_iter()
.map(|data| PrivateAccountPublicInitialData {
npk: data.key_chain.nullifer_public_key.clone(),
npk: data.key_chain.nullifier_public_key.clone(),
account: data.account,
})
.collect()
@ -302,7 +302,7 @@ mod tests {
.key_chain
.private_key_holder
.generate_nullifier_public_key(),
init_private_accs_keys[0].key_chain.nullifer_public_key
init_private_accs_keys[0].key_chain.nullifier_public_key
);
assert_eq!(
init_private_accs_keys[0]
@ -339,7 +339,7 @@ mod tests {
.key_chain
.private_key_holder
.generate_nullifier_public_key(),
init_private_accs_keys[1].key_chain.nullifer_public_key
init_private_accs_keys[1].key_chain.nullifier_public_key
);
assert_eq!(
init_private_accs_keys[1]
@ -359,11 +359,11 @@ mod tests {
);
assert_eq!(
init_private_accs_keys[0].key_chain.nullifer_public_key,
init_private_accs_keys[0].key_chain.nullifier_public_key,
init_comms[0].npk
);
assert_eq!(
init_private_accs_keys[1].key_chain.nullifer_public_key,
init_private_accs_keys[1].key_chain.nullifier_public_key,
init_comms[1].npk
);
@ -375,7 +375,7 @@ mod tests {
program_owner: DEFAULT_PROGRAM_OWNER,
balance: PRIV_ACC_A_INITIAL_BALANCE,
data: Data::default(),
nonce: 0,
nonce: 0.into(),
},
}
);
@ -388,7 +388,7 @@ mod tests {
program_owner: DEFAULT_PROGRAM_OWNER,
balance: PRIV_ACC_B_INITIAL_BALANCE,
data: Data::default(),
nonce: 0,
nonce: 0.into(),
},
}
);

View File

@ -123,7 +123,7 @@ pub unsafe extern "C" fn wallet_ffi_get_private_account_keys(
};
// NPK is a 32-byte array
let npk_bytes = key_chain.nullifer_public_key.0;
let npk_bytes = key_chain.nullifier_public_key.0;
// VPK is a compressed secp256k1 point (33 bytes)
let vpk_bytes = key_chain.viewing_public_key.to_bytes();

View File

@ -222,7 +222,7 @@ impl From<nssa::Account> for FfiAccount {
balance: value.balance.into(),
data,
data_len,
nonce: value.nonce.into(),
nonce: value.nonce.0.into(),
}
}
}
@ -244,7 +244,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

@ -1,147 +1,479 @@
{
"override_rust_log": null,
"sequencer_addr": "http://127.0.0.1:3040",
"seq_poll_timeout": "30s",
"seq_tx_poll_max_blocks": 15,
"seq_poll_max_retries": 10,
"seq_block_poll_max_amount": 100,
"initial_accounts": [
{
"Public": {
"account_id": "6iArKUXxhUJqS7kCaPNhwMWt3ro71PDyBj7jwAyE2VQV",
"pub_sign_key": [
16,
162,
106,
154,
236,
125,
52,
184,
35,
100,
238,
174,
69,
197,
41,
77,
187,
10,
118,
75,
0,
11,
148,
238,
185,
181,
133,
17,
220,
72,
124,
77
]
}
},
{
"Public": {
"account_id": "7wHg9sbJwc6h3NP1S9bekfAzB8CHifEcxKswCKUt3YQo",
"pub_sign_key": [
113,
121,
64,
177,
204,
85,
229,
214,
178,
6,
109,
191,
29,
154,
63,
38,
242,
18,
244,
219,
8,
208,
35,
136,
23,
127,
207,
237,
216,
169,
190,
27
]
}
},
"override_rust_log": null,
"sequencer_addr": "http://127.0.0.1:3040",
"seq_poll_timeout": "30s",
"seq_tx_poll_max_blocks": 15,
"seq_poll_max_retries": 10,
"seq_block_poll_max_amount": 100,
"initial_accounts": [
{
"Private": {
"account_id": "2ECgkFTaXzwjJBXR7ZKmXYQtpHbvTTHK9Auma4NL9AUo",
"account": {
"program_owner": [
0,
0,
0,
0,
0,
0,
0,
0
],
"balance": 10000,
"data": [],
"nonce": 0
"Public": {
"account_id": "CbgR6tj5kWx5oziiFptM7jMvrQeYY3Mzaao6ciuhSr2r",
"pub_sign_key": [
127,
39,
48,
152,
242,
91,
113,
230,
192,
5,
169,
81,
159,
38,
120,
218,
141,
28,
127,
1,
246,
162,
119,
120,
226,
217,
148,
138,
189,
249,
1,
251
]
}
},
"key_chain": {
"secret_spending_key": [112, 17, 152, 192, 217, 201, 142, 92, 111, 68, 85, 222, 107, 73, 78, 196, 118, 226, 37, 17, 185, 177, 149, 182, 9, 85, 187, 152, 163, 144, 68, 121],
"private_key_holder": {
"nullifier_secret_key": [52, 33, 235, 245, 42, 132, 163, 182, 114, 56, 144, 187, 147, 23, 184, 227, 128, 12, 180, 142, 217, 110, 188, 177, 155, 141, 23, 127, 216, 185, 33, 126],
"viewing_secret_key": [44, 81, 165, 166, 34, 188, 192, 240, 40, 9, 83, 189, 215, 184, 246, 154, 247, 227, 155, 16, 121, 238, 4, 245, 63, 135, 192, 213, 222, 247, 120, 86]
},
"nullifer_public_key": [13, 25, 40, 5, 198, 248, 210, 248, 237, 121, 124, 145, 186, 142, 253, 216, 236, 69, 193, 32, 166, 167, 49, 133, 172, 111, 159, 46, 84, 17, 157, 23],
"viewing_public_key": [3, 43, 116, 165, 161, 27, 150, 158, 175, 198, 215, 27, 121, 126, 158, 224, 249, 92, 168, 163, 173, 115, 120, 122, 89, 173, 133, 94, 39, 238, 62, 52, 193]
}
}
},
{
"Private": {
"account_id": "E8HwiTyQe4H9HK7icTvn95HQMnzx49mP9A2ddtMLpNaN",
"account": {
"program_owner": [
0,
0,
0,
0,
0,
0,
0,
0
],
"balance": 20000,
"data": [],
"nonce": 0
{
"Public": {
"account_id": "2RHZhw9h534Zr3eq2RGhQete2Hh667foECzXPmSkGni2",
"pub_sign_key": [
244,
52,
248,
116,
23,
32,
1,
69,
134,
174,
67,
53,
109,
42,
236,
98,
87,
218,
8,
98,
34,
246,
4,
221,
183,
93,
105,
115,
59,
134,
252,
76
]
}
},
"key_chain": {
"secret_spending_key": [48, 175, 124, 10, 230, 240, 166, 14, 249, 254, 157, 226, 208, 124, 122, 177, 203, 139, 192, 180, 43, 120, 55, 151, 50, 21, 113, 22, 254, 83, 148, 56],
"private_key_holder": {
"nullifier_secret_key": [99, 82, 190, 140, 234, 10, 61, 163, 15, 211, 179, 54, 70, 166, 87, 5, 182, 68, 117, 244, 217, 23, 99, 9, 4, 177, 230, 125, 109, 91, 160, 30],
"viewing_secret_key": [205, 32, 76, 251, 255, 236, 96, 119, 61, 111, 65, 100, 75, 218, 12, 22, 17, 170, 55, 226, 21, 154, 161, 34, 208, 74, 27, 1, 119, 13, 88, 128]
},
"nullifer_public_key": [32, 67, 72, 164, 106, 53, 66, 239, 141, 15, 52, 230, 136, 177, 2, 236, 207, 243, 134, 135, 210, 143, 87, 232, 215, 128, 194, 120, 113, 224, 4, 165],
"viewing_public_key": [2, 79, 110, 46, 203, 29, 206, 205, 18, 86, 27, 189, 104, 103, 113, 181, 110, 53, 78, 172, 11, 171, 190, 18, 126, 214, 81, 77, 192, 154, 58, 195, 238]
{
"Private": {
"account_id": "HWkW5qd4XK3me6sCAb4bfPj462k33DjtKtEcYpuzNwB",
"account": {
"program_owner": [
0,
0,
0,
0,
0,
0,
0,
0
],
"balance": 10000,
"data": [],
"nonce": 0
},
"key_chain": {
"secret_spending_key": [
14,
202,
241,
109,
32,
181,
152,
140,
76,
153,
108,
57,
77,
192,
181,
97,
108,
144,
122,
45,
219,
5,
203,
193,
82,
123,
83,
34,
250,
214,
137,
63
],
"private_key_holder": {
"nullifier_secret_key": [
174,
56,
101,
30,
248,
249,
100,
0,
122,
199,
209,
246,
58,
163,
223,
146,
59,
143,
78,
95,
41,
186,
106,
187,
53,
63,
75,
244,
233,
185,
110,
199
],
"viewing_secret_key": [
251,
85,
223,
73,
142,
127,
134,
132,
185,
210,
100,
103,
198,
108,
229,
80,
176,
211,
249,
114,
110,
7,
225,
17,
7,
69,
204,
32,
47,
242,
103,
247
]
},
"nullifier_public_key": [
139,
19,
158,
11,
155,
231,
85,
206,
132,
228,
220,
114,
145,
89,
113,
156,
238,
142,
242,
74,
182,
91,
43,
100,
6,
190,
31,
15,
31,
88,
96,
204
],
"viewing_public_key": [
3,
136,
153,
50,
191,
184,
135,
36,
29,
107,
57,
9,
218,
135,
249,
213,
118,
215,
118,
173,
30,
137,
116,
77,
17,
86,
62,
154,
31,
173,
19,
167,
211
]
}
}
},
{
"Private": {
"account_id": "HUpbRQ1vEcZv5y6TDYv9tpt1VA64ji2v4RDLJfK2rpZn",
"account": {
"program_owner": [
0,
0,
0,
0,
0,
0,
0,
0
],
"balance": 20000,
"data": [],
"nonce": 0
},
"key_chain": {
"secret_spending_key": [
32,
162,
244,
221,
2,
133,
168,
250,
240,
52,
92,
187,
157,
116,
249,
203,
143,
194,
214,
112,
115,
142,
153,
78,
241,
173,
103,
242,
192,
196,
29,
133
],
"private_key_holder": {
"nullifier_secret_key": [
188,
235,
121,
54,
131,
206,
7,
215,
94,
231,
102,
22,
12,
27,
253,
161,
248,
206,
41,
160,
206,
149,
5,
217,
127,
235,
154,
230,
198,
232,
102,
31
],
"viewing_secret_key": [
89,
116,
140,
122,
211,
179,
190,
229,
18,
94,
56,
235,
48,
99,
104,
228,
111,
72,
231,
18,
247,
97,
110,
60,
238,
138,
0,
25,
92,
44,
30,
145
]
},
"nullifier_public_key": [
173,
134,
33,
223,
54,
226,
10,
71,
215,
254,
143,
172,
24,
244,
243,
208,
65,
112,
118,
70,
217,
240,
69,
100,
129,
3,
121,
25,
213,
132,
42,
45
],
"viewing_public_key": [
2,
43,
42,
253,
112,
83,
195,
164,
26,
141,
92,
28,
224,
120,
155,
119,
225,
1,
45,
42,
245,
172,
134,
136,
52,
183,
170,
96,
115,
212,
114,
120,
37
]
}
}
}
}
}
],
"basic_auth": null
],
"basic_auth": null
}

View File

@ -145,7 +145,7 @@ impl WalletSubcommand for NewSubcommand {
println!(
"Generated new account with account_id Private/{account_id} at path {chain_index}",
);
println!("With npk {}", hex::encode(key.nullifer_public_key.0));
println!("With npk {}", hex::encode(key.nullifier_public_key.0));
println!(
"With vpk {}",
hex::encode(key.viewing_public_key.to_bytes())
@ -208,7 +208,7 @@ impl WalletSubcommand for AccountSubcommand {
.get_private_account(account_id)
.context("Private account not found in storage")?;
println!("npk {}", hex::encode(key.nullifer_public_key.0));
println!("npk {}", hex::encode(key.nullifier_public_key.0));
println!("vpk {}", hex::encode(key.viewing_public_key.to_bytes()));
}
}

View File

@ -45,7 +45,7 @@ impl From<Account> for HumanReadableAccount {
balance: account.balance,
program_owner,
data,
nonce: account.nonce,
nonce: account.nonce.0,
}
}
}
@ -146,12 +146,16 @@ pub fn produce_data_for_storage(
}
}
#[expect(dead_code, reason = "Maybe used later")]
pub(crate) fn produce_random_nonces(size: usize) -> Vec<Nonce> {
let mut result = vec![[0; 16]; size];
for bytes in &mut result {
OsRng.fill_bytes(bytes);
}
result.into_iter().map(Nonce::from_le_bytes).collect()
result
.into_iter()
.map(|x| Nonce(u128::from_le_bytes(x)))
.collect()
}
pub(crate) fn parse_addr_with_privacy_prefix(

View File

@ -32,7 +32,7 @@ use tokio::io::AsyncWriteExt as _;
use crate::{
config::{PersistentStorage, WalletConfigOverrides},
helperfunctions::{produce_data_for_storage, produce_random_nonces},
helperfunctions::produce_data_for_storage,
poller::TxPoller,
};
@ -265,7 +265,7 @@ impl WalletCore {
#[must_use]
pub fn get_private_account_commitment(&self, account_id: AccountId) -> Option<Commitment> {
let (keys, account) = self.storage.user_data.get_private_account(account_id)?;
Some(Commitment::new(&keys.nullifer_public_key, account))
Some(Commitment::new(&keys.nullifier_public_key, account))
}
/// Poll transactions.
@ -364,7 +364,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))
@ -470,7 +469,7 @@ impl WalletCore {
let affected_accounts = private_account_key_chains
.flat_map(|(acc_account_id, key_chain, index)| {
let view_tag = EncryptedAccountData::compute_view_tag(
&key_chain.nullifer_public_key,
&key_chain.nullifier_public_key,
&key_chain.viewing_public_key,
);

View File

@ -214,7 +214,7 @@ async fn private_acc_preparation(
let nsk = from_keys.private_key_holder.nullifier_secret_key;
let from_npk = from_keys.nullifer_public_key;
let from_npk = from_keys.nullifier_public_key;
let from_vpk = from_keys.viewing_public_key;
// TODO: Remove this unwrap, error types must be compatible

View File

@ -80,7 +80,10 @@ 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 +190,10 @@ 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 +280,10 @@ 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 +365,10 @@ 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

@ -29,8 +29,16 @@ 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();
let message = 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);
@ -61,7 +69,16 @@ 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

@ -141,7 +141,10 @@ 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();
@ -342,7 +345,10 @@ 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");
@ -472,7 +478,10 @@ 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();

View File

@ -39,7 +39,7 @@ impl WalletCore {
let mut nsk = None;
let mut proof = None;
let from_npk = from_keys.nullifer_public_key;
let from_npk = from_keys.nullifier_public_key;
let from_vpk = from_keys.viewing_public_key;
let sender_commitment = Commitment::new(&from_npk, &from_acc);