Documentation
¶
Overview ¶
Package private holds what a reader is handed to open a private store: the store key. A private store is committed to by a record through a salted root and nothing else, so nothing a host or a reader of the record holds leads to its carriers; the store key is the one thing that does.
The key is the publisher's to hand out, by whatever means: a file, a messagebox, a delivery wrapped for one reader. Its JSON form is frozen at the first private store a publisher hands out, like every other format a reader recomputes from.
Index ¶
- Constants
- Variables
- func AnchorFields(contentID, deliveryHash, readerCommit [32]byte) [][]byte
- func Deliver(ctx context.Context, w Wallet, originator string, release []byte, ...) ([]byte, [32]byte, error)
- func HeadC(txid string) ([32]byte, error)
- func OpenRelease(ctx context.Context, w Wallet, originator string, b []byte) (*Parsed, *ReleaseInfo, error)
- func OpenSegment(k [32]byte, salt [keyed.SaltLen]byte, i uint64, ciphertext []byte) ([]byte, error)
- func OriginatorDigest(keyCommit [32]byte, body record.Map) ([32]byte, error)
- func ReaderCommit(salt [32]byte, reader *ec.PublicKey, data []byte) [32]byte
- func Release(ctx context.Context, w Wallet, originator string, reader *ec.PublicKey, ...) ([]byte, error)
- func SealSegment(k [32]byte, salt [keyed.SaltLen]byte, i uint64, plaintext []byte) ([]byte, error)
- type Anchor
- type Delivery
- type Handoff
- type Inner
- type Key
- type Opened
- type Parsed
- type ReleaseInfo
- type Sealer
- type Signer
- type Wallet
Constants ¶
const AnchorSats = 1
AnchorSats is the anchor output's value.
const EnvelopeVersion = 1
EnvelopeVersion is both envelopes' version.
const Version = 1
Version is the store key's format version.
Variables ¶
var ( ReleaseSignature = pushdrop.Derivation{Protocol: wallet.Protocol{SecurityLevel: 1, Protocol: "bfinger release"}, KeyID: "release"} DeliverySignature = pushdrop.Derivation{Protocol: wallet.Protocol{SecurityLevel: 1, Protocol: "bfinger delivery"}, KeyID: "delivery"} )
The protocols and key ids the envelopes are encrypted and signed under.
var AnchorDerivation = pushdrop.Derivation{Protocol: wallet.Protocol{SecurityLevel: 1, Protocol: "bfinger anchor"}, KeyID: "anchor"}
AnchorDerivation is the key an anchor is locked and signed under, the deliverer's: [1, "bfinger anchor"] and key id "anchor", counterparty anyone.
var AnchorTag = []byte{'b', 'f', 0x03}
AnchorTag is the anchor output's first field: "bf" and 0x03, after the token (0x01) and the funding output (0x02).
var ErrAnchor = errors.New("private: anchor does not match the delivery")
ErrAnchor is an anchor that is not this delivery's.
var ErrEnvelope = errors.New("private: envelope does not verify")
ErrEnvelope is an envelope that does not open or does not verify.
var ErrOpen = errors.New("private: sealed content does not open")
ErrOpen is a sealed sub-record that does not open: a key that is not the committed one, a ciphertext that is not the seal's, or a tag that fails.
var OriginatorDerivation = pushdrop.Derivation{Protocol: wallet.Protocol{SecurityLevel: 1, Protocol: "bfinger seal"}, KeyID: "originator"}
OriginatorDerivation is the key the originator signs a store's head under: [1, "bfinger seal"] and key id "originator", counterparty anyone, so a reader holding only the identity key derives the verifying key.
Functions ¶
func AnchorFields ¶
AnchorFields are the anchor's fields, tag first.
func Deliver ¶
func Deliver(ctx context.Context, w Wallet, originator string, release []byte, now time.Time) ([]byte, [32]byte, error)
Deliver wraps release for its reader: the outer envelope, signed by the deliverer's wallet w and encrypted to the reader. It returns the delivery file and its hash.
func OpenRelease ¶
func OpenRelease(ctx context.Context, w Wallet, originator string, b []byte) (*Parsed, *ReleaseInfo, error)
OpenRelease opens a release with the reader's wallet: the signature, that it is addressed to this reader, then the store key inside, which must be the identity's that signed and name the content the release names.
func OpenSegment ¶
OpenSegment reverses SealSegment; nothing is returned unless the tag verifies.
func OriginatorDigest ¶
OriginatorDigest is what the originator signs: a domain string, the content key's commitment, and the hash of the head's body, so the signature binds this content and this key and nothing else.
func ReaderCommit ¶
ReaderCommit is the salted commitment to what a deliverer records about a reader: SHA-256 of a domain string, the salt, the reader's key and the data.
func Release ¶
func Release(ctx context.Context, w Wallet, originator string, reader *ec.PublicKey, key *Key, contentID [32]byte) ([]byte, error)
Release is the inner envelope: key, the store key, encrypted to reader by the identity's wallet w and signed by it. contentID names the content it releases, the head's seal content id.
Types ¶
type Anchor ¶
type Anchor struct {
ContentID, DeliveryHash, ReaderCommit [32]byte
}
Anchor is a decoded anchor output.
func CheckAnchor ¶
func CheckAnchor(s *script.Script, deliverer *ec.PublicKey, contentID, deliveryHash [32]byte) (*Anchor, error)
CheckAnchor decodes an anchor output and holds it to a delivery: the deliverer's anchor key locks it and signed its fields, and it names this content and this delivery's hash.
type Delivery ¶
type Delivery struct {
Deliverer *ec.PublicKey
Reader *ec.PublicKey
Nonce [32]byte
Time time.Time
Release []byte
// Hash is SHA-256 of the delivery file as delivered: what a reader
// anchor names.
Hash [32]byte
}
Delivery is an opened outer envelope.
func OpenDelivery ¶
OpenDelivery opens a delivery with the reader's wallet: it decrypts, checks the deliverer's signature and that it is addressed to this reader and wraps a release for this reader. The release inside is returned for OpenRelease.
type Handoff ¶
Handoff is what a reader is handed: the delivery and the txid of its anchor, in hash byte order.
type Key ¶
type Key struct {
V int `json:"v"`
// IdentityKey is the identity whose record carries the store's refs
// entry, hex, compressed.
IdentityKey string `json:"identityKey"`
Store string `json:"store"`
Count uint64 `json:"count"`
// Head is the head carrier's txid, display order: the form the carrier
// question takes.
Head string `json:"head"`
// CarrierKey is the key the store's carriers are signed and indexed
// under, hex. The identity's own key, or one the host cannot tie to it.
CarrierKey string `json:"carrierKey"`
Salt string `json:"salt"`
// ContentKey is the BRC-369 content key every sub-record of the store
// is sealed under, hex. It is the one secret here: whoever holds it
// reads the store.
ContentKey string `json:"contentKey"`
}
Key is a store key: which identity's record commits to the store, the store's name and member count, the head to ask a host for (the one member, or the manifest), the key its carriers are published and indexed under, and the store's salt.
type Opened ¶
Opened is a sealed sub-record opened: its clear body, and the originator when the inner content names one and its signature verified.
func Open ¶
Open opens a sealed record with the store's content key: the key is checked against the seal's commitment before it is used (BRC-369 section 5.3, so a wrong key names whoever handed it over), the ciphertext against the seal's content id, then the segment, then, where the seal says the originator is inside and head is set, the originator's signature.
type Parsed ¶
type Parsed struct {
Key
Identity *ec.PublicKey
Carrier *ec.PublicKey
HeadC [32]byte
SaltB [32]byte
Content [32]byte
}
Parsed is a store key read and checked: every field in the form a reader uses.
type ReleaseInfo ¶
ReleaseInfo is what a release says in the clear.
func ReadRelease ¶
func ReadRelease(b []byte) (*ReleaseInfo, record.Map, error)
ReadRelease checks a release's shape and the identity's signature over it, without opening it: what a deliverer does before wrapping it.
type Sealer ¶
type Sealer struct {
Key [32]byte
Salt [keyed.SaltLen]byte
Carrier string // record.CarrierIdentity or record.CarrierChild
Originator string // record.OriginatorInside or record.OriginatorAbsent
}
Sealer seals the sub-records of one private store.
func (*Sealer) Seal ¶
func (s *Sealer) Seal(ctx context.Context, i uint64, body record.Map, signer Signer, originator string) (record.Map, *record.Seal, error)
Seal turns a sub-record's clear body into its sealed body and seal, as segment i. When signer is set (the store's head, with the originator inside) the inner content carries the identity and its signature.
type Signer ¶
type Signer interface {
GetPublicKey(ctx context.Context, args wallet.GetPublicKeyArgs, originator string) (*wallet.GetPublicKeyResult, error)
CreateSignature(ctx context.Context, args wallet.CreateSignatureArgs, originator string) (*wallet.CreateSignatureResult, error)
}
Signer is what signs a store's head with the originator inside: the identity's wallet, or any part of one that can answer these two.
type Wallet ¶
type Wallet interface {
Signer
Encrypt(ctx context.Context, args wallet.EncryptArgs, originator string) (*wallet.EncryptResult, error)
Decrypt(ctx context.Context, args wallet.DecryptArgs, originator string) (*wallet.DecryptResult, error)
}
Wallet is what makes and opens envelopes: an identity that encrypts, decrypts and signs.