Skip to content

Commit 0a61b66

Browse files
committed
Removing deprecated use of elliptic in P384.
1 parent 342ad81 commit 0a61b66

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

ecc/p384/point_test.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,30 @@
44
package p384
55

66
import (
7+
"crypto/ecdh"
78
"crypto/elliptic"
89
"crypto/rand"
910
"encoding/binary"
11+
"slices"
1012
"testing"
1113

1214
"github.com/cloudflare/circl/internal/test"
1315
)
1416

1517
func randomAffine() *affinePoint {
16-
params := elliptic.P384().Params()
17-
k, _ := rand.Int(rand.Reader, params.N)
18-
return newAffinePoint(params.ScalarBaseMult(k.Bytes()))
18+
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
1931
}
2032

2133
func randomJacobian() *jacobianPoint {

0 commit comments

Comments
 (0)