@projectpac/core-identity
v0.1.0
Published
Part of PAC: @projectpac/core-identity.
Readme
@projectpac/core-identity
Claims ctx.identity. One keypair names this node, and this component is the
only thing that holds it: callers get sign and verify, never key material.
ed25519. The key signs every envelope the node sends, so signatures want to be small (64 bytes) and cheap. The RSA key a joint-computation box requires of a participant is a different key for a different job, and belongs to the use provider that talks to the box.
The id is the key. A node id is sha256 of the public key's DER, in hex --
over the DER so that line endings cannot change a node's identity, and the whole
digest because an id that collides is an id that can be impersonated. Any node
can therefore check an id against the key that claims it with no prior
introduction, which is what lets first contact happen with no handshake.
canonicalBytes is the contract of a signature. It covers every field of an
envelope except the signature, each length-prefixed, under a domain string. The
length prefixes are the point: a separator only works while no field can contain
it, and the public key and the payload type can. The sender's public key is
signed too, so a signature is bound to the key it was made with.
The key file is written aside and moved into place with mode 0600: a reader either finds a whole key or none, and a crash mid-write leaves the node without an identity rather than with half of one it would treat as its own.
