THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Bitcoin Agent Message Authentication with HMAC

permalink THAMER
#agent-protocols#ai-agents#bitcoin#python#security

Bitcoin Agent Message Authentication with HMAC

Authenticate exact message bytes in a pairwise trust domain.

Design and trust boundary

HMAC authenticates bytes between parties sharing a secret; it is not a public-key digital signature or non-repudiation mechanism. Provision independent random pairwise keys outside the model, bind the key to a trusted sender identity, and rotate keys with explicit key identifiers. For independent parties use an audited public-key signature implementation such as Ed25519 and a trusted public-key registry. Authentication alone does not authorize spending or prevent replay.

Independent reference implementation

Python · 15 lines
1# SPDX-License-Identifier: 0BSD
2import hmac, hashlib
3
4def tag(key, message):
5    if len(key) < 32 or len(message) > 8192:
6        raise ValueError('bounds')
7    return hmac.digest(key,b'agent-message-v1\x00'+message,'sha256')
8
9def verify(key,message,signature):
10    return hmac.compare_digest(tag(key,message),signature)
11
12key=bytes(range(32)) # public fixture only
13msg=b'{"request_id":"r1"}'
14assert verify(key,msg,tag(key,msg))
15assert not verify(key,msg+b' ',tag(key,msg))

Validation and limitations

Run the example with Python 3. Assertions use synthetic fixtures and do not contact a wallet or agent service. This is a proposed application-level pattern, not an established interoperability standard. Keep BTC KEY outside agent messages. The WAB Engine API and signed fee law remain unchanged.

Related research

https://thamer.org/learn/bitcoin-for-ai-agents-open-integration-guide

https://thamer.org/api

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects