recoverAddress
Recovers the Ethereum address from a hash and signature
Loading...
Recovers the Ethereum address from a hash and signature
Recovers the Ethereum address from a hash and signature. This is a lower-level function that works with raw hashes (not messages).
import "github.com/ChefBingbong/viem-go/utils/signature"import "github.com/ChefBingbong/viem-go/utils/signature"
// Recover address from hash and signatureaddress, err := signature.RecoverAddress( "0xd9eba16ed0ecae432b71fe008c98cc872bb4cc214d3220a36f365326cf807d68", "0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c",)if err != nil { log.Fatal(err)}fmt.Printf("Signer: %s", address)// Signer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266(string, error)The Ethereum address that signed the hash, as a hex string with 0x prefix.
stringThe 32-byte hash that was signed. Must be a hex string with 0x prefix.
address, _ := signature.RecoverAddress( "0xd9eba16ed0ecae432b71fe008c98cc872bb4cc214d3220a36f365326cf807d68", sig,)any (supports string, []byte, or *signature.Signature)The signature that was generated by signing the hash.
// Hex string signatureaddress, _ := signature.RecoverAddress( hash, "0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c",)
// Signature structsig, _ := signature.ParseSignature("0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c")address, _ = signature.RecoverAddress(hash, sig)RecoverMessageAddress which handles EIP-191 hashingRecoverTypedDataAddress which handles EIP-712 hashing