From 0a61b66c046bde9375e74f5510c4dbd268e50436 Mon Sep 17 00:00:00 2001 From: armfazh Date: Wed, 22 Jan 2025 14:17:36 -0800 Subject: [PATCH] Removing deprecated use of elliptic in P384. --- ecc/p384/point_test.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ecc/p384/point_test.go b/ecc/p384/point_test.go index 219522d6d..d3c133ca0 100644 --- a/ecc/p384/point_test.go +++ b/ecc/p384/point_test.go @@ -4,18 +4,30 @@ package p384 import ( + "crypto/ecdh" "crypto/elliptic" "crypto/rand" "encoding/binary" + "slices" "testing" "github.com/cloudflare/circl/internal/test" ) func randomAffine() *affinePoint { - params := elliptic.P384().Params() - k, _ := rand.Int(rand.Reader, params.N) - return newAffinePoint(params.ScalarBaseMult(k.Bytes())) + sk, err := ecdh.P384().GenerateKey(rand.Reader) + if err != nil { + panic(err) + } + + b := sk.PublicKey().Bytes() + x, y := b[1:1+sizeFp], b[1+sizeFp:1+2*sizeFp] + slices.Reverse(x) + slices.Reverse(y) + p := new(affinePoint) + montEncode(&p.x, (*fp384)(x)) + montEncode(&p.y, (*fp384)(y)) + return p } func randomJacobian() *jacobianPoint {