From ba20728f400d69c02a045aeb53ebff28fccc965f Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Thu, 16 Oct 2025 16:19:03 -0300 Subject: [PATCH] update version tags in domain separator --- .../debug/sequencer/sequencer_config.json | 4 ++-- .../configs/debug/wallet/wallet_config.json | 8 ++++---- integration_tests/src/lib.rs | 8 ++++---- nssa/core/src/encryption/mod.rs | 2 +- nssa/core/src/nullifier.rs | 18 +++++++++--------- .../encoding/privacy_preserving_transaction.rs | 4 ++-- .../encoding/program_deployment_transaction.rs | 9 +++------ nssa/src/encoding/public_transaction.rs | 4 ++-- .../privacy_preserving_transaction/message.rs | 6 +++--- nssa/src/program.rs | 5 +++++ nssa/src/public_transaction/transaction.rs | 8 ++++---- nssa/src/signature/public_key.rs | 2 +- sequencer_core/src/lib.rs | 8 ++++---- sequencer_rpc/src/process.rs | 12 ++++++------ .../configs/debug/sequencer_config.json | 4 ++-- wallet/src/chain_storage/mod.rs | 4 ++-- 16 files changed, 54 insertions(+), 52 deletions(-) diff --git a/integration_tests/configs/debug/sequencer/sequencer_config.json b/integration_tests/configs/debug/sequencer/sequencer_config.json index 87624ae9..2a2037de 100644 --- a/integration_tests/configs/debug/sequencer/sequencer_config.json +++ b/integration_tests/configs/debug/sequencer/sequencer_config.json @@ -8,11 +8,11 @@ "port": 3040, "initial_accounts": [ { - "addr": "0eee24287296ba55278f1e5403be014754866366388730303c2889be17ada065", + "addr": "d07ad2e84b27fa00c262f0a1eea0ff35ca0973547e6a106f72f193c2dc838b44", "balance": 10000 }, { - "addr": "9e3d8e654d440e95293aa2dceceb137899a59535e952f747068e7a0ee30965f2", + "addr": "e7ae77c5ef1a05999344af499fc78a1705398d62ed06cf2e1479f6def89a39bc", "balance": 20000 } ], diff --git a/integration_tests/configs/debug/wallet/wallet_config.json b/integration_tests/configs/debug/wallet/wallet_config.json index 09209f64..0081da6e 100644 --- a/integration_tests/configs/debug/wallet/wallet_config.json +++ b/integration_tests/configs/debug/wallet/wallet_config.json @@ -9,7 +9,7 @@ "initial_accounts": [ { "Public": { - "address": "0eee24287296ba55278f1e5403be014754866366388730303c2889be17ada065", + "address": "d07ad2e84b27fa00c262f0a1eea0ff35ca0973547e6a106f72f193c2dc838b44", "pub_sign_key": [ 1, 1, @@ -48,7 +48,7 @@ }, { "Public": { - "address": "9e3d8e654d440e95293aa2dceceb137899a59535e952f747068e7a0ee30965f2", + "address": "e7ae77c5ef1a05999344af499fc78a1705398d62ed06cf2e1479f6def89a39bc", "pub_sign_key": [ 2, 2, @@ -87,7 +87,7 @@ }, { "Private": { - "address": "9cb6b0035320266e430eac9d96745769e7efcf30d2b9cc21ff000b3f873dc2a8", + "address": "d360d6b5763f71ac6af56253687fd7d556d5c6c64312e53c0b92ef039a4375df", "account": { "program_owner": [ 0, @@ -316,7 +316,7 @@ }, { "Private": { - "address": "a55f4f98d2f265c91d8a9868564242d8070b9bf7180a29363f52eb76988636fd", + "address": "f27087ffc29b99035303697dcf6c8e323b1847d4261e6afd49e0d71c6dfa31ea", "account": { "program_owner": [ 0, diff --git a/integration_tests/src/lib.rs b/integration_tests/src/lib.rs index 85cb7a15..fa22250e 100644 --- a/integration_tests/src/lib.rs +++ b/integration_tests/src/lib.rs @@ -32,13 +32,13 @@ struct Args { test_name: String, } -pub const ACC_SENDER: &str = "0eee24287296ba55278f1e5403be014754866366388730303c2889be17ada065"; -pub const ACC_RECEIVER: &str = "9e3d8e654d440e95293aa2dceceb137899a59535e952f747068e7a0ee30965f2"; +pub const ACC_SENDER: &str = "d07ad2e84b27fa00c262f0a1eea0ff35ca0973547e6a106f72f193c2dc838b44"; +pub const ACC_RECEIVER: &str = "e7ae77c5ef1a05999344af499fc78a1705398d62ed06cf2e1479f6def89a39bc"; pub const ACC_SENDER_PRIVATE: &str = - "9cb6b0035320266e430eac9d96745769e7efcf30d2b9cc21ff000b3f873dc2a8"; + "d360d6b5763f71ac6af56253687fd7d556d5c6c64312e53c0b92ef039a4375df"; pub const ACC_RECEIVER_PRIVATE: &str = - "a55f4f98d2f265c91d8a9868564242d8070b9bf7180a29363f52eb76988636fd"; + "f27087ffc29b99035303697dcf6c8e323b1847d4261e6afd49e0d71c6dfa31ea"; pub const TIME_TO_WAIT_FOR_BLOCK_SECONDS: u64 = 12; diff --git a/nssa/core/src/encryption/mod.rs b/nssa/core/src/encryption/mod.rs index f2dc18ec..280451bb 100644 --- a/nssa/core/src/encryption/mod.rs +++ b/nssa/core/src/encryption/mod.rs @@ -54,7 +54,7 @@ impl EncryptionScheme { ) -> [u8; 32] { let mut bytes = Vec::new(); - bytes.extend_from_slice(b"NSSA/v0.1/KDF-SHA256"); + bytes.extend_from_slice(b"NSSA/v0.2/KDF-SHA256/"); bytes.extend_from_slice(&shared_secret.0); bytes.extend_from_slice(&commitment.to_byte_array()); bytes.extend_from_slice(&output_index.to_le_bytes()); diff --git a/nssa/core/src/nullifier.rs b/nssa/core/src/nullifier.rs index 5e3e208d..a1bc38c8 100644 --- a/nssa/core/src/nullifier.rs +++ b/nssa/core/src/nullifier.rs @@ -9,7 +9,7 @@ pub struct NullifierPublicKey(pub [u8; 32]); impl From<&NullifierPublicKey> for AccountId { fn from(value: &NullifierPublicKey) -> Self { - const PRIVATE_ACCOUNT_ID_PREFIX: &[u8; 32] = b"/NSSA/v0.1/AccountId/Private/\x00\x00\x00"; + const PRIVATE_ACCOUNT_ID_PREFIX: &[u8; 32] = b"/NSSA/v0.2/AccountId/Private/\x00\x00\x00"; let mut bytes = [0; 64]; bytes[0..32].copy_from_slice(PRIVATE_ACCOUNT_ID_PREFIX); @@ -46,7 +46,7 @@ pub struct Nullifier(pub(super) [u8; 32]); impl Nullifier { pub fn for_account_update(commitment: &Commitment, nsk: &NullifierSecretKey) -> Self { - const UPDATE_PREFIX: &[u8; 32] = b"/NSSA/v0.1/Nullifier/Update/\x00\x00\x00\x00"; + const UPDATE_PREFIX: &[u8; 32] = b"/NSSA/v0.2/Nullifier/Update/\x00\x00\x00\x00"; let mut bytes = UPDATE_PREFIX.to_vec(); bytes.extend_from_slice(&commitment.to_byte_array()); bytes.extend_from_slice(nsk); @@ -54,7 +54,7 @@ impl Nullifier { } pub fn for_account_initialization(npk: &NullifierPublicKey) -> Self { - const INIT_PREFIX: &[u8; 32] = b"/NSSA/v0.1/Nullifier/Initialize/"; + const INIT_PREFIX: &[u8; 32] = b"/NSSA/v0.2/Nullifier/Initialize/"; let mut bytes = INIT_PREFIX.to_vec(); bytes.extend_from_slice(&npk.to_byte_array()); Self(Impl::hash_bytes(&bytes).as_bytes().try_into().unwrap()) @@ -70,8 +70,8 @@ mod tests { let commitment = Commitment((0..32u8).collect::>().try_into().unwrap()); let nsk = [0x42; 32]; let expected_nullifier = Nullifier([ - 235, 128, 185, 229, 74, 74, 83, 13, 165, 48, 239, 24, 48, 101, 71, 251, 253, 92, 88, - 201, 103, 43, 250, 135, 193, 54, 175, 82, 245, 171, 90, 135, + 148, 243, 116, 209, 140, 231, 211, 61, 35, 62, 114, 110, 143, 224, 82, 201, 221, 34, + 53, 80, 185, 48, 174, 28, 203, 43, 94, 187, 85, 199, 115, 81, ]); let nullifier = Nullifier::for_account_update(&commitment, &nsk); assert_eq!(nullifier, expected_nullifier); @@ -84,8 +84,8 @@ mod tests { 255, 29, 105, 42, 186, 43, 11, 157, 168, 132, 225, 17, 163, ]); let expected_nullifier = Nullifier([ - 96, 99, 33, 1, 116, 84, 169, 18, 85, 201, 17, 243, 123, 240, 242, 34, 116, 233, 92, - 203, 247, 92, 161, 162, 135, 66, 127, 108, 230, 149, 105, 157, + 1, 6, 59, 168, 16, 146, 65, 252, 255, 91, 48, 85, 116, 189, 110, 218, 110, 136, 163, + 193, 245, 103, 51, 27, 235, 170, 215, 115, 97, 144, 36, 238, ]); let nullifier = Nullifier::for_account_initialization(&npk); assert_eq!(nullifier, expected_nullifier); @@ -113,8 +113,8 @@ mod tests { ]; let npk = NullifierPublicKey::from(&nsk); let expected_account_id = AccountId::new([ - 69, 160, 50, 67, 12, 56, 150, 116, 62, 145, 17, 161, 17, 45, 24, 53, 33, 167, 83, 178, - 47, 114, 111, 233, 251, 30, 54, 244, 184, 22, 100, 236, + 18, 153, 225, 78, 35, 214, 212, 205, 152, 83, 18, 246, 69, 41, 20, 217, 85, 1, 108, 7, + 87, 133, 181, 53, 247, 221, 174, 12, 112, 194, 34, 121, ]); let account_id = AccountId::from(&npk); diff --git a/nssa/src/encoding/privacy_preserving_transaction.rs b/nssa/src/encoding/privacy_preserving_transaction.rs index 2e5ea145..e08584b9 100644 --- a/nssa/src/encoding/privacy_preserving_transaction.rs +++ b/nssa/src/encoding/privacy_preserving_transaction.rs @@ -16,8 +16,8 @@ use crate::{ }, }; -const MESSAGE_ENCODING_PREFIX_LEN: usize = 22; -const MESSAGE_ENCODING_PREFIX: &[u8; MESSAGE_ENCODING_PREFIX_LEN] = b"\x01/NSSA/v0.1/TxMessage/"; +const MESSAGE_ENCODING_PREFIX_LEN: usize = 32; +const MESSAGE_ENCODING_PREFIX: &[u8; MESSAGE_ENCODING_PREFIX_LEN] = b"/NSSA/v0.2/TxMessage/Private/\x00\x00\x00"; impl EncryptedAccountData { pub fn to_bytes(&self) -> Vec { diff --git a/nssa/src/encoding/program_deployment_transaction.rs b/nssa/src/encoding/program_deployment_transaction.rs index 70bd4eaa..bb4452d7 100644 --- a/nssa/src/encoding/program_deployment_transaction.rs +++ b/nssa/src/encoding/program_deployment_transaction.rs @@ -2,15 +2,12 @@ use std::io::{Cursor, Read}; -use nssa_core::program::ProgramId; - use crate::{ - Address, ProgramDeploymentTransaction, PublicKey, PublicTransaction, Signature, - error::NssaError, program_deployment_transaction::Message, + ProgramDeploymentTransaction, error::NssaError, program_deployment_transaction::Message, }; -const MESSAGE_ENCODING_PREFIX_LEN: usize = 22; -const MESSAGE_ENCODING_PREFIX: &[u8; MESSAGE_ENCODING_PREFIX_LEN] = b"\x02/NSSA/v0.1/TxMessage/"; +const MESSAGE_ENCODING_PREFIX_LEN: usize = 32; +const MESSAGE_ENCODING_PREFIX: &[u8; MESSAGE_ENCODING_PREFIX_LEN] = b"/NSSA/v0.2/TxMessage/Program/\x00\x00\x00"; impl Message { /// Serializes a `Message` into bytes in the following layout: diff --git a/nssa/src/encoding/public_transaction.rs b/nssa/src/encoding/public_transaction.rs index e8890de9..31162575 100644 --- a/nssa/src/encoding/public_transaction.rs +++ b/nssa/src/encoding/public_transaction.rs @@ -10,8 +10,8 @@ use crate::{ public_transaction::{Message, WitnessSet}, }; -const MESSAGE_ENCODING_PREFIX_LEN: usize = 22; -const MESSAGE_ENCODING_PREFIX: &[u8; MESSAGE_ENCODING_PREFIX_LEN] = b"\x00/NSSA/v0.1/TxMessage/"; +const MESSAGE_ENCODING_PREFIX_LEN: usize = 32; +const MESSAGE_ENCODING_PREFIX: &[u8; MESSAGE_ENCODING_PREFIX_LEN] = b"/NSSA/v0.2/TxMessage/Public/\x00\x00\x00\x00"; impl Message { /// Serializes a `Message` into bytes in the following layout: diff --git a/nssa/src/privacy_preserving_transaction/message.rs b/nssa/src/privacy_preserving_transaction/message.rs index 0bcb02d9..59118382 100644 --- a/nssa/src/privacy_preserving_transaction/message.rs +++ b/nssa/src/privacy_preserving_transaction/message.rs @@ -31,10 +31,10 @@ impl EncryptedAccountData { } } - /// Computes the tag as the first byte of SHA256("/NSSA/v0.1/ViewTag" || Npk || Ivk) + /// Computes the tag as the first byte of SHA256("/NSSA/v0.2/ViewTag/" || Npk || Ivk) pub fn compute_view_tag(npk: NullifierPublicKey, ivk: IncomingViewingPublicKey) -> ViewTag { let mut hasher = Sha256::new(); - hasher.update(b"/NSSA/v0.1/ViewTag"); + hasher.update(b"/NSSA/v0.2/ViewTag/"); hasher.update(npk.to_byte_array()); hasher.update(ivk.to_bytes()); let digest: [u8; 32] = hasher.finalize().into(); @@ -166,7 +166,7 @@ pub mod tests { let expected_view_tag = { let mut hasher = Sha256::new(); - hasher.update(b"/NSSA/v0.1/ViewTag"); + hasher.update(b"/NSSA/v0.2/ViewTag/"); hasher.update(npk.to_byte_array()); hasher.update(ivk.to_bytes()); let digest: [u8; 32] = hasher.finalize().into(); diff --git a/nssa/src/program.rs b/nssa/src/program.rs index 17f6d2b5..4efd2744 100644 --- a/nssa/src/program.rs +++ b/nssa/src/program.rs @@ -8,6 +8,10 @@ use serde::Serialize; use crate::error::NssaError; +/// Maximum number of cycles for a public execution. +/// TODO: Make this variable when fees are implemented +const MAX_NUM_CYCLES_PUBLIC_EXECUTION: u64 = 1024 * 1024 * 32; // 32M cycles + #[derive(Debug, PartialEq, Eq)] pub struct Program { id: ProgramId, @@ -46,6 +50,7 @@ impl Program { ) -> Result, NssaError> { // Write inputs to the program let mut env_builder = ExecutorEnv::builder(); + env_builder.session_limit(Some(MAX_NUM_CYCLES_PUBLIC_EXECUTION)); Self::write_inputs(pre_states, instruction_data, &mut env_builder)?; let env = env_builder.build().unwrap(); diff --git a/nssa/src/public_transaction/transaction.rs b/nssa/src/public_transaction/transaction.rs index ea9c4300..ae372888 100644 --- a/nssa/src/public_transaction/transaction.rs +++ b/nssa/src/public_transaction/transaction.rs @@ -186,12 +186,12 @@ pub mod tests { let tx = transaction_for_tests(); let expected_signer_addresses = vec![ Address::new([ - 14, 238, 36, 40, 114, 150, 186, 85, 39, 143, 30, 84, 3, 190, 1, 71, 84, 134, 99, - 102, 56, 135, 48, 48, 60, 40, 137, 190, 23, 173, 160, 101, + 208, 122, 210, 232, 75, 39, 250, 0, 194, 98, 240, 161, 238, 160, 255, 53, 202, 9, + 115, 84, 126, 106, 16, 111, 114, 241, 147, 194, 220, 131, 139, 68, ]), Address::new([ - 158, 61, 142, 101, 77, 68, 14, 149, 41, 58, 162, 220, 236, 235, 19, 120, 153, 165, - 149, 53, 233, 82, 247, 71, 6, 142, 122, 14, 227, 9, 101, 242, + 231, 174, 119, 197, 239, 26, 5, 153, 147, 68, 175, 73, 159, 199, 138, 23, 5, 57, + 141, 98, 237, 6, 207, 46, 20, 121, 246, 222, 248, 154, 57, 188, ]), ]; let signer_addresses = tx.signer_addresses(); diff --git a/nssa/src/signature/public_key.rs b/nssa/src/signature/public_key.rs index efa732b9..dbd7d643 100644 --- a/nssa/src/signature/public_key.rs +++ b/nssa/src/signature/public_key.rs @@ -33,7 +33,7 @@ impl PublicKey { impl From<&PublicKey> for Address { fn from(key: &PublicKey) -> Self { - const PUBLIC_ACCOUNT_ID_PREFIX: &[u8; 32] = b"/NSSA/v0.1/AccountId/Public/\x00\x00\x00\x00"; + const PUBLIC_ACCOUNT_ID_PREFIX: &[u8; 32] = b"/NSSA/v0.2/AccountId/Public/\x00\x00\x00\x00"; let mut hasher = Sha256::new(); hasher.update(PUBLIC_ACCOUNT_ID_PREFIX); diff --git a/sequencer_core/src/lib.rs b/sequencer_core/src/lib.rs index f7fc9be5..92d53e73 100644 --- a/sequencer_core/src/lib.rs +++ b/sequencer_core/src/lib.rs @@ -238,13 +238,13 @@ mod tests { fn setup_sequencer_config() -> SequencerConfig { let acc1_addr = vec![ - 14, 238, 36, 40, 114, 150, 186, 85, 39, 143, 30, 84, 3, 190, 1, 71, 84, 134, 99, 102, - 56, 135, 48, 48, 60, 40, 137, 190, 23, 173, 160, 101, + 208, 122, 210, 232, 75, 39, 250, 0, 194, 98, 240, 161, 238, 160, 255, 53, 202, 9, 115, + 84, 126, 106, 16, 111, 114, 241, 147, 194, 220, 131, 139, 68, ]; let acc2_addr = vec![ - 158, 61, 142, 101, 77, 68, 14, 149, 41, 58, 162, 220, 236, 235, 19, 120, 153, 165, 149, - 53, 233, 82, 247, 71, 6, 142, 122, 14, 227, 9, 101, 242, + 231, 174, 119, 197, 239, 26, 5, 153, 147, 68, 175, 73, 159, 199, 138, 23, 5, 57, 141, + 98, 237, 6, 207, 46, 20, 121, 246, 222, 248, 154, 57, 188, ]; let initial_acc1 = AccountInitialData { diff --git a/sequencer_rpc/src/process.rs b/sequencer_rpc/src/process.rs index f376f94e..aa6d386b 100644 --- a/sequencer_rpc/src/process.rs +++ b/sequencer_rpc/src/process.rs @@ -308,13 +308,13 @@ mod tests { let tempdir = tempdir().unwrap(); let home = tempdir.path().to_path_buf(); let acc1_addr = vec![ - 14, 238, 36, 40, 114, 150, 186, 85, 39, 143, 30, 84, 3, 190, 1, 71, 84, 134, 99, 102, - 56, 135, 48, 48, 60, 40, 137, 190, 23, 173, 160, 101, + 208, 122, 210, 232, 75, 39, 250, 0, 194, 98, 240, 161, 238, 160, 255, 53, 202, 9, 115, + 84, 126, 106, 16, 111, 114, 241, 147, 194, 220, 131, 139, 68, ]; let acc2_addr = vec![ - 158, 61, 142, 101, 77, 68, 14, 149, 41, 58, 162, 220, 236, 235, 19, 120, 153, 165, 149, - 53, 233, 82, 247, 71, 6, 142, 122, 14, 227, 9, 101, 242, + 231, 174, 119, 197, 239, 26, 5, 153, 147, 68, 175, 73, 159, 199, 138, 23, 5, 57, 141, + 98, 237, 6, 207, 46, 20, 121, 246, 222, 248, 154, 57, 188, ]; let initial_acc1 = AccountInitialData { @@ -352,8 +352,8 @@ mod tests { let balance_to_move = 10; let tx = common::test_utils::create_transaction_native_token_transfer( [ - 14, 238, 36, 40, 114, 150, 186, 85, 39, 143, 30, 84, 3, 190, 1, 71, 84, 134, 99, - 102, 56, 135, 48, 48, 60, 40, 137, 190, 23, 173, 160, 101, + 208, 122, 210, 232, 75, 39, 250, 0, 194, 98, 240, 161, 238, 160, 255, 53, 202, 9, + 115, 84, 126, 106, 16, 111, 114, 241, 147, 194, 220, 131, 139, 68, ], 0, [2; 32], diff --git a/sequencer_runner/configs/debug/sequencer_config.json b/sequencer_runner/configs/debug/sequencer_config.json index 14de2c11..19ff4587 100644 --- a/sequencer_runner/configs/debug/sequencer_config.json +++ b/sequencer_runner/configs/debug/sequencer_config.json @@ -8,11 +8,11 @@ "port": 3040, "initial_accounts": [ { - "addr": "0eee24287296ba55278f1e5403be014754866366388730303c2889be17ada065", + "addr": "d07ad2e84b27fa00c262f0a1eea0ff35ca0973547e6a106f72f193c2dc838b44", "balance": 10000 }, { - "addr": "9e3d8e654d440e95293aa2dceceb137899a59535e952f747068e7a0ee30965f2", + "addr": "e7ae77c5ef1a05999344af499fc78a1705398d62ed06cf2e1479f6def89a39bc", "balance": 20000 } ], diff --git a/wallet/src/chain_storage/mod.rs b/wallet/src/chain_storage/mod.rs index d4123d66..e07ba8e0 100644 --- a/wallet/src/chain_storage/mod.rs +++ b/wallet/src/chain_storage/mod.rs @@ -77,14 +77,14 @@ mod tests { fn create_initial_accounts() -> Vec { let initial_acc1 = serde_json::from_str(r#"{ "Public": { - "address": "0eee24287296ba55278f1e5403be014754866366388730303c2889be17ada065", + "address": "d07ad2e84b27fa00c262f0a1eea0ff35ca0973547e6a106f72f193c2dc838b44", "pub_sign_key": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] } }"#).unwrap(); let initial_acc2 = serde_json::from_str(r#"{ "Public": { - "address": "9e3d8e654d440e95293aa2dceceb137899a59535e952f747068e7a0ee30965f2", + "address": "e7ae77c5ef1a05999344af499fc78a1705398d62ed06cf2e1479f6def89a39bc", "pub_sign_key": [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2] } }"#).unwrap();