From f33d9227f7e49e7818b4d3771b6d1126a71bdce5 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Thu, 17 Apr 2025 20:26:55 -0400 Subject: load private signing key --- key/box.go | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'key/box.go') 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 { -- cgit v1.2.3