mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-07-24 08:33:16 +00:00
refactor: rename PrivateUnauthorized to PrivateForeignInit
The account_identity's is_authorized flag no longer determines authorization for this variant, so keep the name tied to what actually distinguishes it: no nsk, only npk (a foreign account init).
This commit is contained in:
parent
914f14e870
commit
b4fa27db42
@ -633,7 +633,7 @@ async fn prove_init_with_commitment_root(
|
||||
})?,
|
||||
vec![
|
||||
InputAccountIdentity::Public,
|
||||
InputAccountIdentity::PrivateUnauthorized {
|
||||
InputAccountIdentity::PrivateForeignInit {
|
||||
vpk,
|
||||
random_seed: [0; 32],
|
||||
npk,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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 = (
|
||||
|
||||
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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(),
|
||||
|
||||
@ -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(),
|
||||
|
||||
@ -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(),
|
||||
|
||||
@ -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(),
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user