diff --git a/coins/monero/src/ringct/mod.rs b/coins/monero/src/ringct/mod.rs index 6c0fd9e0..db1d0648 100644 --- a/coins/monero/src/ringct/mod.rs +++ b/coins/monero/src/ringct/mod.rs @@ -11,10 +11,10 @@ use curve25519_dalek::{constants::ED25519_BASEPOINT_TABLE, scalar::Scalar, edwar pub(crate) mod hash_to_point; pub use hash_to_point::{raw_hash_to_point, hash_to_point}; -/// CLSAG struct, along with signing and verifying functionality. -pub mod clsag; /// MLSAG struct, along with verifying functionality. pub mod mlsag; +/// CLSAG struct, along with signing and verifying functionality. +pub mod clsag; /// BorromeanRange struct, along with verifying functionality. pub mod borromean; /// Bulletproofs(+) structs, along with proving and verifying functionality. @@ -23,7 +23,7 @@ pub mod bulletproofs; use crate::{ Protocol, serialize::*, - ringct::{clsag::Clsag, mlsag::Mlsag, bulletproofs::Bulletproofs, borromean::BorromeanRange}, + ringct::{mlsag::Mlsag, clsag::Clsag, borromean::BorromeanRange, bulletproofs::Bulletproofs}, }; /// Generate a key image for a given key. Defined as `x * hash_to_point(xG)`. @@ -60,8 +60,8 @@ impl EncryptedAmount { #[derive(Clone, PartialEq, Eq, Debug)] pub struct RctBase { pub fee: u64, - pub encrypted_amounts: Vec, pub pseudo_outs: Vec, + pub encrypted_amounts: Vec, pub commitments: Vec, } @@ -91,7 +91,7 @@ impl RctBase { let rct_type = read_byte(r)?; Ok(( if rct_type == 0 { - RctBase { fee: 0, encrypted_amounts: vec![], pseudo_outs: vec![], commitments: vec![] } + RctBase { fee: 0, pseudo_outs: vec![], encrypted_amounts: vec![], commitments: vec![] } } else { RctBase { fee: read_varint(r)?, diff --git a/coins/monero/src/rpc/mod.rs b/coins/monero/src/rpc/mod.rs index 19826db9..daae57a2 100644 --- a/coins/monero/src/rpc/mod.rs +++ b/coins/monero/src/rpc/mod.rs @@ -278,7 +278,6 @@ impl Rpc { let res: BlockResponse = self.json_rpc_call("get_block", Some(json!({ "hash": hex::encode(hash) }))).await?; - // TODO: Verify the TXs included are actually committed to by the header let block = Block::read::<&[u8]>(&mut rpc_hex(&res.blob)?.as_ref()).map_err(|_| RpcError::InvalidNode)?; if block.hash() != hash { diff --git a/coins/monero/src/wallet/mod.rs b/coins/monero/src/wallet/mod.rs index b0e8065d..b3d90af2 100644 --- a/coins/monero/src/wallet/mod.rs +++ b/coins/monero/src/wallet/mod.rs @@ -9,7 +9,7 @@ use curve25519_dalek::{ edwards::{EdwardsPoint, CompressedEdwardsY}, }; -use crate::{hash, hash_to_scalar, serialize::write_varint, transaction::Input}; +use crate::{hash, hash_to_scalar, serialize::write_varint, ringct::EncryptedAmount, transaction::Input}; pub mod extra; pub(crate) use extra::{PaymentId, ExtraField, Extra}; @@ -35,7 +35,6 @@ pub use send::SignableTransactionBuilder; pub(crate) use send::InternalPayment; #[cfg(feature = "multisig")] pub use send::TransactionMachine; -use crate::ringct::EncryptedAmount; fn key_image_sort(x: &EdwardsPoint, y: &EdwardsPoint) -> core::cmp::Ordering { x.compress().to_bytes().cmp(&y.compress().to_bytes()).reverse() @@ -87,6 +86,12 @@ pub(crate) fn shared_key( (view_tag, hash_to_scalar(&shared_key), payment_id_xor) } +pub(crate) fn commitment_mask(shared_key: Scalar) -> Scalar { + let mut mask = b"commitment_mask".to_vec(); + mask.extend(shared_key.to_bytes()); + hash_to_scalar(&mask) +} + pub(crate) fn amount_encryption(amount: u64, key: Scalar) -> [u8; 8] { let mut amount_mask = b"amount".to_vec(); amount_mask.extend(key.to_bytes()); @@ -126,12 +131,6 @@ fn amount_decryption(amount: &EncryptedAmount, key: Scalar) -> (Scalar, u64) { } } -pub(crate) fn commitment_mask(shared_key: Scalar) -> Scalar { - let mut mask = b"commitment_mask".to_vec(); - mask.extend(shared_key.to_bytes()); - hash_to_scalar(&mask) -} - /// The private view key and public spend key, enabling scanning transactions. #[derive(Clone, Zeroize, ZeroizeOnDrop)] pub struct ViewPair {