...
1 package curve4q
2
3 import "github.com/cloudflare/circl/ecc/fourq"
4
5
6 const Size = 32
7
8
9 type Key [Size]byte
10
11
12 func KeyGen(public, secret *Key) {
13 var P fourq.Point
14 P.ScalarBaseMult((*[Size]byte)(secret))
15 P.Marshal((*[Size]byte)(public))
16 }
17
18
19
20 func Shared(shared, secret, public *Key) bool {
21 var P, Q fourq.Point
22 ok := P.Unmarshal((*[Size]byte)(public))
23 Q.ScalarMult((*[Size]byte)(secret), &P)
24 Q.Marshal((*[Size]byte)(shared))
25 ok = ok && Q.IsOnCurve()
26 return ok
27 }
28
View as plain text