Repository navigation
API reference
Everything below is stable within 1.x. Names starting with _ are private.
This device's keys. The private keys never leave the process; repr() shows only the
device id.
| Member | |
|---|---|
Identity.generate() |
New random identity |
Identity.from_seed(seed: bytes) |
Restore from a 32-byte seed |
.seed() -> bytes |
The 32-byte seed, for a key store |
.public -> PublicIdentity |
The public half |
.sign(data) -> bytes |
Ed25519 signature |
.exchange(peer_box_key) -> bytes |
X25519 shared secret (used internally) |
Another device's public keys. Frozen, hashable, safe to share and store.
| Member | |
|---|---|
.device_id -> str |
16 hex characters derived from the signing key |
.to_bytes() -> bytes |
64 bytes, for QR codes and storage |
PublicIdentity.from_bytes(raw) |
Inverse of to_bytes; ValueError if not 64 bytes |
.verify(data, signature) -> bool |
Ed25519 verification |
.seal(recipient: PublicIdentity, body) -> bytes: encrypts and signs body (any JSON value)
for recipient. Thread-safe; one sealer serves every recipient.
Verifies and decrypts messages for me: Identity.
| Member | |
|---|---|
.add_peer(peer: PublicIdentity) |
Trust messages from peer
|
.remove_peer(device_id) |
Stop trusting it and forget its sequence number |
.open(raw: bytes) -> (PublicIdentity, body) |
Or EnvelopeError; see How it works
|
The only exception Opener.open raises for bad input. str(e) is one of the reasons in
How it works.
| Class | |
|---|---|
MemorySeqStore() |
Default. Forgets on restart; Opener then refuses 30 s of old messages |
JsonFileSeqStore(path) |
Survives restarts; atomic writes; ValueError if the file is not a lanpair one |
SeqStore |
Protocol for your own (persistent, get, set, forget) |
| Function | |
|---|---|
load_or_create_identity(name="default") |
Stored identity, or a new one stored first |
lanpair.keystore.load_identity(name) |
Stored identity or None
|
lanpair.keystore.save_identity(identity, name) |
Store, replacing |
lanpair.keystore.delete_identity(name) |
Remove (no error if missing) |
KeyStoreError |
Missing keyring, locked or unreachable store, or a corrupt entry |
All take service="lanpair" as a keyword to use another key store service name.
| Member | |
|---|---|
Announcer(identity: PublicIdentity, name, port, *, addresses=None, app="lanpair") |
Announces until .close(); also a context manager |
browse(seconds=2.0, *, app="lanpair") -> list[FoundDevice] |
Everything that answers |
find(device_id, seconds=2.0, *, app="lanpair") -> FoundDevice | None |
One device by id |
FoundDevice |
device_id, name, addresses, port, .address (host:port) |
service_type(app) -> str |
_<app>._tcp.local.; app is 1-15 lowercase letters, digits, inner hyphens |
DiscoveryError |
zeroconf missing, or announcing failed |
Use your own app name so devices of different applications don't see each other.
lanpair is MIT-licensed. Found a mistake on this page? Open an issue.