Skip to content

Instantly share code, notes, and snippets.

@Jwata
Created April 12, 2019 06:12
Show Gist options
  • Select an option

  • Save Jwata/ff1d194b80a4e74f8f8bf9dcd7feef94 to your computer and use it in GitHub Desktop.

Select an option

Save Jwata/ff1d194b80a4e74f8f8bf9dcd7feef94 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/hex"
"fmt"
"github.com/btcsuite/btcd/btcec"
)
func privkeyToPubkey(priv int) int {
pub := priv * 2
return pub
}
func genPrivkey(privHex string) *btcec.PrivateKey {
pk, _ := hex.DecodeString(privHex)
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), pk)
return priv
}
func main() {
privHex := "a2b1"
priv := genPrivkey(privHex)
fmt.Println(priv.D)
// pub := privkeyToPubkey(priv)
// fmt.Printf("priv: %d, pub: %d\n", priv, pub)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment