aboutsummaryrefslogtreecommitdiffstats
path: root/key/box.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-04-17 20:26:55 -0400
committerSam Anthony <sam@samanthony.xyz>2025-04-17 20:26:55 -0400
commitf33d9227f7e49e7818b4d3771b6d1126a71bdce5 (patch)
treec1cb1476b2b60f0f492b9a68d5653eb1fc60b5cb /key/box.go
parent7b3042859c3f594c7638074987ebb6c32de5cc56 (diff)
downloadhose-f33d9227f7e49e7818b4d3771b6d1126a71bdce5.zip
load private signing key
Diffstat (limited to 'key/box.go')
-rw-r--r--key/box.go18
1 files changed, 1 insertions, 17 deletions
diff --git a/key/box.go b/key/box.go
index 984447f..51bc3ff 100644
--- a/key/box.go
+++ b/key/box.go
@@ -4,8 +4,6 @@ import (
"bytes"
"encoding/hex"
"fmt"
- "io"
- "os"
)
// BoxPublicKey is a public NaCl box key.
@@ -46,21 +44,7 @@ func LoadBoxPublicKey() (BoxPublicKey, error) {
// loadBoxKey reads a NaCl box key (public or private) from the specified file.
func loadBoxKey(filename string) ([32]byte, error) {
- // Open file.
- f, err := os.Open(filename)
- if err != nil {
- return [32]byte{}, err
- }
- defer f.Close()
-
- // Read key from file.
- buf, err := io.ReadAll(f)
- if err != nil {
- return [32]byte{}, err
- }
-
- // Decode key.
- return decodeBoxKey(buf)
+ return loadKey(filename, decodeBoxKey)
}
func (bpk1 BoxPublicKey) Compare(bpk2 BoxPublicKey) int {