We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 342ad81 commit 0a61b66Copy full SHA for 0a61b66
ecc/p384/point_test.go
@@ -4,18 +4,30 @@
4
package p384
5
6
import (
7
+ "crypto/ecdh"
8
"crypto/elliptic"
9
"crypto/rand"
10
"encoding/binary"
11
+ "slices"
12
"testing"
13
14
"github.com/cloudflare/circl/internal/test"
15
)
16
17
func randomAffine() *affinePoint {
- params := elliptic.P384().Params()
- k, _ := rand.Int(rand.Reader, params.N)
18
- return newAffinePoint(params.ScalarBaseMult(k.Bytes()))
+ sk, err := ecdh.P384().GenerateKey(rand.Reader)
19
+ if err != nil {
20
+ panic(err)
21
+ }
22
+
23
+ b := sk.PublicKey().Bytes()
24
+ x, y := b[1:1+sizeFp], b[1+sizeFp:1+2*sizeFp]
25
+ slices.Reverse(x)
26
+ slices.Reverse(y)
27
+ p := new(affinePoint)
28
+ montEncode(&p.x, (*fp384)(x))
29
+ montEncode(&p.y, (*fp384)(y))
30
+ return p
31
}
32
33
func randomJacobian() *jacobianPoint {
0 commit comments