mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Initial documentation for the Monero libraries (#122)
* Document all features * Largely document the Monero libraries Relevant to https://github.com/serai-dex/serai/issues/103 and likely sufficient to get this removed from https://github.com/serai-dex/serai/issues/102.
This commit is contained in:
@@ -92,6 +92,7 @@ pub(crate) fn commitment_mask(shared_key: Scalar) -> Scalar {
|
||||
hash_to_scalar(&mask)
|
||||
}
|
||||
|
||||
/// The private view key and public spend key, enabling scanning transactions.
|
||||
#[derive(Clone, Zeroize, ZeroizeOnDrop)]
|
||||
pub struct ViewPair {
|
||||
spend: EdwardsPoint,
|
||||
@@ -120,6 +121,10 @@ impl ViewPair {
|
||||
}
|
||||
}
|
||||
|
||||
/// Transaction scanner.
|
||||
/// This scanner is capable of generating subaddresses, additionally scanning for them once they've
|
||||
/// been explicitly generated. If the burning bug is attempted, any secondary outputs will be
|
||||
/// ignored.
|
||||
#[derive(Clone)]
|
||||
pub struct Scanner {
|
||||
pair: ViewPair,
|
||||
@@ -155,8 +160,13 @@ impl Drop for Scanner {
|
||||
impl ZeroizeOnDrop for Scanner {}
|
||||
|
||||
impl Scanner {
|
||||
// For burning bug immune addresses (Featured Address w/ the Guaranteed feature), pass None
|
||||
// For traditional Monero address, provide a HashSet of all historically scanned output keys
|
||||
/// Create a Scanner from a ViewPair.
|
||||
/// The network is used for generating subaddresses.
|
||||
/// burning_bug is a HashSet of used keys, intended to prevent key reuse which would burn funds.
|
||||
/// When an output is successfully scanned, the output key MUST be saved to disk.
|
||||
/// When a new scanner is created, ALL saved output keys must be passed in to be secure.
|
||||
/// If None is passed, a modified shared key derivation is used which is immune to the burning
|
||||
/// bug (specifically the Guaranteed feature from Featured Addresses).
|
||||
pub fn from_view(
|
||||
pair: ViewPair,
|
||||
network: Network,
|
||||
@@ -167,6 +177,7 @@ impl Scanner {
|
||||
Scanner { pair, network, subaddresses, burning_bug }
|
||||
}
|
||||
|
||||
/// Return the main address for this view pair.
|
||||
pub fn address(&self) -> Address {
|
||||
Address::new(
|
||||
AddressMeta {
|
||||
@@ -182,6 +193,7 @@ impl Scanner {
|
||||
)
|
||||
}
|
||||
|
||||
/// Return the specified subaddress for this view pair.
|
||||
pub fn subaddress(&mut self, index: (u32, u32)) -> Address {
|
||||
if index == (0, 0) {
|
||||
return self.address();
|
||||
|
||||
Reference in New Issue
Block a user