Skip to content

Instantly share code, notes, and snippets.

@dshulyak
Created November 23, 2018 13:48
Show Gist options
  • Save dshulyak/b8f3e043f6876cefb051e8b0b3383a12 to your computer and use it in GitHub Desktop.
Save dshulyak/b8f3e043f6876cefb051e8b0b3383a12 to your computer and use it in GitHub Desktop.
package main
import (
"crypto/elliptic"
"crypto/rand"
"fmt"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/ecies"
)
func main() {
key, _ := crypto.GenerateKey()
r, _ := ecies.GenerateKey(rand.Reader, key.PublicKey, ecies.ParamsFromCurve(key.PublicKey.Curve))
fmt.Println(hexutil.Bytes(elliptic.Marshal(r.PublicKey.Curve, r.PublicKey.X, r.PublicKey.Y)).String())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment