mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-06 15:23:10 +00:00
add pedersen commitments to Transaction and TransactionPayload struct
This commit is contained in:
parent
bfe39185fa
commit
8fc244b271
@ -1,6 +1,7 @@
|
|||||||
use log::info;
|
use log::info;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sha2::{digest::FixedOutput, Digest};
|
use sha2::{digest::FixedOutput, Digest};
|
||||||
|
use secp256k1_zkp::{rand, PedersenCommitment, Tweak};
|
||||||
|
|
||||||
use crate::merkle_tree_public::TreeHashType;
|
use crate::merkle_tree_public::TreeHashType;
|
||||||
|
|
||||||
@ -43,6 +44,12 @@ pub struct Transaction {
|
|||||||
pub encoded_data: Vec<(CipherText, Vec<u8>, Tag)>,
|
pub encoded_data: Vec<(CipherText, Vec<u8>, Tag)>,
|
||||||
///Transaction senders ephemeral pub key
|
///Transaction senders ephemeral pub key
|
||||||
pub ephemeral_pub_key: Vec<u8>,
|
pub ephemeral_pub_key: Vec<u8>,
|
||||||
|
///Public (Pedersen) commitment
|
||||||
|
pub commitment: Vec<PedersenCommitment>,
|
||||||
|
///tweak
|
||||||
|
pub tweak: Tweak,
|
||||||
|
///secret_r
|
||||||
|
pub secret_r: [u8; 32],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
@ -65,6 +72,12 @@ pub struct TransactionPayload {
|
|||||||
pub encoded_data: Vec<(CipherText, Vec<u8>, Tag)>,
|
pub encoded_data: Vec<(CipherText, Vec<u8>, Tag)>,
|
||||||
///Transaction senders ephemeral pub key
|
///Transaction senders ephemeral pub key
|
||||||
pub ephemeral_pub_key: Vec<u8>,
|
pub ephemeral_pub_key: Vec<u8>,
|
||||||
|
///Public (Pedersen) commitment
|
||||||
|
pub commitment: Vec<PedersenCommitment>,
|
||||||
|
///tweak
|
||||||
|
pub tweak: Tweak,
|
||||||
|
///secret_r
|
||||||
|
pub secret_r: [u8; 32],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<TransactionPayload> for Transaction {
|
impl From<TransactionPayload> for Transaction {
|
||||||
@ -77,6 +90,8 @@ impl From<TransactionPayload> for Transaction {
|
|||||||
|
|
||||||
let hash = <TreeHashType>::from(hasher.finalize_fixed());
|
let hash = <TreeHashType>::from(hasher.finalize_fixed());
|
||||||
|
|
||||||
|
let mut rng = rand::thread_rng();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
hash,
|
hash,
|
||||||
tx_kind: value.tx_kind,
|
tx_kind: value.tx_kind,
|
||||||
@ -88,6 +103,9 @@ impl From<TransactionPayload> for Transaction {
|
|||||||
execution_proof_private: value.execution_proof_private,
|
execution_proof_private: value.execution_proof_private,
|
||||||
encoded_data: value.encoded_data,
|
encoded_data: value.encoded_data,
|
||||||
ephemeral_pub_key: value.ephemeral_pub_key,
|
ephemeral_pub_key: value.ephemeral_pub_key,
|
||||||
|
commitment: value.commitment,
|
||||||
|
tweak: Tweak::new(&mut rng),
|
||||||
|
secret_r: [0; 32],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user