mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-02 21:33:09 +00:00
rename fingerprint to account_id
This commit is contained in:
parent
32910e76e3
commit
bfbb5e2870
@ -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<FingerPrint>) -> Self {
|
||||
pub fn new(account: Account, is_authorized: bool, account_id: impl Into<AccountId>) -> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user