bsecret

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2026 License: Apache-2.0

README

bsecret

License

Secrets management on Bitcoin, replicated by overlay hosts that hold ciphertext and never a key. A secret is encrypted once under a random key; the key is wrapped to the members of a group's current epoch; and when the group removes a member, the vault must re-key everything it holds before it does anything else.

How it works

  • A secret is a keyed object. Each version is encrypted under its own random content key, committed to before anyone holds it (BRC-369). The ciphertext is public; the key is wrapped to the owner's wallet and under the key of one epoch of a borg group.
  • Readers are a group's members. Adding a reader is adding a member. Removing one begins a new epoch whose key the removed member never receives.
  • Revoke forces rotation, checked by every host. A vault is a chain of mined tokens. Once it acknowledges a new epoch, no host admits anything onto that chain but the re-keying or retirement of what it held, until nothing is left under an earlier epoch. Hosts cannot make an owner acknowledge: readers and auditors see a vault that has not.
  • The chain is the audit trail. Anyone with block headers verifies which versions the owner listed, in what order, under which epoch, and how long each stayed listed under an epoch a removed member held. No cooperation from a host or the owner is needed. The trail proves what the owner signed; that a version's key is wrapped under the epoch it names is checked by the members who open it.
  • Hosts are replicas, not authorities. A host can withhold; it cannot forge, alter or decrypt.
  • Honest about what removal does. A removed member keeps everything it could read. Removal protects what is written after the vault re-keys.

Documentation

If you want to Read
Try it on one machine in ten minutes QUICKSTART.md
Understand the ideas and use it day to day docs/user-guide.md
Look up a command, a setting or an exit code docs/usage.md
Implement a compatible owner, reader, auditor or host docs/spec.md (the specification)
Know what cannot change once published docs/frozen.md
Know the defaults and caps, why each is set where it is, what was measured, and what it does not do docs/limits.md
Run an overlay host that carries a crypt docs/host.md

The command

bsecret is the owner's tooling, the member's reader and the auditor's check in one command (docs/usage.md).

$ bsecret init -borg ~/.borg                    # a home around the organisation's identity
$ bsecret vault create engineering -name ops    # a vault on a borg group
$ bsecret put db/password < new-password.txt    # a version, listed in a mined token
$ bsecret get db/password | psql ...            # a member reads, every check in order
$ borg org remove <key> -group engineering      # the removal is borg's: a new epoch
$ bsecret rotate -set db/password=new.txt -same-all   # acknowledge, re-key, sweep
$ bsecret -org <key> -vault <id> audit -free    # anyone: the trail, from headers

A vault's owner is a borg organisation, so an owner's bsecret home is made around the identity of its borg home and shares nothing else with it: the group's chain and its epoch keys are read from the hall's hosts by borg's own packages.

Build and test

$ (cd host && npm ci)   # once: the TypeScript package's dependencies
$ make verify           # gofmt, vet, dependency set, licences, typecheck, vectors, tests
$ make bsecret          # the command, bin/bsecret
$ make module           # the host module, host/bundle/bsecret-module.js
$ make vectors          # regenerate the golden vectors, both languages
$ make e2e REFERENCE_HOST=/path/to/host   # the module on a local reference overlay host
$ make e2e-client REFERENCE_HOST=/path/to/host BORG_MODULE=/path/to/borg-module.js
                        # the command and borg's, against two local hosts loading both modules
$ make docker-build     # the command's and the local chain's images
$ make quickstart-check # QUICKSTART.md, run as written

Go 1.27.1 or later, and Node 24 for the TypeScript package under host/ (make verify NODE=/path/to/node24 when it is not on PATH). The direct Go dependencies are go-sdk v1.5.2, bcommon v0.6.4 and borg v0.1.3, and nothing else.

