Class BSV::Wallet::KeyDeriver ¶
Inherits: Object
BRC-42/43 key derivation for the wallet interface.
Derives child keys from a root private key using BKDS (BSV Key Derivation Scheme). Supports protocol IDs, key IDs, counterparties, and security levels as defined in BRC-43.
Constants¶
ANYONE_BN ¶
Not documented.
Attributes¶
root_key [R] ¶
Returns the value of attribute root_key.
Public Instance Methods¶
derive_private_key(protocol_id, key_id, counterparty) ¶
Derives a private key using BRC-42 key derivation. - @param protocol_id [Array] [security_level, protocol_name] - @param key_id [String] key identifier - @param counterparty [String] public key hex, 'self', or 'anyone' - @return [BSV::Primitives::PrivateKey]
derive_public_key(protocol_id, key_id, counterparty, for_self: = false) ¶
Derives a public key using BRC-42 key derivation. - @param protocol_id [Array] [security_level, protocol_name] - @param key_id [String] key identifier - @param counterparty [String] public key hex, 'self', or 'anyone' - @param for_self [Boolean] derive from own identity rather than counterparty's - @return [BSV::Primitives::PublicKey]
derive_symmetric_key(protocol_id, key_id, counterparty) ¶
Derives a symmetric key for encryption/HMAC operations.
Uses ECDH between the derived private and public child keys to produce a shared secret, then uses the X-coordinate as the key. - @param protocol_id [Array] [security_level, protocol_name] - @param key_id [String] key identifier - @param counterparty [String] public key hex, 'self', or 'anyone' - @return [BSV::Primitives::SymmetricKey]
identity_key() ¶
Returns the identity public key as a hex string. - @return [String] 66-character compressed public key hex
initialize(root_key) ¶
- @param
root_key[BSV::Primitives::PrivateKey, String] a private key or 'anyone' - @return [KeyDeriver] a new instance of KeyDeriver
reveal_counterparty_secret(counterparty) ¶
Reveals the ECDH shared secret between this wallet and a counterparty. Used for BRC-69 Method 1 (counterparty key linkage). - @param counterparty [String] public key hex (not 'self') - @raise [InvalidParameterError] - @return [String] compressed shared secret bytes
reveal_specific_secret(counterparty, protocol_id, key_id) ¶
Reveals the specific key offset for a particular derived key. Used for BRC-69 Method 2 (specific key linkage). - @param counterparty [String] public key hex - @param protocol_id [Array] [security_level, protocol_name] - @param key_id [String] key identifier - @return [String] HMAC-SHA256 bytes (the key offset)