Bitcoin Agent Message Authentication with HMAC
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
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
