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 {
|
fn amount_decryption(amount: &EcdhInfo, key: Scalar) -> u64 {
|
||||||
match amount {
|
match amount {
|
||||||
EcdhInfo::Standard { mask, amount } => {
|
EcdhInfo::Standard { mask: _, amount } => {
|
||||||
let shared_sec1 = hash(key.as_bytes());
|
#[cfg(feature = "experimental")]
|
||||||
let shared_sec2 = hash(&shared_sec1);
|
{
|
||||||
let _mask_scalar = mask - Scalar::from_bytes_mod_order(shared_sec1);
|
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);
|
#[cfg(not(feature = "experimental"))]
|
||||||
// get first 64 bits (d2b in rctTypes.cpp)
|
{
|
||||||
let amount_significant_bytes =
|
let _ = amount;
|
||||||
amount_scalar.to_bytes()[0 .. 8].try_into().expect("Can't fail");
|
todo!("decrypting a legacy monero transaction's amount")
|
||||||
|
}
|
||||||
u64::from_le_bytes(amount_significant_bytes)
|
|
||||||
}
|
}
|
||||||
EcdhInfo::Bulletproof { amount } => {
|
EcdhInfo::Bulletproof { amount } => {
|
||||||
u64::from_le_bytes(amount_encryption(u64::from_le_bytes(*amount), key))
|
u64::from_le_bytes(amount_encryption(u64::from_le_bytes(*amount), key))
|
||||||
|
|||||||
Reference in New Issue
Block a user