summaryrefslogtreecommitdiffhomepage
path: root/device/noise-types.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-02-04 18:03:31 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-02-04 22:02:53 +0100
commitcb4bb63030d09afe7ee78fd49613b86709fdc006 (patch)
treeb33248ec5791faded576d4ca7d88851baefd136f /device/noise-types.go
parent05b03c675090df893e8317983702c9661dfc319b (diff)
uapi: allow unsetting device private key with /dev/null
Diffstat (limited to 'device/noise-types.go')
-rw-r--r--device/noise-types.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/device/noise-types.go b/device/noise-types.go
index 6b1f16f..a1976ff 100644
--- a/device/noise-types.go
+++ b/device/noise-types.go
@@ -52,6 +52,15 @@ func (key *NoisePrivateKey) FromHex(src string) (err error) {
return
}
+func (key *NoisePrivateKey) FromMaybeZeroHex(src string) (err error) {
+ err = loadExactHex(key[:], src)
+ if key.IsZero() {
+ return
+ }
+ key.clamp()
+ return
+}
+
func (key NoisePrivateKey) ToHex() string {
return hex.EncodeToString(key[:])
}