BorrouPartner APISandboxDraft

Draft documentation for partners integrating against the sandbox. It can change before /v1 is published; the contract, openapi.yaml, is the reference.

Overview / Guides / Build

Verifying a collateral address

v0.1 draftBorrou's signature on every collateral address, and the checks your app runs before it shows one.

A borrower sends Bitcoin to the address your app shows them. If that address has been swapped, anywhere between the custodian and the borrower's screen, the Bitcoin goes to whoever swapped it, and nothing brings it back. So Borrou signs every collateral address it hands out, and your app checks that signature before it shows the address.

What Borrou signs

When the custodian issues a loan's collateral wallet, Borrou signs a short statement of what it was given, once, with an Ed25519 key. Borrou checks the signature itself every time it shows the address (on its own screens, in its emails, on the borrower's loan page) and every time the API returns it. The API returns it with the deposit address (GET /v1/loans/{reference}/collateral/deposit-address) and the top-up address (GET /v1/loans/{reference}/collateral/top-up-address):

{
  "address": "bc1q…",
  "address_attestation": {
    "algorithm": "Ed25519",
    "key_id": "addr-2026-10",
    "signed_at": "2026-10-02T12:34:56.789Z",
    "statement": "purpose=BORROU_COLLATERAL_ADDRESS_V1\nasset=BTC\nnetwork=bitcoin\naddress=bc1q…\nloan_reference=LN-0042\nwallet=5f2c…\nkey_id=addr-2026-10\nsigned_at=2026-10-02T12:34:56.789Z",
    "signature": "…86 characters of base64url…",
    "verification_code": "K7QD-2MXA"
  }
}

The statement is eight name=value lines in this order, joined by a single line feed, with no trailing newline:

LineValue
purposeAlways BORROU_COLLATERAL_ADDRESS_V1
assetAlways BTC
networkAlways bitcoin
addressThe collateral address
loan_referenceThe loan it belongs to, LN- and digits
walletA salted commitment to the custodian's wallet reference: Borrou checks it; you do not need to, and Borrou does not disclose the reference
key_idThe key that signed, the same as the attestation's key_id
signed_atWhen Borrou signed, RFC 3339 UTC with milliseconds

The signature is Ed25519 (RFC 8032) over the statement's UTF-8 bytes, 64 bytes in base64url without padding. The verification code is the first eight RFC 4648 base32 characters of the SHA-256 of the signature's bytes, as two groups of four.

The keys

GET /v1/address-keys lists the public keys, with no credential: verifying an address must not depend on the credentials of the systems being checked.

{
  "algorithm": "Ed25519",
  "statement_purpose": "BORROU_COLLATERAL_ADDRESS_V1",
  "current_key_id": "addr-2026-10",
  "keys": [{ "key_id": "addr-2026-10", "public_key": "…43 characters…", "public_key_pem": "-----BEGIN PUBLIC KEY-----\n…" }]
}

public_key is the 32 raw bytes in base64url (a JWK's x); public_key_pem is the same key as an SPKI PEM, which every language's standard library loads. Every key listed verifies the addresses it signed; current_key_id signs new ones. A new key is listed before it signs anything, and an old one stays listed while any address it signed can still be shown. Cache the list (it may be cached for five minutes), and fetch it again when an attestation names a key you do not hold. A signature does not expire: an address stays valid while its loan takes collateral, and the API stops serving it when it no longer does.

You can also obtain the keys from TFG out of band and compare them with the list, so that a compromise of the API's answers alone cannot change both an address and the key that checks it.

Before your app shows an address

  1. Find the key the attestation's key_id names in the list. Not there after a fresh fetch: show nothing.
  2. Verify the signature over the statement's bytes exactly as you received them. Never rebuild the statement from other fields, and never re-serialise it.
  3. Read the statement: the eight lines, in order, with the purpose, asset and network above and the same key_id as the attestation. Anything else: show nothing.
  4. Compare its address with the address you are about to show, and its loan_reference with the loan you are showing it for.
  5. Work out the verification code from the signature, check it is the one you were given, and show it beside the address.

If any step fails, show no address, tell the borrower to send nothing, and contact TFG with the loan reference and the X-Request-Id. Never fall back on an address you held from before.

Tested implementations, run against attestations made by Borrou's own signing code (snippets/fixtures/address-attestations.json):

LanguageVerifierTest
TypeScript (Node 20+, node:crypto)snippets/typescript/addressVerification.tsthe API's own test suite
Python 3.9+ (cryptography)snippets/python/borrou_addresses.pypython3 -m unittest discover -s snippets/python
Java 17+ (JDK only)snippets/java/BorrouAddresses.javajava -cp out BorrouAddressesTest snippets/fixtures/address-attestations.json

The verification code, for the borrower

The borrower's loan page shows the same address with the same verification code, and Borrou's emails carry it too. Show the code beside the address in your app, so the borrower can compare the two before sending. A different code, or a different address with the same code, means something has been changed: the borrower should send nothing and contact you, and you contact TFG.

When there is no signature

In live mode an address without a signature is never served: the API answers 409 address_verification_pending (see Error codes). Only the development sandbox may return address_attestation: null, for a wallet assigned before signing was set up there. Show such an address as unsigned, never as verified, and never send real funds to it (no sandbox address takes real funds anyway).