mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-05-14 12:09:35 +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)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct NSSAUserData {
|
pub struct NSSAUserData {
|
||||||
/// Default public accounts.
|
/// Default public accounts.
|
||||||
|
/// TODO: it appears this is unnecessary
|
||||||
pub default_pub_account_signing_keys: BTreeMap<nssa::AccountId, nssa::PrivateKey>,
|
pub default_pub_account_signing_keys: BTreeMap<nssa::AccountId, nssa::PrivateKey>,
|
||||||
/// Default private accounts.
|
/// Default private accounts.
|
||||||
pub default_user_private_accounts:
|
pub default_user_private_accounts:
|
||||||
@ -32,7 +33,7 @@ impl NSSAUserData {
|
|||||||
let mut check_res = true;
|
let mut check_res = true;
|
||||||
for (account_id, key) in accounts_keys_map {
|
for (account_id, key) in accounts_keys_map {
|
||||||
let expected_account_id =
|
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 {
|
if &expected_account_id != account_id {
|
||||||
println!("{expected_account_id}, {account_id}");
|
println!("{expected_account_id}, {account_id}");
|
||||||
check_res = false;
|
check_res = false;
|
||||||
@ -55,6 +56,7 @@ impl NSSAUserData {
|
|||||||
check_res
|
check_res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default only? (Marvin)
|
||||||
pub fn new_with_accounts(
|
pub fn new_with_accounts(
|
||||||
default_accounts_keys: BTreeMap<nssa::AccountId, nssa::PrivateKey>,
|
default_accounts_keys: BTreeMap<nssa::AccountId, nssa::PrivateKey>,
|
||||||
default_accounts_key_chains: BTreeMap<
|
default_accounts_key_chains: BTreeMap<
|
||||||
@ -64,7 +66,7 @@ impl NSSAUserData {
|
|||||||
public_key_tree: KeyTreePublic,
|
public_key_tree: KeyTreePublic,
|
||||||
private_key_tree: KeyTreePrivate,
|
private_key_tree: KeyTreePrivate,
|
||||||
) -> Result<Self> {
|
) -> 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!(
|
anyhow::bail!(
|
||||||
"Key transaction pairing check not satisfied, there are public account_ids, which are not derived from keys"
|
"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
|
self.default_pub_account_signing_keys
|
||||||
.get(&account_id)
|
.get(&account_id)
|
||||||
.or_else(|| self.public_key_tree.get_node(account_id).map(Into::into))
|
.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.
|
/// Generated new private key for privacy preserving transactions.
|
||||||
///
|
///
|
||||||
|
|||||||
@ -13,6 +13,8 @@ pub struct WitnessSet {
|
|||||||
|
|
||||||
impl WitnessSet {
|
impl WitnessSet {
|
||||||
#[must_use]
|
#[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 {
|
pub fn for_message(message: &Message, proof: Proof, private_keys: &[&PrivateKey]) -> Self {
|
||||||
let message_bytes = message.to_bytes();
|
let message_bytes = message.to_bytes();
|
||||||
let signatures_and_public_keys = private_keys
|
let signatures_and_public_keys = private_keys
|
||||||
|
|||||||
@ -8,6 +8,25 @@ pub struct WitnessSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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]
|
#[must_use]
|
||||||
pub fn for_message(message: &Message, private_keys: &[&PrivateKey]) -> Self {
|
pub fn for_message(message: &Message, private_keys: &[&PrivateKey]) -> Self {
|
||||||
let message_bytes = message.to_bytes();
|
let message_bytes = message.to_bytes();
|
||||||
|
|||||||
@ -56,7 +56,7 @@ impl WalletChainStore {
|
|||||||
.expect("Malformed persistent account data, must have private root");
|
.expect("Malformed persistent account data, must have private root");
|
||||||
|
|
||||||
let mut public_tree = KeyTreePublic::new_from_root(match public_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!(),
|
_ => unreachable!(),
|
||||||
});
|
});
|
||||||
let mut private_tree = KeyTreePrivate::new_from_root(match private_root {
|
let mut private_tree = KeyTreePrivate::new_from_root(match private_root {
|
||||||
@ -67,7 +67,7 @@ impl WalletChainStore {
|
|||||||
for pers_acc_data in persistent_accounts {
|
for pers_acc_data in persistent_accounts {
|
||||||
match pers_acc_data {
|
match pers_acc_data {
|
||||||
PersistentAccountData::Public(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) => {
|
PersistentAccountData::Private(data) => {
|
||||||
private_tree.insert(data.account_id, data.chain_index, data.data);
|
private_tree.insert(data.account_id, data.chain_index, data.data);
|
||||||
@ -225,7 +225,7 @@ mod tests {
|
|||||||
PersistentAccountData::Public(PersistentAccountDataPublic {
|
PersistentAccountData::Public(PersistentAccountDataPublic {
|
||||||
account_id: public_data.account_id(),
|
account_id: public_data.account_id(),
|
||||||
chain_index: ChainIndex::root(),
|
chain_index: ChainIndex::root(),
|
||||||
data: public_data,
|
data: Some(public_data),
|
||||||
}),
|
}),
|
||||||
PersistentAccountData::Private(Box::new(PersistentAccountDataPrivate {
|
PersistentAccountData::Private(Box::new(PersistentAccountDataPrivate {
|
||||||
account_id: private_data.account_id(),
|
account_id: private_data.account_id(),
|
||||||
|
|||||||
@ -23,7 +23,7 @@ use url::Url;
|
|||||||
pub struct PersistentAccountDataPublic {
|
pub struct PersistentAccountDataPublic {
|
||||||
pub account_id: nssa::AccountId,
|
pub account_id: nssa::AccountId,
|
||||||
pub chain_index: ChainIndex,
|
pub chain_index: ChainIndex,
|
||||||
pub data: ChildKeysPublic,
|
pub data: Option<ChildKeysPublic>, // `None` when Keycard is used.
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
|||||||
@ -158,7 +158,7 @@ pub fn produce_data_for_storage(
|
|||||||
PersistentAccountDataPublic {
|
PersistentAccountDataPublic {
|
||||||
account_id: *account_id,
|
account_id: *account_id,
|
||||||
chain_index: key.clone(),
|
chain_index: key.clone(),
|
||||||
data: data.clone(),
|
data: Some(data.clone()),
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user