func Public(PrivateKey string) (publicKey string) { var e ecdsa.PrivateKey e.D, _ = new(big.Int).SetString(PrivateKey, 16) e.PublicKey.Curve = secp256k1.S256() e.PublicKey.X, e.PublicKey.Y = e.PublicKey.Curve.ScalarBaseMult(e.D.Bytes()) return fmt.Sprintf("%x", elliptic.MarshalCompressed(secp256k1.S256(), e.X, e.Y)) _________________________________________________________________________________________ i tried this
package main import ( "crypto/ecdsa" "crypto/elliptic" "fmt" "math/big" "github.com/ethereum/go-ethereum/crypto/secp256k1" ) func Public(PrivateKey string) (publicKey string) { var e ecdsa.PrivateKey e.D, _ = new(big.Int).SetString(PrivateKey, 16) e.PublicKey.Curve = secp256k1.S256() e.PublicKey.X, e.PublicKey.Y = e.PublicKey.Curve.ScalarBaseMult(e.D.Bytes()) return fmt.Sprintf("%x", elliptic.MarshalCompressed(secp256k1.S256(), e.X, e.Y)) } func main() { count, one := big.NewInt(1), big.NewInt(1) count.SetString("9404625697166532776746648320380374280100293470930272690489102837043110636674",10) PrivateKey := make([]byte, 32) for { count.Add(count, one) copy(PrivateKey[32-len(count.Bytes()):], count.Bytes()) fmt.Printf("%x\n",Public(PrivateKey)) } } _______________________________________________________________________________________ output: ./ keysgo.go: 33: 33: unable to use PrivateKey (type [] byte) as type string in argument in Public _______________________________________________________________________________________ I hope for your help. A thousand thanks -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/ed039fa4-4f11-4ac0-af22-30fe6f83bf82n%40googlegroups.com.