File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 44package p384
55
66import (
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
1517func 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
2133func randomJacobian () * jacobianPoint {
You can’t perform that action at this time.
0 commit comments