Skip to content

Instantly share code, notes, and snippets.

@ulerdogan
Created March 12, 2023 00:03
Show Gist options
  • Save ulerdogan/687fa9679dae0fbf0f618082c60536c3 to your computer and use it in GitHub Desktop.
Save ulerdogan/687fa9679dae0fbf0f618082c60536c3 to your computer and use it in GitHub Desktop.
package main
import (
"crypto/ecdsa"
"crypto/elliptic"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
func main() {
// Ethereum adresini byte formatında belirleyin
addressBytes := common.Hex2Bytes("0123456789abcdef0123456789abcdef0123456")
// Adresi ECDSA public key'e dönüştürmek için önce byte dizisini 32 byte'a tamamlayın
paddedAddress := common.LeftPadBytes(addressBytes, 32)
// Elliptic eğri türünü belirleyin
curve := elliptic.P256()
// ECDSA public key'i elde edin
x, y := curve.ScalarBaseMult(paddedAddress)
publicKey := ecdsa.PublicKey{Curve: curve, X: x, Y: y}
// ECDSA public key'ini hex formatına dönüştürün ve yazdırın
publicKeyBytes := crypto.FromECDSAPub(&publicKey)
fmt.Printf("ECDSA public key: %x\n", publicKeyBytes)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment