mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 13:39:25 +00:00
Mark legacy EcdhInfo amount decryption as experimental
This commit is contained in:
@@ -95,17 +95,21 @@ pub(crate) fn amount_encryption(amount: u64, key: Scalar) -> [u8; 8] {
|
||||
|
||||
fn amount_decryption(amount: &EcdhInfo, key: Scalar) -> u64 {
|
||||
match amount {
|
||||
EcdhInfo::Standard { mask, amount } => {
|
||||
let shared_sec1 = hash(key.as_bytes());
|
||||
let shared_sec2 = hash(&shared_sec1);
|
||||
let _mask_scalar = mask - Scalar::from_bytes_mod_order(shared_sec1);
|
||||
EcdhInfo::Standard { mask: _, amount } => {
|
||||
#[cfg(feature = "experimental")]
|
||||
{
|
||||
let shared_sec = hash(&hash(key.as_bytes()));
|
||||
let amount_scalar = amount - Scalar::from_bytes_mod_order(shared_sec);
|
||||
// d2b from rctTypes.cpp
|
||||
let amount_significant_bytes = amount_scalar.to_bytes()[0 .. 8].try_into().unwrap();
|
||||
u64::from_le_bytes(amount_significant_bytes)
|
||||
}
|
||||
|
||||
let amount_scalar = amount - Scalar::from_bytes_mod_order(shared_sec2);
|
||||
// get first 64 bits (d2b in rctTypes.cpp)
|
||||
let amount_significant_bytes =
|
||||
amount_scalar.to_bytes()[0 .. 8].try_into().expect("Can't fail");
|
||||
|
||||
u64::from_le_bytes(amount_significant_bytes)
|
||||
#[cfg(not(feature = "experimental"))]
|
||||
{
|
||||
let _ = amount;
|
||||
todo!("decrypting a legacy monero transaction's amount")
|
||||
}
|
||||
}
|
||||
EcdhInfo::Bulletproof { amount } => {
|
||||
u64::from_le_bytes(amount_encryption(u64::from_le_bytes(*amount), key))
|
||||
|
||||
Reference in New Issue
Block a user