Expand description
The signed-in account: reading what someone signs in with, keeping what is secret where it belongs, signing, and encrypting what the account keeps to itself.
Signing in takes one of three things:
- an
nsec, the account’s secret key: full access, signed here; - an
npub, its public key: read-only; - a
bunker://address (NIP-46): full access, signed by a remote signer that keeps the key.
A remote signer knows this client by a key of the client’s own. There is
one for each signer, made the first time that signer is signed in with
and the same ever after, signing out included: a signer that only answers
clients it was told about (nak bunker -k) is told this key once. When a
signer turns a sign-in down, the key’s public half is what is shown, to
be authorized there. Revoking it is done at the signer.
What is secret goes to the system keyring (Secret Service: gnome-keyring,
KWallet) and nowhere else: an account’s nsec or its bunker address,
and the client keys. None is ever written to the config, the event store
or a log. The config only names the account by its npub.
Signing with an nsec fetches it from the keyring, signs, and lets go of
it: the applet runs for as long as the session does, and holds no secret
key between one signature and the next. A remote signer is connected to
when the first signature is asked for, and stays connected until the
account signs out: connecting anew for every signature would have the
signer greet this client each time.
What an account keeps to itself, such as its private bookmarks, it encrypts to its own key (NIP-44), and only it can read back. That takes the secret key as signing does, and goes the same two ways: here, with the key from the keyring, or at the remote signer.
flowchart LR
subgraph keyring["The system keyring, service cosmic-applet-avestruz"]
secret["Under the account's npub: its nsec, or its bunker address"]
client["Under bunker-client and a signer's key: this client's key for that signer"]
end
subgraph config["The config"]
npub["The account's npub, and nothing secret"]
end
signer["Signer"] -->|"an nsec: fetched for one signature, and let go of"| secret
signer -->|"a bunker: fetched once, and the connection kept"| secret
signer --> client
restore["At startup"] --> npub
restore -->|"is anything kept for it?"| secretThe three ways in, step by step, and what a signature goes through,
are in crate::guide::flows.
Structs§
- Account
- The account in use.
- Approve
InBrowser 🔒 - Opens the page a remote signer asks to be approved on. Some signers answer a request with an address where the person says yes.
- Session 🔒
- A connection to an account’s remote signer.
- Signer
- What signs for the account. Cheap to clone; clones share the connection to a remote signer, when there is one.
Enums§
- Credential
- What someone signed in with.
- Credential
Error - Why the text in the sign-in field can’t be signed in with.
- Sign
Error - Why an event was not signed, or something not encrypted or decrypted.
- Sign
InError - Why nobody was signed in.
- Stored
Signer 🔒 - What the keyring holds for an account: how it signs.
Constants§
- BUNKER_
SCHEME 🔒 - How bunker addresses start.
- CLIENT_
KEY_ 🔒PREFIX - What the keyring user name of a client key starts with; the signer’s public key, in hex, follows.
- KEYRING_
SERVICE 🔒 - The keyring service an account’s secret is filed under; the entry’s user
name is the account’s
npub. - REMOTE_
TIMEOUT 🔒 - How long a remote signer gets to answer one request. Someone may have to pick up a phone and approve it.
Functions§
- blocking 🔒
- Run a keyring call off the async executor: the Secret Service is reached over D-Bus with a blocking client, and may wait on an unlock prompt.
- client_
keys 🔒 - The key this client is known by to the signer
remote_signer: the one in the keyring, or, the first time, a new one that is put there. - client_
keys_ 🔒entry - Where the keyring keeps the key this client is known by to the signer
remote_signer. - delete_
signer 🔒 - Take what
public_keysigns with out of the keyring, if it is there. - has_
signer 🔒 - Whether the keyring holds what
public_keysigns with. - is_
bunker_ 🔒address - Whether
inputis meant as a bunker address. - is_
nip04 🔒 - Whether
payloadwas encrypted the old way (NIP-04) rather than the new (NIP-44): it ends in?iv=and the 24 characters of an initialisation vector, which nothing encrypted the new way does. Lists written by older clients are. - keyring_
entry 🔒 - load_
signer 🔒 - What
public_keysigns with, read from the keyring for the purpose. - nsec 🔒
keys’ secret half as annsec: the form the keyring keeps.- parse_
credential - Read what was typed or pasted into the sign-in field.
- remote_
signer 🔒 - The signer a bunker address names.
- restore
- The account the config names by
npub, as it stands at startup: able to sign if the keyring holds what it signs with. A keyring that can’t be asked leaves the account read-only rather than signed out. - store_
signer 🔒 - Put what
public_keysigns with in the keyring, filed under itsnpub.