Documentation
¶
Overview ¶
Package ledger is the signed membership log of a RemoHop account: the one piece of account state that does not depend on trusting the rendezvous server.
An account's membership is an append-only, hash-chained list of entries. Each entry is signed with the identity key of a device that is a member at that point in the log:
seq 0 create device = signer = the first device; email = EmailHash seq n add device = a new member, signed by an existing member seq n remove device = a member that leaves, signed by any member
Every entry after the first names the hash of its predecessor, so the log can only be extended, never rewritten, without a member's key. The hash of the create entry is the account's ID; people compare its fingerprint (Fingerprint) between devices when a device joins, and every device keeps the ID it confirmed. A rendezvous server stores and relays the log but holds no member key, so it cannot add a device, and a device checks every log it receives against the ID it holds and against the longest log it has already verified (Extends).
What a server can still do is withhold the newest entries, for example a removal, from a device; see the account package for how hosts bound that.
Index ¶
- Constants
- func Domain(email string) string
- func EmailHash(normalized string) []byte
- func Extends(old, next []Entry) bool
- func Fingerprint(id []byte) string
- func NormalizeEmail(s string) (string, error)
- func NormalizeFingerprint(s string) string
- func SignedBytes(e *Entry) []byte
- type Entry
- type Member
- type State
Constants ¶
const ( OpCreate = "create" OpAdd = "add" OpRemove = "remove" )
Operations.
const ( // MaxEntries bounds a log. An account that reaches it has to be // deleted and created again; at a few changes a month that is decades. MaxEntries = 256 // MaxMembers bounds the devices in an account at one time. MaxMembers = 64 // MaxName bounds a device name in an entry. MaxName = auth.MaxTokenName // MaxEmail bounds an email address. MaxEmail = 254 )
Variables ¶
This section is empty.
Functions ¶
func EmailHash ¶
EmailHash names an account's address without spelling it out: the rendezvous server indexes accounts by it and the create entry commits to it.
func Extends ¶
Extends reports whether next is old with zero or more entries appended: the only way an honest log changes. Both must already be verified.
func Fingerprint ¶
Fingerprint is how people compare an account ID between devices.
func NormalizeEmail ¶
NormalizeEmail checks an address and returns its canonical form: the bare address, lower case.
func NormalizeFingerprint ¶
NormalizeFingerprint reduces a typed fingerprint (any case, with or without colons or spaces) to the form Fingerprint prints, or "" if it is not a complete one.
func SignedBytes ¶
SignedBytes is what an entry's signature covers. Other implementations (mobile apps, a web gateway) verify entries with it.
Types ¶
type Entry ¶
type Entry struct {
Seq int `json:"seq"`
Prev []byte `json:"prev,omitempty"`
Op string `json:"op"`
Device []byte `json:"device"`
// Name is the device's name when the entry was made; display only.
Name string `json:"name,omitempty"`
// Email is EmailHash of the account's address, in the create entry.
Email []byte `json:"email,omitempty"`
Time int64 `json:"time"`
Signer []byte `json:"signer"`
Sig []byte `json:"sig"`
}
Entry is one signed change to an account's membership.
type Member ¶
type Member struct {
Key ed25519.PublicKey
// Name is the name recorded when the device was added.
Name string
// Seq is the entry that added it; AddedBy the device that signed it.
Seq int
AddedBy ed25519.PublicKey
Added time.Time
}
Member is a device in the account.
type State ¶
type State struct {
// ID is the account ID: the hash of the create entry.
ID []byte
EmailHash []byte
// Len is the number of entries; Head the hash of the last one.
Len int
Head []byte
// Members in the order they were added.
Members []Member
}
State is the result of replaying a log.