Skip to main content

Module fingerprint

Module fingerprint 

Source
Expand description

A server key’s fingerprint: a short code a person can compare between the server’s terminal and a client’s screen before the client pins the key.

SHA-256 over a fixed label and the 32-byte EndpointId, the first 80 bits, in Crockford base32, as four groups of four: K7QX-3MPA-9TRD-WF2H. 80 bits puts making a key with a given fingerprint out of reach; a six-digit code could be matched by generating keys for a few seconds. Crockford’s alphabet has no I, L, O or U, so the code reads aloud without confusion. The server and every client compute it here, so they always agree.

Constants§

TEST_VECTORS
Keys and their fingerprints, computed apart from this code (Python’s hashlib), so the format cannot drift. The server’s and the SDK’s tests check them too.

Functions§

fingerprint
The fingerprint of the EndpointId whose 32 bytes are key.
of_hex
The fingerprint of an EndpointId written as iroh prints it (64 hex digits); None if it is not one.
parse
A fingerprint as a person typed it, read back from another screen or aloud: in the form fingerprint writes it, or None if it is not one. Case, spaces and dashes do not matter, and the letters Crockford reads as digits are read so (O as 0, I and L as 1); anything else, and any length but sixteen characters, is not a fingerprint.