mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-05-14 03:59:30 +00:00
initialize changes
This commit is contained in:
parent
c6f8890473
commit
deccbc3ac0
@ -15,6 +15,7 @@ pub type PublicKey = AffinePoint;
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct NSSAUserData {
|
||||
/// Default public accounts.
|
||||
/// TODO: it appears this is unnecessary
|
||||
pub default_pub_account_signing_keys: BTreeMap<nssa::AccountId, nssa::PrivateKey>,
|
||||
/// Default private accounts.
|
||||
pub default_user_private_accounts:
|
||||
@ -32,7 +33,7 @@ impl NSSAUserData {
|
||||
let mut check_res = true;
|
||||
for (account_id, key) in accounts_keys_map {
|
||||
let expected_account_id =
|
||||
nssa::AccountId::from(&nssa::PublicKey::new_from_private_key(key));
|
||||
nssa::AccountId::from(&nssa::PublicKey::new_from_private_key(&key));
|
||||
if &expected_account_id != account_id {
|
||||
println!("{expected_account_id}, {account_id}");
|
||||
check_res = false;
|
||||
@ -55,6 +56,7 @@ impl NSSAUserData {
|
||||
check_res
|
||||
}
|
||||
|
||||
// Default only? (Marvin)
|
||||
pub fn new_with_accounts(
|
||||
default_accounts_keys: BTreeMap<nssa::AccountId, nssa::PrivateKey>,
|
||||
default_accounts_key_chains: BTreeMap<
|
||||
@ -64,7 +66,7 @@ impl NSSAUserData {
|
||||
public_key_tree: KeyTreePublic,
|
||||
private_key_tree: KeyTreePrivate,
|
||||
) -> Result<Self> {
|
||||
if !Self::valid_public_key_transaction_pairing_check(&default_accounts_keys) {
|
||||
if !Self::valid_public_key_transaction_pairing_check(&default_accounts_keys) { // TODO: modified not to use default_pub... (Marvin)
|
||||
anyhow::bail!(
|
||||
"Key transaction pairing check not satisfied, there are public account_ids, which are not derived from keys"
|
||||
);
|
||||
@ -112,7 +114,7 @@ impl NSSAUserData {
|
||||
self.default_pub_account_signing_keys
|
||||
.get(&account_id)
|
||||
.or_else(|| self.public_key_tree.get_node(account_id).map(Into::into))
|
||||
}
|
||||
} // TODO: dependent on whether keycard is not; part I care about is get-node() (Marvin)
|
||||
|
||||
/// Generated new private key for privacy preserving transactions.
|
||||
///
|
||||
|
||||
@ -13,6 +13,8 @@ pub struct WitnessSet {
|
||||
|
||||
impl WitnessSet {
|
||||
#[must_use]
|
||||
// TODO: this generates signatures.
|
||||
// However. we may need to get signatures from Keycard.
|
||||
pub fn for_message(message: &Message, proof: Proof, private_keys: &[&PrivateKey]) -> Self {
|
||||
let message_bytes = message.to_bytes();
|
||||
let signatures_and_public_keys = private_keys
|
||||
|
||||
@ -8,6 +8,25 @@ pub struct WitnessSet {
|
||||
}
|
||||
|
||||
impl WitnessSet {
|
||||
#[must_use]
|
||||
pub fn from_list(signatures: &[Signature], pub_keys: &[PublicKey]) -> Self {
|
||||
assert_eq!(signatures.len(), pub_keys.len());
|
||||
|
||||
let signatures_and_public_keys = signatures
|
||||
.iter()
|
||||
.zip( pub_keys.iter())
|
||||
.map(|(sig,key)| {
|
||||
(
|
||||
sig.clone(), key.clone()
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
Self {
|
||||
signatures_and_public_keys,
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn for_message(message: &Message, private_keys: &[&PrivateKey]) -> Self {
|
||||
let message_bytes = message.to_bytes();
|
||||
|
||||
@ -56,7 +56,7 @@ impl WalletChainStore {
|
||||
.expect("Malformed persistent account data, must have private root");
|
||||
|
||||
let mut public_tree = KeyTreePublic::new_from_root(match public_root {
|
||||
PersistentAccountData::Public(data) => data.data,
|
||||
PersistentAccountData::Public(data) => data.data.expect("Expect valid public account keys"), //TODO: Marvin
|
||||
_ => unreachable!(),
|
||||
});
|
||||
let mut private_tree = KeyTreePrivate::new_from_root(match private_root {
|
||||
@ -67,7 +67,7 @@ impl WalletChainStore {
|
||||
for pers_acc_data in persistent_accounts {
|
||||
match pers_acc_data {
|
||||
PersistentAccountData::Public(data) => {
|
||||
public_tree.insert(data.account_id, data.chain_index, data.data);
|
||||
public_tree.insert(data.account_id, data.chain_index, data.data.expect("Expect valid public account keys")); //TODO: Marvin
|
||||
}
|
||||
PersistentAccountData::Private(data) => {
|
||||
private_tree.insert(data.account_id, data.chain_index, data.data);
|
||||
@ -225,7 +225,7 @@ mod tests {
|
||||
PersistentAccountData::Public(PersistentAccountDataPublic {
|
||||
account_id: public_data.account_id(),
|
||||
chain_index: ChainIndex::root(),
|
||||
data: public_data,
|
||||
data: Some(public_data),
|
||||
}),
|
||||
PersistentAccountData::Private(Box::new(PersistentAccountDataPrivate {
|
||||
account_id: private_data.account_id(),
|
||||
|
||||
@ -23,7 +23,7 @@ use url::Url;
|
||||
pub struct PersistentAccountDataPublic {
|
||||
pub account_id: nssa::AccountId,
|
||||
pub chain_index: ChainIndex,
|
||||
pub data: ChildKeysPublic,
|
||||
pub data: Option<ChildKeysPublic>, // `None` when Keycard is used.
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
||||
@ -158,7 +158,7 @@ pub fn produce_data_for_storage(
|
||||
PersistentAccountDataPublic {
|
||||
account_id: *account_id,
|
||||
chain_index: key.clone(),
|
||||
data: data.clone(),
|
||||
data: Some(data.clone()),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user