pub struct SwapSecret {
pub preimage: [u8; 32],
pub hash: [u8; 32],
}Expand description
A swap secret: 32-byte preimage and its SHA-256 hash.
The preimage is zeroized from memory when this struct is dropped.
Fields§
§preimage: [u8; 32]The 32-byte secret preimage (keep private until claiming).
hash: [u8; 32]SHA-256 hash of the preimage (publicly shared as the hash lock).
Implementations§
Source§impl SwapSecret
impl SwapSecret
Sourcepub fn generate() -> Result<Self, SignerError>
pub fn generate() -> Result<Self, SignerError>
Generate a new cryptographically secure swap secret.
§Errors
Returns SignerError if the system RNG fails (e.g., entropy exhaustion).
Sourcepub fn from_preimage(preimage: [u8; 32]) -> Self
pub fn from_preimage(preimage: [u8; 32]) -> Self
Create a swap secret from a known preimage.
Trait Implementations§
Source§impl Clone for SwapSecret
impl Clone for SwapSecret
Source§fn clone(&self) -> SwapSecret
fn clone(&self) -> SwapSecret
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Drop for SwapSecret
impl Drop for SwapSecret
Auto Trait Implementations§
impl Freeze for SwapSecret
impl RefUnwindSafe for SwapSecret
impl Send for SwapSecret
impl Sync for SwapSecret
impl Unpin for SwapSecret
impl UnsafeUnpin for SwapSecret
impl UnwindSafe for SwapSecret
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more