X402.Signer backed by a raw secp256k1 private key held in memory.
Requires the optional ex_secp256k1 and ex_keccak dependencies;
new/1 returns {:error, :missing_dependency} when they are unavailable.
The struct redacts the private key when inspected, but the key still lives in process memory — prefer an external signer implementation (KMS, hardware wallet) for production payers holding significant funds.
Examples
{:ok, signer} = X402.Signer.LocalKey.new("0x" <> String.duplicate("11", 32))
{:ok, address} = X402.Signer.LocalKey.address(signer)
Summary
Functions
Returns the EVM address derived from the private key.
Builds a signer from a 32-byte secp256k1 private key.
Signs the precomputed EIP-712 digest with the local key.
Types
Functions
Returns the EVM address derived from the private key.
Builds a signer from a 32-byte secp256k1 private key.
Accepts the raw 32-byte binary or its hex encoding (with or without a
leading 0x). The EVM address is derived once at construction.
Returns {:error, :invalid_private_key} for malformed keys and
{:error, :missing_dependency} when the optional ex_secp256k1 /
ex_keccak dependencies are unavailable.
Examples
iex> X402.Signer.LocalKey.new("not hex")
{:error, :invalid_private_key}
iex> {:ok, signer} = X402.Signer.LocalKey.new("0x" <> String.duplicate("11", 32))
iex> signer.address
"0x19e7e376e7c213b7e7e7e46cc70a5dd086daff2a"
@spec sign_eip712(t(), binary(), X402.Signer.typed_data()) :: {:ok, X402.Signer.signature()} | {:error, term()}
Signs the precomputed EIP-712 digest with the local key.
The typed data is ignored — a local key can sign the digest directly.