types/key: add IsZero methods

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/115/head
Brad Fitzpatrick 4 years ago
parent 3878f0a67a
commit a6c695ba6b

@ -10,6 +10,9 @@ import "golang.org/x/crypto/curve25519"
// Private represents a curve25519 private key.
type Private [32]byte
// Private reports whether p is the zero value.
func (p Private) IsZero() bool { return p == Private{} }
// B32 returns k as the *[32]byte type that's used by the
// golang.org/x/crypto packages. This allocates; it might
// not be appropriate for performance-sensitive paths.
@ -18,6 +21,9 @@ func (k Private) B32() *[32]byte { return (*[32]byte)(&k) }
// Public represents a curve25519 public key.
type Public [32]byte
// Public reports whether p is the zero value.
func (p Public) IsZero() bool { return p == Public{} }
// B32 returns k as the *[32]byte type that's used by the
// golang.org/x/crypto packages. This allocates; it might
// not be appropriate for performance-sensitive paths.

Loading…
Cancel
Save