types/key: export constants for key size, not a method.

Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
David Anderson
2021-10-29 17:35:51 -07:00
parent 6422789ea0
commit 84c3a09a8d
6 changed files with 17 additions and 21 deletions

View File

@@ -21,6 +21,10 @@ const (
// This prefix is used in the control protocol, so cannot be
// changed.
discoPublicHexPrefix = "discokey:"
// DiscoPublicRawLen is the length in bytes of a DiscoPublic, when
// serialized with AppendTo, Raw32 or WriteRawWithoutAllocating.
DiscoPublicRawLen = 32
)
// DiscoPrivate is a disco key, used for peer-to-peer path discovery.
@@ -115,12 +119,6 @@ func (k DiscoPublic) AppendTo(buf []byte) []byte {
return append(buf, k.k[:]...)
}
// RawLen returns the length of k when to the format handled by
// ReadRawWithoutAllocating and WriteRawWithoutAllocating.
func (k DiscoPublic) RawLen() int {
return 32
}
// String returns the output of MarshalText as a string.
func (k DiscoPublic) String() string {
bs, err := k.MarshalText()

View File

@@ -33,6 +33,10 @@ const (
// This prefix is used in the control protocol, so cannot be
// changed.
nodePublicHexPrefix = "nodekey:"
// NodePublicRawLen is the length in bytes of a NodePublic, when
// serialized with AppendTo, Raw32 or WriteRawWithoutAllocating.
NodePublicRawLen = 32
)
// NodePrivate is a node key, used for WireGuard tunnels and
@@ -190,12 +194,6 @@ func (k NodePublic) AppendTo(buf []byte) []byte {
return append(buf, k.k[:]...)
}
// RawLen returns the length of k when to the format handled by
// ReadRawWithoutAllocating and WriteRawWithoutAllocating.
func (k NodePublic) RawLen() int {
return 32
}
// ReadRawWithoutAllocating initializes k with bytes read from br.
// The reading is done ~4x slower than io.ReadFull, but in exchange is
// allocation-free.