Update Go version to 1.23

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd)
2024-12-09 09:41:00 +00:00
parent 349c58e084
commit 4bd07e24d9
39 changed files with 344 additions and 282 deletions

View File

@ -1,4 +1,4 @@
// Copyright 2018-2022 The NATS Authors
// Copyright 2018-2024 The NATS Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@ -15,10 +15,9 @@ package nkeys
import (
"bytes"
"crypto/ed25519"
"crypto/rand"
"io"
"golang.org/x/crypto/ed25519"
)
// kp is the internal struct for a kepypair using seed.
@ -31,7 +30,7 @@ const seedLen = 32
// CreatePair will create a KeyPair based on the rand entropy and a type/prefix byte.
func CreatePair(prefix PrefixByte) (KeyPair, error) {
return CreatePairWithRand(prefix, rand.Reader)
return CreatePairWithRand(prefix, nil)
}
// CreatePair will create a KeyPair based on the rand reader and a type/prefix byte. rand can be nil.
@ -39,17 +38,12 @@ func CreatePairWithRand(prefix PrefixByte, rr io.Reader) (KeyPair, error) {
if prefix == PrefixByteCurve {
return CreateCurveKeysWithRand(rr)
}
if rr == nil {
rr = rand.Reader
}
var rawSeed [seedLen]byte
_, err := io.ReadFull(rr, rawSeed[:])
_, priv, err := ed25519.GenerateKey(rr)
if err != nil {
return nil, err
}
seed, err := EncodeSeed(prefix, rawSeed[:])
seed, err := EncodeSeed(prefix, priv.Seed())
if err != nil {
return nil, err
}