mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-03-26 12:13:08 +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.
|
/// is public, or a `NullifierPublicKey` in case the account is private.
|
||||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq)]
|
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||||
#[cfg_attr(any(feature = "host", test), derive(Debug))]
|
#[cfg_attr(any(feature = "host", test), derive(Debug))]
|
||||||
pub struct FingerPrint([u8; 32]);
|
pub struct AccountId([u8; 32]);
|
||||||
impl FingerPrint {
|
impl AccountId {
|
||||||
pub fn new(value: [u8; 32]) -> Self {
|
pub fn new(value: [u8; 32]) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
@ -30,16 +30,16 @@ impl FingerPrint {
|
|||||||
pub struct AccountWithMetadata {
|
pub struct AccountWithMetadata {
|
||||||
pub account: Account,
|
pub account: Account,
|
||||||
pub is_authorized: bool,
|
pub is_authorized: bool,
|
||||||
pub fingerprint: FingerPrint,
|
pub account_id: AccountId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "host")]
|
#[cfg(feature = "host")]
|
||||||
impl AccountWithMetadata {
|
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 {
|
Self {
|
||||||
account,
|
account,
|
||||||
is_authorized,
|
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(),
|
data: b"testing_account_with_metadata_constructor".to_vec(),
|
||||||
nonce: 0xdeadbeef,
|
nonce: 0xdeadbeef,
|
||||||
};
|
};
|
||||||
let fingerprint = FingerPrint::new([8; 32]);
|
let fingerprint = AccountId::new([8; 32]);
|
||||||
let new_acc_with_metadata =
|
let new_acc_with_metadata =
|
||||||
AccountWithMetadata::new(account.clone(), true, fingerprint.clone());
|
AccountWithMetadata::new(account.clone(), true, fingerprint.clone());
|
||||||
assert_eq!(new_acc_with_metadata.account, account);
|
assert_eq!(new_acc_with_metadata.account, account);
|
||||||
assert!(new_acc_with_metadata.is_authorized);
|
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 super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
Commitment, Nullifier, NullifierPublicKey,
|
Commitment, Nullifier, NullifierPublicKey,
|
||||||
account::{Account, AccountWithMetadata, FingerPrint},
|
account::{Account, AccountWithMetadata, AccountId},
|
||||||
};
|
};
|
||||||
use risc0_zkvm::serde::from_slice;
|
use risc0_zkvm::serde::from_slice;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ mod tests {
|
|||||||
nonce: 18446744073709551614,
|
nonce: 18446744073709551614,
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
FingerPrint::new([0; 32]),
|
AccountId::new([0; 32]),
|
||||||
),
|
),
|
||||||
AccountWithMetadata::new(
|
AccountWithMetadata::new(
|
||||||
Account {
|
Account {
|
||||||
@ -67,7 +67,7 @@ mod tests {
|
|||||||
nonce: 9999999999999999999999,
|
nonce: 9999999999999999999999,
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
FingerPrint::new([1; 32]),
|
AccountId::new([1; 32]),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
public_post_states: vec![Account {
|
public_post_states: vec![Account {
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
use risc0_zkvm::sha::{Impl, Sha256};
|
use risc0_zkvm::sha::{Impl, Sha256};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{Commitment, account::FingerPrint};
|
use crate::{Commitment, account::AccountId};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Eq)]
|
#[derive(Serialize, Deserialize, PartialEq, Eq)]
|
||||||
#[cfg_attr(any(feature = "host", test), derive(Debug, Clone, Hash))]
|
#[cfg_attr(any(feature = "host", test), derive(Debug, Clone, Hash))]
|
||||||
pub struct NullifierPublicKey(pub(super) [u8; 32]);
|
pub struct NullifierPublicKey(pub(super) [u8; 32]);
|
||||||
|
|
||||||
impl From<&NullifierPublicKey> for FingerPrint {
|
impl From<&NullifierPublicKey> for AccountId {
|
||||||
fn from(value: &NullifierPublicKey) -> Self {
|
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 risc0_zkvm::{guest::env, serde::to_vec};
|
||||||
|
|
||||||
use nssa_core::{
|
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() {
|
fn main() {
|
||||||
@ -65,8 +65,8 @@ fn main() {
|
|||||||
let new_nonce = private_nonces_iter.next().expect("Missing private nonce");
|
let new_nonce = private_nonces_iter.next().expect("Missing private nonce");
|
||||||
let (npk, shared_secret) = private_keys_iter.next().expect("Missing keys");
|
let (npk, shared_secret) = private_keys_iter.next().expect("Missing keys");
|
||||||
|
|
||||||
if FingerPrint::from(npk) != pre_states[i].fingerprint {
|
if AccountId::from(npk) != pre_states[i].account_id {
|
||||||
panic!("Fingerprint mismatch");
|
panic!("AccountId mismatch");
|
||||||
}
|
}
|
||||||
|
|
||||||
if visibility_mask[i] == 1 {
|
if visibility_mask[i] == 1 {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use std::{fmt::Display, str::FromStr};
|
use std::{fmt::Display, str::FromStr};
|
||||||
|
|
||||||
use nssa_core::account::FingerPrint;
|
use nssa_core::account::AccountId;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::signature::PublicKey;
|
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 {
|
fn from(address: &Address) -> Self {
|
||||||
FingerPrint::new(address.value)
|
AccountId::new(address.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -90,7 +90,7 @@ fn execute_and_prove_program(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use nssa_core::{
|
use nssa_core::{
|
||||||
Commitment, EncryptionScheme, Nullifier,
|
Commitment, EncryptionScheme, Nullifier,
|
||||||
account::{Account, AccountWithMetadata, FingerPrint},
|
account::{Account, AccountWithMetadata, AccountId},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -114,13 +114,13 @@ mod tests {
|
|||||||
..Account::default()
|
..Account::default()
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
FingerPrint::new([0; 32]),
|
AccountId::new([0; 32]),
|
||||||
);
|
);
|
||||||
|
|
||||||
let recipient = AccountWithMetadata::new(
|
let recipient = AccountWithMetadata::new(
|
||||||
Account::default(),
|
Account::default(),
|
||||||
false,
|
false,
|
||||||
FingerPrint::from(&recipient_keys.npk()),
|
AccountId::from(&recipient_keys.npk()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let balance_to_move: u128 = 37;
|
let balance_to_move: u128 = 37;
|
||||||
@ -187,14 +187,14 @@ mod tests {
|
|||||||
..Account::default()
|
..Account::default()
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
FingerPrint::from(&sender_keys.npk()),
|
AccountId::from(&sender_keys.npk()),
|
||||||
);
|
);
|
||||||
let commitment_sender = Commitment::new(&sender_keys.npk(), &sender_pre.account);
|
let commitment_sender = Commitment::new(&sender_keys.npk(), &sender_pre.account);
|
||||||
|
|
||||||
let recipient = AccountWithMetadata::new(
|
let recipient = AccountWithMetadata::new(
|
||||||
Account::default(),
|
Account::default(),
|
||||||
false,
|
false,
|
||||||
FingerPrint::from(&recipient_keys.npk()),
|
AccountId::from(&recipient_keys.npk()),
|
||||||
);
|
);
|
||||||
let balance_to_move: u128 = 37;
|
let balance_to_move: u128 = 37;
|
||||||
|
|
||||||
|
|||||||
@ -77,7 +77,7 @@ impl Program {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use nssa_core::account::{Account, AccountWithMetadata, FingerPrint};
|
use nssa_core::account::{Account, AccountWithMetadata, AccountId};
|
||||||
|
|
||||||
use crate::program::Program;
|
use crate::program::Program;
|
||||||
|
|
||||||
@ -174,10 +174,10 @@ mod tests {
|
|||||||
..Account::default()
|
..Account::default()
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
FingerPrint::new([0; 32]),
|
AccountId::new([0; 32]),
|
||||||
);
|
);
|
||||||
let recipient =
|
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 {
|
let expected_sender_post = Account {
|
||||||
balance: 77665544332211 - balance_to_move,
|
balance: 77665544332211 - balance_to_move,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user