From a6c695ba6badfc682a50f5bfbe6ee42fa8846655 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 28 Feb 2020 11:12:02 -0800 Subject: [PATCH] types/key: add IsZero methods Signed-off-by: Brad Fitzpatrick --- types/key/key.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/key/key.go b/types/key/key.go index 576714797..6dae4d101 100644 --- a/types/key/key.go +++ b/types/key/key.go @@ -10,6 +10,9 @@ // 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.