borg is a private module. Its tagged archive is kept under third_party/goproxy and the Makefile serves it to the go command as a file proxy, so make needs no credentials for borg's repository; go.sum holds the tag's hashes and the go command checks the copy against them. Outside make, either set the same GOPROXY, GONOPROXY and GONOSUMDB the Makefile sets, or set GOPRIVATE=github.com/lightwebinc/* and give git credentials for the repository. make borg-module refreshes the copy after go.mod moves to another tag.

The record layer exists twice, held to one set of vectors: internal/secrec in Go, and host/ in TypeScript. Each reads what the other writes (testdata/vectors, testdata/ts). host/ is also the host module: the topic manager tm_bsecret_<name>_<suffix> and the lookup service ls_bsecret, bundled into one file an overlay host loads by path.

License

Apache License 2.0. See LICENSE.

Directories

Path Synopsis
cmd
bsecret command
Command bsecret keeps an organisation's secrets on overlay hosts, and reads them as a member of the group a vault is keyed to: it creates an identity home around a borg organisation's key, creates crypts and vaults, writes each version of a secret under a fresh content key wrapped to the group's current epoch, acknowledges a new epoch of the group and re-keys everything the vault held, retires and retracts, reads a secret with every check made in the signed order, audits a vault's trail from block headers alone, pays a host's 402 for the priced questions, and settles the payments a host accepted as its payee.
Command bsecret keeps an organisation's secrets on overlay hosts, and reads them as a member of the group a vault is keyed to: it creates an identity home around a borg organisation's key, creates crypts and vaults, writes each version of a secret under a fresh content key wrapped to the group's current epoch, acknowledges a new epoch of the group and re-keys everything the vault held, retires and retracts, reads a secret with every check made in the signed order, audits a vault's trail from block headers alone, pays a host's 402 for the priced questions, and settles the payments a host accepted as its payee.
devchain command
Command devchain is a local stand-in chain for trying bsecret without a node, a settlement service or any coin: it serves a node's JSON-RPC (generatetoaddress, sendrawtransaction, getinfo) at /rpc, a node's asset API under /api/v1/, and a header source (/v1/root/<height>, /v1/tip) that the bsecret and borg commands and the overlay hosts check proofs against.
Command devchain is a local stand-in chain for trying bsecret without a node, a settlement service or any coin: it serves a node's JSON-RPC (generatetoaddress, sendrawtransaction, getinfo) at /rpc, a node's asset API under /api/v1/, and a header source (/v1/root/<height>, /v1/tip) that the bsecret and borg commands and the overlay hosts check proofs against.
vectors command
Command vectors writes the golden vectors under testdata/vectors.
Command vectors writes the golden vectors under testdata/vectors.
internal
config
Package config resolves the bsecret command's settings: flags, then BSECRET_* in the environment, then the config file, then the built-in default.
Package config resolves the bsecret command's settings: flags, then BSECRET_* in the environment, then the config file, then the built-in default.
engine
Package engine is a bsecret publisher: the owner's tooling (docs/spec.md sections 7, 8, 12 and 13), run from one identity's home.
Package engine is a bsecret publisher: the owner's tooling (docs/spec.md sections 7, 8, 12 and 13), run from one identity's home.
secrec
Package secrec is the byte-level contract of bsecret: the vault record that rides a mined chain token, the secret record that rides an unmined carrier, the payload a secret's ciphertext holds, the BRC-369 keyed content around it, the wrap of a content key under a group epoch's key and to the owner's own wallet, the crypt, label and name grammars, the vault fold, and the lookup question classes.
Package secrec is the byte-level contract of bsecret: the vault record that rides a mined chain token, the secret record that rides an unmined carrier, the payload a secret's ciphertext holds, the BRC-369 keyed content around it, the wrap of a content key under a group epoch's key and to the owner's own wallet, the crypt, label and name grammars, the vault fold, and the lookup question classes.
state
Package state is an identity's durable record in its home: the funding trees its carriers and vaults spend, the vaults it owns (each vault's chain of mined tokens and every version it published), the objects persisted before they are published, the sweeps it built, every content key commitment it ever published or listed, and, for a reader, the latest token of each vault it has verified.
Package state is an identity's durable record in its home: the funding trees its carriers and vaults spend, the vaults it owns (each vault's chain of mined tokens and every version it published), the objects persisted before they are published, the sweeps it built, every content key commitment it ever published or listed, and, for a reader, the latest token of each vault it has verified.
testhost
Package testhost is the local stand-ins this module's tests run against: an overlay host that carries bsecret crypts and borg halls, a plane, a terms route, and an organisation's borg tooling reduced to what a vault needs of it.
Package testhost is the local stand-ins this module's tests run against: an overlay host that carries bsecret crypts and borg halls, a plane, a terms route, and an organisation's borg tooling reduced to what a vault needs of it.
unicast
Package unicast publishes objects to overlay hosts one by one, for a deployment with no multicast plane (spec section 13).
Package unicast publishes objects to overlay hosts one by one, for a deployment with no multicast plane (spec section 13).
vectors
Package vectors generates the golden vectors under testdata/vectors from the codec in internal/secrec.
Package vectors generates the golden vectors under testdata/vectors from the codec in internal/secrec.
vread
Package vread asks overlay hosts the ls_bsecret questions and checks every answer itself (docs/spec.md sections 10.2, 13 and 14): a vault token's record, lock and field signature, its proof against the reader's own headers and its descent by spends from the vault's first token; a secret carrier by the host's own admission rules and by SPV through its funding parent; a sweep by its proof.
Package vread asks overlay hosts the ls_bsecret questions and checks every answer itself (docs/spec.md sections 10.2, 13 and 14): a vault token's record, lock and field signature, its proof against the reader's own headers and its descent by spends from the vault's first token; a secret carrier by the host's own admission rules and by SPV through its funding parent; a sweep by its proof.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL