BSV.Wallet.ProtoWallet (bsv_sdk v1.1.0)

Copy Markdown View Source

A foundational wallet capable of cryptographic operations (key derivation, encrypt/decrypt, sign/verify, HMAC) but not transaction management or blockchain interaction.

Implements the BSV.Wallet behaviour for crypto-only operations.

Summary

Functions

Create an 'anyone' ProtoWallet (scalar=1).

Create an HMAC-SHA256 using a derived symmetric key.

Create a DER-encoded signature using a derived private key.

Decrypt ciphertext using a derived symmetric key.

Encrypt plaintext using a derived symmetric key.

Create a ProtoWallet from a KeyDeriver.

Create a ProtoWallet from a private key.

Derive a public key based on encryption args, or return the identity key.

The identity public key.

Verify an HMAC-SHA256 using a derived symmetric key.

Verify a DER-encoded signature using a derived public key.

Types

t()

@type t() :: %BSV.Wallet.ProtoWallet{key_deriver: BSV.Wallet.KeyDeriver.t()}

Functions

anyone()

@spec anyone() :: t()

Create an 'anyone' ProtoWallet (scalar=1).

create_hmac(proto_wallet, enc, data)

Create an HMAC-SHA256 using a derived symmetric key.

create_signature(proto_wallet, enc, data, hash_to_sign)

Create a DER-encoded signature using a derived private key.

decrypt(proto_wallet, enc, ciphertext)

Decrypt ciphertext using a derived symmetric key.

Automatically falls back to legacy key derivation (raw ECDH x-coordinate) if decryption with the current KDF (SHA-256) fails, for backward compatibility.

encrypt(proto_wallet, enc, plaintext)

Encrypt plaintext using a derived symmetric key.

from_key_deriver(kd)

@spec from_key_deriver(BSV.Wallet.KeyDeriver.t()) :: t()

Create a ProtoWallet from a KeyDeriver.

from_private_key(pk)

@spec from_private_key(BSV.PrivateKey.t()) :: t()

Create a ProtoWallet from a private key.

get_public_key(proto_wallet, opts)

Derive a public key based on encryption args, or return the identity key.

identity_key(proto_wallet)

@spec identity_key(t()) :: BSV.PublicKey.t()

The identity public key.

verify_hmac(proto_wallet, enc, data, hmac)

Verify an HMAC-SHA256 using a derived symmetric key.

Falls back to legacy key derivation if the current key doesn't match, for backward compatibility with HMACs created by v0.1.

verify_signature(proto_wallet, enc, data, hash_to_verify, signature, opts)

Verify a DER-encoded signature using a derived public key.