signature

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2023 License: MIT Imports: 4 Imported by: 0

README

Golang Ethereum Personal Sign

Go Reference Go Report Card

A simple Golang solution for MetaMasks personal_sign method (https://docs.metamask.io/guide/signing-data.html#a-brief-history). Create a MetaMask signature for comparison: https://app.mycrypto.com/sign-message

Usage

Install:

go get github.com/etaaa/Golang-Ethereum-Personal-Sign

Usage:

package main

import (
	"fmt"
	"log"
	"os"
	"testing"

	"github.com/ethereum/go-ethereum/crypto"
	"github.com/joho/godotenv"

	ps "github.com/etaaa/Golang-Ethereum-Personal-Sign"
)

func main() {
	// Load private key from .env file
	err := godotenv.Load()
	if err != nil {
		log.Fatal(err)
	}
	privateKeyString := os.Getenv("PRIVATE_KEY")
	// Parse private key
	privateKey, err := crypto.HexToECDSA(privateKeyString)
	if err != nil {
		log.Fatal(err)
	}
	// Sign message
	signature, err := ps.PersonalSign("Hello World.", privateKey)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(signature)
}

Questions

For any questions feel free to DM me on Discord (@itseta).

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PersonalSign

func PersonalSign(message string, privateKey *ecdsa.PrivateKey) (string, error)

Returns a signature string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL