fix eph_key_compressed AffinePoint serialization

This commit is contained in:
Rostyslav Tyshko 2025-04-04 14:13:51 -04:00
parent 691bc1d4e6
commit ef3125b48e

View File

@ -106,15 +106,11 @@ impl NodeChainStore {
.collect(), .collect(),
)?; )?;
let slice_try: Result<[u8; 33], _> = tx.ephemeral_pub_key.clone().try_into(); let eph_key_compressed = serde_json::to_vec(&tx.ephemeral_pub_key);
let eph_key_compressed =
slice_try.and_then(|inner| Ok(<AffinePoint as GroupEncoding>::Repr::from(inner)));
if let Ok(eph_key_compressed) = eph_key_compressed { if let Ok(eph_key_compressed) = eph_key_compressed {
let ephemeral_public_key_sender = AffinePoint::from_bytes(&eph_key_compressed);
if ephemeral_public_key_sender.is_some().into() { let ephemeral_public_key_sender = serde_json::from_slice::<AffinePoint>(&eph_key_compressed)?;
let ephemeral_public_key_sender = ephemeral_public_key_sender.unwrap();
for (ciphertext, nonce, tag) in tx.encoded_data.clone() { for (ciphertext, nonce, tag) in tx.encoded_data.clone() {
let slice = nonce.as_slice(); let slice = nonce.as_slice();
@ -122,7 +118,6 @@ impl NodeChainStore {
accounts::key_management::constants_types::Nonce::clone_from_slice( accounts::key_management::constants_types::Nonce::clone_from_slice(
slice, slice,
); );
for (acc_id, acc) in self.acc_map.iter_mut() { for (acc_id, acc) in self.acc_map.iter_mut() {
if acc_id[0] == tag { if acc_id[0] == tag {
let decoded_data_curr_acc = acc.decrypt_data( let decoded_data_curr_acc = acc.decrypt_data(
@ -130,11 +125,9 @@ impl NodeChainStore {
ciphertext.clone(), ciphertext.clone(),
nonce, nonce,
); );
if let Ok(decoded_data_curr_acc) = decoded_data_curr_acc { if let Ok(decoded_data_curr_acc) = decoded_data_curr_acc {
let decoded_utxo_try = let decoded_utxo_try =
serde_json::from_slice::<UTXO>(&decoded_data_curr_acc); serde_json::from_slice::<UTXO>(&decoded_data_curr_acc);
if let Ok(utxo) = decoded_utxo_try { if let Ok(utxo) = decoded_utxo_try {
if &utxo.owner == acc_id { if &utxo.owner == acc_id {
acc.utxo_tree.insert_item(utxo)?; acc.utxo_tree.insert_item(utxo)?;
@ -145,7 +138,6 @@ impl NodeChainStore {
} }
} }
} }
}
self.pub_tx_store.add_tx(tx.clone()); self.pub_tx_store.add_tx(tx.clone());
} }