Package crypto is a wrapper around packages under golang.org/x/crypto/, particulaly curve25519, ed25519, and nacl/box. This is used to avoid explicitly importing and using these packages throughout yggdrasil. It also includes the all-important NodeID and TreeID types, which are used to identify nodes in the DHT and in the spanning tree's root selection algorithm, respectively.
const BoxNonceLen = 24
BoxNonceLen is the length of a BoxNonce in bytes.
BoxOverhead is the length of the overhead from boxing something.
const BoxPrivKeyLen = 32
BoxPrivKeyLen is the length of a BoxPrivKey in bytes.
const BoxPubKeyLen = 32
BoxPubKeyLen is the length of a BoxPubKey in bytes.
BoxSharedKeyLen is the length of a BoxSharedKey in bytes.
NodeIDLen is the length (in bytes) of a NodeID.
SigLen is the length of SigBytes.
SigPrivKeyLen is the length of a SigPrivKey in bytes.
SigPubKeyLen is the length of a SigPubKey in bytes.
TreeIDLen is the length (in bytes) of a TreeID.
BoxOpen returns a message and true if it successfully opens a crypto box using the provided shared key and nonce.
NewBoxKeys generates a new pair of public/private crypto box keys.
NewSigKeys generates a public/private ed25519 key pair.
Verify returns true if the provided signature matches the key and message.
BoxNonce is the nonce used in NaCl-like crypto "box" operations (curve25519+xsalsa20+poly1305), and must not be reused for different messages encrypted using the same BoxSharedKey.
BoxSeal seals a crypto box using the provided shared key, returning the box and the nonce needed to decrypt it. If nonce is nil, a random BoxNonce will be used and returned. If nonce is non-nil, then nonce.Increment() will be called before using it, and the incremented BoxNonce is what is returned.
NewBoxNonce generates a (cryptographically) random BoxNonce.
Increment adds 2 to a BoxNonce, which is useful if one node intends to send only with odd BoxNonce values, and the other only with even BoxNonce values.
Minus is the result of subtracting the provided BoNonce from this BoxNonce, bounded at +- 64. It's primarily used to determine if a new BoxNonce is higher than the last known BoxNonce from a crypto session, and by how much. This is used in the machinery that makes sure replayed packets can't keep a session open indefinitely or stuck using old/bad information about a node.
BoxPrivKey is a NaCl-like "box" private key (curve25519+xsalsa20+poly1305).
Public returns the BoxPubKey associated with this BoxPrivKey.
BoxPubKey is a NaCl-like "box" public key (curve25519+xsalsa20+poly1305).
Network returns "curve25519" for "box" keys.
String returns a string representation of the "box" key.
BoxSharedKey is a NaCl-like "box" shared key (curve25519+xsalsa20+poly1305).
GetSharedKey returns the shared key derived from your private key and the destination's public key.
NewHandle returns a new (cryptographically random) Handle, used by the session code to identify which session an incoming packet is associated with.
NodeID is how a yggdrasil node is identified in the DHT, and is used to derive IPv6 addresses and subnets in the main executable. It is a sha512sum hash of the node's BoxPubKey
GetNodeID returns the NodeID associated with a BoxPubKey.
Network returns "nodeid" nearly always right now.
PrefixLength returns the number of bits set in a masked NodeID.
SigBytes is an ed25519 signature.
Sign returns the SigBytes signing a message.
SigPrivKey is a private ed25519 signing key.
Public returns the SigPubKey associated with this SigPrivKey.
SigPubKey is a public ed25519 signing key.
TreeID is how a yggdrasil node is identified in the root selection algorithm used to construct the spanning tree.
GetTreeID returns the TreeID associated with a BoxPubKey