pub struct BSM;Expand description
Bitcoin Signed Messages (BSM) – legacy message signing and verification.
BSM uses a magic prefix to prevent cross-protocol signature attacks. Messages are double-SHA256 hashed with the prefix before signing.
Implementations§
Source§impl BSM
impl BSM
Sourcepub fn magic_hash(message: &[u8]) -> [u8; 32]
pub fn magic_hash(message: &[u8]) -> [u8; 32]
Compute the BSM magic hash of a message.
Constructs the prefixed buffer: VarInt(25) || “Bitcoin Signed Message:\n” || VarInt(message.len()) || message
Then returns hash256 (double SHA-256) of the buffer.
Sourcepub fn sign(
message: &[u8],
private_key: &PrivateKey,
) -> Result<Vec<u8>, CompatError>
pub fn sign( message: &[u8], private_key: &PrivateKey, ) -> Result<Vec<u8>, CompatError>
Sign a message using BSM.
Returns a 65-byte compact BSM signature (recovery byte + 32-byte r + 32-byte s). The magic hash is computed, then ECDSA signing is performed with the hash256 output. Recovery factor is calculated and encoded in the first byte.
Auto Trait Implementations§
impl Freeze for BSM
impl RefUnwindSafe for BSM
impl Send for BSM
impl Sync for BSM
impl Unpin for BSM
impl UnsafeUnpin for BSM
impl UnwindSafe for BSM
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