Skip to content

Instantly share code, notes, and snippets.

@mmcloughlin
Created September 1, 2019 22:59
Show Gist options
  • Save mmcloughlin/823f698cd20cb299327bec705de0f014 to your computer and use it in GitHub Desktop.
Save mmcloughlin/823f698cd20cb299327bec705de0f014 to your computer and use it in GitHub Desktop.
package main
import (
"crypto/elliptic"
"crypto/rand"
"fmt"
"log"
"math/big"
"github.com/cloudflare/circl/ecc/p384"
)
var ref = elliptic.P384()
func RandPoint() (x, y *big.Int) {
k, err := rand.Int(rand.Reader, ref.Params().N)
if err != nil {
log.Fatal(err)
}
return ref.ScalarBaseMult(k.Bytes())
}
func main() {
c := p384.P384()
x1, y1 := RandPoint()
k := []byte{6}
gx, gy := c.ScalarMult(x1, y1, k)
ex, ey := ref.ScalarMult(x1, y1, k)
fmt.Printf("got x=%x y=%x\n", gx, gy)
fmt.Printf("expect x=%x y=%x\n", ex, ey)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment