diff --git a/nssa/core/src/account.rs b/nssa/core/src/account.rs index 54d0196..fdd51e1 100644 --- a/nssa/core/src/account.rs +++ b/nssa/core/src/account.rs @@ -18,8 +18,8 @@ pub struct Account { /// is public, or a `NullifierPublicKey` in case the account is private. #[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] #[cfg_attr(any(feature = "host", test), derive(Debug))] -pub struct FingerPrint([u8; 32]); -impl FingerPrint { +pub struct AccountId([u8; 32]); +impl AccountId { pub fn new(value: [u8; 32]) -> Self { Self(value) } @@ -30,16 +30,16 @@ impl FingerPrint { pub struct AccountWithMetadata { pub account: Account, pub is_authorized: bool, - pub fingerprint: FingerPrint, + pub account_id: AccountId, } #[cfg(feature = "host")] impl AccountWithMetadata { - pub fn new(account: Account, is_authorized: bool, fingerprint: impl Into) -> Self { + pub fn new(account: Account, is_authorized: bool, account_id: impl Into) -> Self { Self { account, is_authorized, - fingerprint: fingerprint.into(), + account_id: account_id.into(), } } } @@ -86,11 +86,11 @@ mod tests { data: b"testing_account_with_metadata_constructor".to_vec(), nonce: 0xdeadbeef, }; - let fingerprint = FingerPrint::new([8; 32]); + let fingerprint = AccountId::new([8; 32]); let new_acc_with_metadata = AccountWithMetadata::new(account.clone(), true, fingerprint.clone()); assert_eq!(new_acc_with_metadata.account, account); assert!(new_acc_with_metadata.is_authorized); - assert_eq!(new_acc_with_metadata.fingerprint, fingerprint); + assert_eq!(new_acc_with_metadata.account_id, fingerprint); } } diff --git a/nssa/core/src/circuit_io.rs b/nssa/core/src/circuit_io.rs index beae76a..deeedbd 100644 --- a/nssa/core/src/circuit_io.rs +++ b/nssa/core/src/circuit_io.rs @@ -41,7 +41,7 @@ mod tests { use super::*; use crate::{ Commitment, Nullifier, NullifierPublicKey, - account::{Account, AccountWithMetadata, FingerPrint}, + account::{Account, AccountWithMetadata, AccountId}, }; use risc0_zkvm::serde::from_slice; @@ -57,7 +57,7 @@ mod tests { nonce: 18446744073709551614, }, true, - FingerPrint::new([0; 32]), + AccountId::new([0; 32]), ), AccountWithMetadata::new( Account { @@ -67,7 +67,7 @@ mod tests { nonce: 9999999999999999999999, }, false, - FingerPrint::new([1; 32]), + AccountId::new([1; 32]), ), ], public_post_states: vec![Account { diff --git a/nssa/core/src/nullifier.rs b/nssa/core/src/nullifier.rs index e852af4..405bb56 100644 --- a/nssa/core/src/nullifier.rs +++ b/nssa/core/src/nullifier.rs @@ -1,15 +1,15 @@ use risc0_zkvm::sha::{Impl, Sha256}; use serde::{Deserialize, Serialize}; -use crate::{Commitment, account::FingerPrint}; +use crate::{Commitment, account::AccountId}; #[derive(Serialize, Deserialize, PartialEq, Eq)] #[cfg_attr(any(feature = "host", test), derive(Debug, Clone, Hash))] pub struct NullifierPublicKey(pub(super) [u8; 32]); -impl From<&NullifierPublicKey> for FingerPrint { +impl From<&NullifierPublicKey> for AccountId { fn from(value: &NullifierPublicKey) -> Self { - FingerPrint::new(value.0) + AccountId::new(value.0) } } diff --git a/nssa/program_methods/guest/src/bin/privacy_preserving_circuit.rs b/nssa/program_methods/guest/src/bin/privacy_preserving_circuit.rs index 346682d..398bfc6 100644 --- a/nssa/program_methods/guest/src/bin/privacy_preserving_circuit.rs +++ b/nssa/program_methods/guest/src/bin/privacy_preserving_circuit.rs @@ -1,7 +1,7 @@ use risc0_zkvm::{guest::env, serde::to_vec}; use nssa_core::{ - account::{Account, AccountWithMetadata, FingerPrint}, compute_digest_for_path, encryption::Ciphertext, program::{validate_execution, ProgramOutput, DEFAULT_PROGRAM_ID}, Commitment, CommitmentSetDigest, EncryptionScheme, Nullifier, NullifierPublicKey, PrivacyPreservingCircuitInput, PrivacyPreservingCircuitOutput + account::{Account, AccountWithMetadata, AccountId}, compute_digest_for_path, encryption::Ciphertext, program::{validate_execution, ProgramOutput, DEFAULT_PROGRAM_ID}, Commitment, CommitmentSetDigest, EncryptionScheme, Nullifier, NullifierPublicKey, PrivacyPreservingCircuitInput, PrivacyPreservingCircuitOutput }; fn main() { @@ -65,8 +65,8 @@ fn main() { let new_nonce = private_nonces_iter.next().expect("Missing private nonce"); let (npk, shared_secret) = private_keys_iter.next().expect("Missing keys"); - if FingerPrint::from(npk) != pre_states[i].fingerprint { - panic!("Fingerprint mismatch"); + if AccountId::from(npk) != pre_states[i].account_id { + panic!("AccountId mismatch"); } if visibility_mask[i] == 1 { diff --git a/nssa/src/address.rs b/nssa/src/address.rs index f9d085e..319b236 100644 --- a/nssa/src/address.rs +++ b/nssa/src/address.rs @@ -1,6 +1,6 @@ use std::{fmt::Display, str::FromStr}; -use nssa_core::account::FingerPrint; +use nssa_core::account::AccountId; use serde::{Deserialize, Serialize}; use crate::signature::PublicKey; @@ -82,9 +82,9 @@ impl<'de> Deserialize<'de> for Address { } } -impl From<&Address> for FingerPrint { +impl From<&Address> for AccountId { fn from(address: &Address) -> Self { - FingerPrint::new(address.value) + AccountId::new(address.value) } } diff --git a/nssa/src/privacy_preserving_transaction/circuit.rs b/nssa/src/privacy_preserving_transaction/circuit.rs index 281d59b..3d6f594 100644 --- a/nssa/src/privacy_preserving_transaction/circuit.rs +++ b/nssa/src/privacy_preserving_transaction/circuit.rs @@ -90,7 +90,7 @@ fn execute_and_prove_program( mod tests { use nssa_core::{ Commitment, EncryptionScheme, Nullifier, - account::{Account, AccountWithMetadata, FingerPrint}, + account::{Account, AccountWithMetadata, AccountId}, }; use crate::{ @@ -114,13 +114,13 @@ mod tests { ..Account::default() }, true, - FingerPrint::new([0; 32]), + AccountId::new([0; 32]), ); let recipient = AccountWithMetadata::new( Account::default(), false, - FingerPrint::from(&recipient_keys.npk()), + AccountId::from(&recipient_keys.npk()), ); let balance_to_move: u128 = 37; @@ -187,14 +187,14 @@ mod tests { ..Account::default() }, true, - FingerPrint::from(&sender_keys.npk()), + AccountId::from(&sender_keys.npk()), ); let commitment_sender = Commitment::new(&sender_keys.npk(), &sender_pre.account); let recipient = AccountWithMetadata::new( Account::default(), false, - FingerPrint::from(&recipient_keys.npk()), + AccountId::from(&recipient_keys.npk()), ); let balance_to_move: u128 = 37; diff --git a/nssa/src/program.rs b/nssa/src/program.rs index 552c436..6def822 100644 --- a/nssa/src/program.rs +++ b/nssa/src/program.rs @@ -77,7 +77,7 @@ impl Program { #[cfg(test)] mod tests { - use nssa_core::account::{Account, AccountWithMetadata, FingerPrint}; + use nssa_core::account::{Account, AccountWithMetadata, AccountId}; use crate::program::Program; @@ -174,10 +174,10 @@ mod tests { ..Account::default() }, true, - FingerPrint::new([0; 32]), + AccountId::new([0; 32]), ); let recipient = - AccountWithMetadata::new(Account::default(), false, FingerPrint::new([1; 32])); + AccountWithMetadata::new(Account::default(), false, AccountId::new([1; 32])); let expected_sender_post = Account { balance: 77665544332211 - balance_to_move,