I cannot generate the public keys in sequence.
output :./keysgo.go:33:33: cannot use PrivateKey (type []byte) as type string in argument to Public
Thank you so much for your help
important to keep this part:
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))
}
}
}