diff --git a/integration_tests/tests/auth_transfer/private.rs b/integration_tests/tests/auth_transfer/private.rs index 655ca1a9..59975128 100644 --- a/integration_tests/tests/auth_transfer/private.rs +++ b/integration_tests/tests/auth_transfer/private.rs @@ -633,7 +633,7 @@ async fn prove_init_with_commitment_root( })?, vec![ InputAccountIdentity::Public, - InputAccountIdentity::PrivateUnauthorized { + InputAccountIdentity::PrivateForeignInit { vpk, random_seed: [0; 32], npk, diff --git a/integration_tests/tests/tps.rs b/integration_tests/tests/tps.rs index 7141303e..968a90ad 100644 --- a/integration_tests/tests/tps.rs +++ b/integration_tests/tests/tps.rs @@ -299,7 +299,7 @@ fn build_privacy_transaction() -> PrivacyPreservingTransaction { membership_proof: proof, identifier: 0, }, - InputAccountIdentity::PrivateUnauthorized { + InputAccountIdentity::PrivateForeignInit { vpk: recipient_vpk, random_seed: [0; 32], npk: recipient_npk, diff --git a/lee/privacy_preserving_circuit/src/output.rs b/lee/privacy_preserving_circuit/src/output.rs index c5d962d6..57ab588a 100644 --- a/lee/privacy_preserving_circuit/src/output.rs +++ b/lee/privacy_preserving_circuit/src/output.rs @@ -119,7 +119,7 @@ pub fn compute_circuit_output( new_nonce, ); } - InputAccountIdentity::PrivateUnauthorized { + InputAccountIdentity::PrivateForeignInit { vpk, random_seed, npk, @@ -135,8 +135,8 @@ pub fn compute_circuit_output( "Found new private account with non default values", ); assert!( - !pre_state.is_authorized, - "Found new private account marked as authorized." + pre_state.is_authorized, + "Found new private account marked as unauthorized." ); let new_nullifier = ( diff --git a/lee/state_machine/core/src/circuit_io.rs b/lee/state_machine/core/src/circuit_io.rs index 8db29342..47b97833 100644 --- a/lee/state_machine/core/src/circuit_io.rs +++ b/lee/state_machine/core/src/circuit_io.rs @@ -49,7 +49,7 @@ pub enum InputAccountIdentity { }, /// Init of a standalone private account the caller does not own (e.g. a recipient who /// doesn't yet exist on chain). No `nsk`, no membership proof. - PrivateUnauthorized { + PrivateForeignInit { vpk: ViewingPublicKey, random_seed: [u8; 32], npk: NullifierPublicKey, @@ -127,7 +127,7 @@ impl InputAccountIdentity { Self::Public | Self::PrivateAuthorizedInit { .. } | Self::PrivateAuthorizedUpdate { .. } - | Self::PrivateUnauthorized { .. } => None, + | Self::PrivateForeignInit { .. } => None, } } } diff --git a/lee/state_machine/src/privacy_preserving_transaction/circuit/tests.rs b/lee/state_machine/src/privacy_preserving_transaction/circuit/tests.rs index fb66186b..82d25823 100644 --- a/lee/state_machine/src/privacy_preserving_transaction/circuit/tests.rs +++ b/lee/state_machine/src/privacy_preserving_transaction/circuit/tests.rs @@ -89,7 +89,7 @@ fn prove_privacy_preserving_execution_circuit_public_and_private_pre_accounts() Program::serialize_instruction(balance_to_move).unwrap(), vec![ InputAccountIdentity::Public, - InputAccountIdentity::PrivateUnauthorized { + InputAccountIdentity::PrivateForeignInit { vpk: recipient_keys.vpk(), random_seed: [0; 32], npk: recipient_keys.npk(), @@ -205,7 +205,7 @@ fn prove_privacy_preserving_execution_circuit_fully_private() { .expect("sender's commitment must be in the set"), identifier: 0, }, - InputAccountIdentity::PrivateUnauthorized { + InputAccountIdentity::PrivateForeignInit { vpk: recipient_keys.vpk(), random_seed: [0; 32], npk: recipient_keys.npk(), @@ -342,7 +342,7 @@ fn circuit_fails_when_chained_validity_windows_have_empty_intersection() { let result = execute_and_prove( vec![pre], instruction, - vec![InputAccountIdentity::PrivateUnauthorized { + vec![InputAccountIdentity::PrivateForeignInit { vpk: account_keys.vpk(), random_seed: [0; 32], npk: account_keys.npk(), @@ -526,7 +526,7 @@ fn shared_account_receives_via_simple_transfer() { instruction, vec![ InputAccountIdentity::Public, - InputAccountIdentity::PrivateUnauthorized { + InputAccountIdentity::PrivateForeignInit { vpk: shared_keys.vpk(), random_seed: [0; 32], npk: shared_npk, @@ -578,7 +578,7 @@ fn private_authorized_init_encrypts_regular_kind_with_identifier() { ); } -/// `PrivateUnauthorized` with a non-default identifier produces a ciphertext that decrypts +/// `PrivateForeignInit` with a non-default identifier produces a ciphertext that decrypts /// to `PrivateAccountKind::Regular` carrying the correct identifier. #[test] fn private_unauthorized_init_encrypts_regular_kind_with_identifier() { @@ -597,7 +597,7 @@ fn private_unauthorized_init_encrypts_regular_kind_with_identifier() { let (output, _) = execute_and_prove( vec![recipient], Program::serialize_instruction(()).unwrap(), - vec![InputAccountIdentity::PrivateUnauthorized { + vec![InputAccountIdentity::PrivateForeignInit { vpk: keys.vpk(), random_seed: [0; 32], npk: keys.npk(), diff --git a/lee/state_machine/src/state/tests/circuit.rs b/lee/state_machine/src/state/tests/circuit.rs index 0b234b30..3c4516be 100644 --- a/lee/state_machine/src/state/tests/circuit.rs +++ b/lee/state_machine/src/state/tests/circuit.rs @@ -69,7 +69,7 @@ fn circuit_fails_if_invalid_auth_keys_are_provided() { membership_proof: (0, vec![]), identifier: 0, }, - InputAccountIdentity::PrivateUnauthorized { + InputAccountIdentity::PrivateForeignInit { vpk: recipient_keys.vpk(), random_seed: [0; 32], npk: recipient_keys.npk(), @@ -119,7 +119,7 @@ fn circuit_should_fail_if_new_private_account_with_non_default_balance_is_provid membership_proof: (0, vec![]), identifier: 0, }, - InputAccountIdentity::PrivateUnauthorized { + InputAccountIdentity::PrivateForeignInit { vpk: recipient_keys.vpk(), random_seed: [0; 32], npk: recipient_keys.npk(), @@ -169,7 +169,7 @@ fn circuit_should_fail_if_new_private_account_with_non_default_program_owner_is_ membership_proof: (0, vec![]), identifier: 0, }, - InputAccountIdentity::PrivateUnauthorized { + InputAccountIdentity::PrivateForeignInit { vpk: recipient_keys.vpk(), random_seed: [0; 32], npk: recipient_keys.npk(), @@ -219,7 +219,7 @@ fn circuit_should_fail_if_new_private_account_with_non_default_data_is_provided( membership_proof: (0, vec![]), identifier: 0, }, - InputAccountIdentity::PrivateUnauthorized { + InputAccountIdentity::PrivateForeignInit { vpk: recipient_keys.vpk(), random_seed: [0; 32], npk: recipient_keys.npk(), @@ -269,7 +269,7 @@ fn circuit_should_fail_if_new_private_account_with_non_default_nonce_is_provided membership_proof: (0, vec![]), identifier: 0, }, - InputAccountIdentity::PrivateUnauthorized { + InputAccountIdentity::PrivateForeignInit { vpk: recipient_keys.vpk(), random_seed: [0; 32], npk: recipient_keys.npk(), @@ -317,7 +317,7 @@ fn circuit_should_fail_if_new_private_account_is_provided_with_default_values_bu membership_proof: (0, vec![]), identifier: 0, }, - InputAccountIdentity::PrivateUnauthorized { + InputAccountIdentity::PrivateForeignInit { vpk: recipient_keys.vpk(), random_seed: [0; 32], npk: recipient_keys.npk(), @@ -790,7 +790,7 @@ fn private_unauthorized_uninitialized_account_can_still_be_claimed() { let (output, proof) = execute_and_prove( vec![unauthorized_account], Program::serialize_instruction(()).unwrap(), - vec![InputAccountIdentity::PrivateUnauthorized { + vec![InputAccountIdentity::PrivateForeignInit { vpk: private_keys.vpk(), random_seed: [0; 32], npk: private_keys.npk(), diff --git a/lee/state_machine/src/state/tests/mod.rs b/lee/state_machine/src/state/tests/mod.rs index d6acaa2e..e7bb3166 100644 --- a/lee/state_machine/src/state/tests/mod.rs +++ b/lee/state_machine/src/state/tests/mod.rs @@ -279,7 +279,7 @@ fn shielded_balance_transfer_for_tests( Program::serialize_instruction(balance_to_move).unwrap(), vec![ InputAccountIdentity::Public, - InputAccountIdentity::PrivateUnauthorized { + InputAccountIdentity::PrivateForeignInit { vpk: recipient_keys.vpk(), random_seed: [0; 32], npk: recipient_keys.npk(), @@ -338,7 +338,7 @@ fn private_balance_transfer_for_tests( .expect("sender's commitment must be in state"), identifier: 0, }, - InputAccountIdentity::PrivateUnauthorized { + InputAccountIdentity::PrivateForeignInit { vpk: recipient_keys.vpk(), random_seed: [0; 32], npk: recipient_keys.npk(), diff --git a/lee/state_machine/src/state/tests/validity_window.rs b/lee/state_machine/src/state/tests/validity_window.rs index 12e7c229..4581aa89 100644 --- a/lee/state_machine/src/state/tests/validity_window.rs +++ b/lee/state_machine/src/state/tests/validity_window.rs @@ -138,7 +138,7 @@ fn validity_window_works_in_privacy_preserving_transactions( let (output, proof) = crate::privacy_preserving_transaction::circuit::execute_and_prove( vec![pre], Program::serialize_instruction(instruction).unwrap(), - vec![InputAccountIdentity::PrivateUnauthorized { + vec![InputAccountIdentity::PrivateForeignInit { vpk: account_keys.vpk(), random_seed: [0; 32], npk: account_keys.npk(), @@ -203,7 +203,7 @@ fn timestamp_validity_window_works_in_privacy_preserving_transactions( let (output, proof) = crate::privacy_preserving_transaction::circuit::execute_and_prove( vec![pre], Program::serialize_instruction(instruction).unwrap(), - vec![InputAccountIdentity::PrivateUnauthorized { + vec![InputAccountIdentity::PrivateForeignInit { vpk: account_keys.vpk(), random_seed: [0; 32], npk: account_keys.npk(), diff --git a/lez/wallet/src/account_manager.rs b/lez/wallet/src/account_manager.rs index 37f8761d..e1127181 100644 --- a/lez/wallet/src/account_manager.rs +++ b/lez/wallet/src/account_manager.rs @@ -256,7 +256,7 @@ impl AccountManager { identifier, } => { let acc = lee_core::account::Account::default(); - let auth_acc = AccountWithMetadata::new(acc, false, (&npk, &vpk, identifier)); + let auth_acc = AccountWithMetadata::new(acc, true, (&npk, &vpk, identifier)); let mut random_seed: [u8; 32] = [0; 32]; OsRng.fill_bytes(&mut random_seed); let pre = AccountPreparedData { @@ -437,7 +437,7 @@ impl AccountManager { identifier: pre.identifier, commitment_root: self.dummy_commitment_root, }, - (None, _) => InputAccountIdentity::PrivateUnauthorized { + (None, _) => InputAccountIdentity::PrivateForeignInit { vpk: pre.vpk.clone(), random_seed: pre.random_seed, npk: pre.npk,