siwetest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package siwetest signs Sign-In with Ethereum messages with a fixed key, for tests and examples that need a real wallet signature without a wallet.

It produces exactly what a wallet's personal_sign produces (EIP-191, 65 bytes r || s || v with v = 27 or 28), so a signature it makes is checked by the plugin's real verifier, not a stub. Never use it with a key that holds anything: the keys here are public test keys.

Index

Constants

View Source
const HardhatKey0 = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

HardhatKey0 is the first account of Hardhat's and Anvil's default test mnemonic, whose address every Ethereum developer recognizes: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266. Public; it guards nothing.

View Source
const SecondKey = "59c6995e998f97a5a0044966f0d6f9cb2b6b8a15b1a9a2e3b7dc4cd2b1e5d0c6"

SecondKey is an arbitrary second test key, address 0x22181e4B9Bb252e079fC81DEB438E49d571F9faf, for a test that needs a second wallet. Public; it guards nothing.

Variables

View Source
var ErrKeyInvalid = errors.New("siwetest: a key is 32 bytes of hex")

ErrKeyInvalid is NewKey's error for text that is not a 32-byte hex key.

Functions

This section is empty.

Types

type Key

type Key struct {
	// contains filtered or unexported fields
}

Key is one test wallet.

func MustKey

func MustKey(hexKey string) *Key

MustKey is NewKey for a constant known to be valid; it panics otherwise.

func NewKey

func NewKey(hexKey string) (*Key, error)

NewKey reads a private key written as hex, with or without "0x".

func (*Key) Address

func (k *Key) Address() string

Address is the key's address in its EIP-55 checksummed form.

func (*Key) Sign

func (k *Key) Sign(text string) string

Sign returns text's personal_sign signature as "0x" + 130 hex digits, the form a wallet hands back.

Jump to

Keyboard shortcuts

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