types/key: add a dedicated type for node keys.

Complete with converters to all the other types that represent a
node key today, so the new type can gradually subsume old ones.

Updates #3206

Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
David Anderson
2021-09-20 09:59:09 -07:00
committed by Dave Anderson
parent 22dbaa0894
commit bc89a796ec
4 changed files with 483 additions and 5 deletions

View File

@@ -81,6 +81,15 @@ func (u StableNodeID) IsZero() bool {
// NodeKey is the curve25519 public key for a node.
type NodeKey [32]byte
// NodeKeyFromNodePublic returns k converted to a NodeKey.
//
// Deprecated: exists only as a compatibility bridge while NodeKey
// gets removed from the codebase. Do not introduce new uses that
// aren't related to #3206.
func NodeKeyFromNodePublic(k key.NodePublic) NodeKey {
return k.Raw32()
}
// DiscoKey is the curve25519 public key for path discovery key.
// It's never written to disk or reused between network start-ups.
type DiscoKey [32]byte