@@ -28,14 +28,12 @@ import (
28
28
"crypto"
29
29
cryptoRand "crypto/rand"
30
30
"crypto/subtle"
31
- "errors"
32
31
"fmt"
33
32
"io"
34
- "strconv"
35
33
36
- "github.com/cloudflare/circl/ecc/goldilocks"
37
34
sha3 "github.com/cloudflare/circl/internal/shake"
38
35
"github.com/cloudflare/circl/sign"
36
+ "github.com/cloudflare/circl/sign/ed448/internal/goldilocks"
39
37
)
40
38
41
39
const (
@@ -66,7 +64,8 @@ type SignerOptions struct {
66
64
// Its length must be less or equal than 255 bytes.
67
65
Context string
68
66
69
- // Scheme is an identifier for choosing a signature scheme.
67
+ // Scheme is an identifier for choosing a signature scheme. The zero value
68
+ // is ED448.
70
69
Scheme SchemeID
71
70
}
72
71
@@ -154,7 +153,7 @@ func (priv PrivateKey) Sign(
154
153
case scheme == ED448Ph && opts .HashFunc () == crypto .Hash (0 ):
155
154
return SignPh (priv , message , ctx ), nil
156
155
default :
157
- return nil , errors . New ("ed448: bad hash algorithm" )
156
+ return nil , fmt . Errorf ("ed448: bad hash algorithm" )
158
157
}
159
158
}
160
159
@@ -170,9 +169,9 @@ func GenerateKey(rand io.Reader) (PublicKey, PrivateKey, error) {
170
169
return nil , nil , err
171
170
}
172
171
173
- privateKey := NewKeyFromSeed ( seed )
174
- publicKey := make ([] byte , PublicKeySize )
175
- copy ( publicKey , privateKey [ SeedSize :] )
172
+ privateKey := make ( PrivateKey , PrivateKeySize )
173
+ publicKey := make (PublicKey , PublicKeySize )
174
+ newKeyFromSeed ( privateKey , publicKey , seed )
176
175
177
176
return publicKey , privateKey , nil
178
177
}
@@ -187,9 +186,9 @@ func NewKeyFromSeed(seed []byte) PrivateKey {
187
186
return privateKey
188
187
}
189
188
190
- func newKeyFromSeed (privateKey , seed []byte ) {
189
+ func newKeyFromSeed (privateKey PrivateKey , publicKey PublicKey , seed []byte ) {
191
190
if l := len (seed ); l != SeedSize {
192
- panic ("ed448: bad seed length: " + strconv . Itoa ( l ))
191
+ panic (fmt . Errorf ( "ed448: bad seed length: %v" , l ))
193
192
}
194
193
195
194
var h [hashSize ]byte
@@ -213,7 +212,7 @@ func newKeyFromSeed(privateKey, seed []byte) {
213
212
214
213
func signAll (signature []byte , privateKey PrivateKey , message , ctx []byte , preHash bool ) {
215
214
if len (ctx ) > ContextMaxSize {
216
- panic (fmt .Errorf ("ed448: bad context length: " + strconv . Itoa ( len (ctx ) )))
215
+ panic (fmt .Errorf ("ed448: bad context length: %v" , len (ctx )))
217
216
}
218
217
219
218
H := sha3 .NewShake256 ()
0 commit comments