Commit 0a61b66 1 parent 342ad81 commit 0a61b66 Copy full SHA for 0a61b66
File tree 1 file changed +15
-3
lines changed
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 4
4
package p384
5
5
6
6
import (
7
+ "crypto/ecdh"
7
8
"crypto/elliptic"
8
9
"crypto/rand"
9
10
"encoding/binary"
11
+ "slices"
10
12
"testing"
11
13
12
14
"github.com/cloudflare/circl/internal/test"
13
15
)
14
16
15
17
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
19
31
}
20
32
21
33
func randomJacobian () * jacobianPoint {
You can’t perform that action at this time.
0 commit comments