If you have a problem using the go-ethereum library then you're probably 
best asking at the tracker or discussion group for that software.

However, the error message seems pretty clear: you're trying to pass a 
value of type []byte to a function which takes a string.  You can convert 
one to the other, but it has to be requested explicitly:
https://go.dev/play/p/67C3mySRegN

Note also that your code posted is badly formatted (it's missing line 
breaks) which means it won't compile.  Using go.dev/play/ to make a 
self-contained program which demonstrates the problem is always a good 
idea, since it can be edited in-situ to fix.

On Wednesday, 6 April 2022 at 19:30:35 UTC+1 sdsa...@gmail.com wrote:

> 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/32248607-da5b-4bda-8b91-379820e4a486n%40googlegroups.com.

Reply via email to