keys

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package keys manages Anvil private key allocation for E2E tests.

The 10 default Anvil accounts are partitioned by role to avoid collisions:

Account 0:   admin (on-chain registration, canonical network ops)
Account 1:   client (payer envelope signing)
Accounts 2-4: gateways (signer + payer keys)
Accounts 5-9: nodes (signer keys)

When a pool is exhausted, new ECDSA keys are generated and funded from the admin account via the Anvil RPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminKey

func AdminKey() string

AdminKey returns the admin private key (account 0). Used exclusively for on-chain registration and canonical network operations.

func ClientKey

func ClientKey() string

ClientKey returns the client payer private key (account 1). Used for signing payer envelopes in traffic generation.

Types

type Manager

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

Manager allocates private keys from role-specific pools. When a pool is exhausted, it generates new ECDSA keys and funds them from the admin account via the Anvil RPC endpoint.

func NewManager

func NewManager(logger *zap.Logger, rpcURL string) *Manager

NewManager creates a key manager that uses the given RPC URL to fund generated keys when pre-funded pools are exhausted.

func (*Manager) NextClientKey

func (m *Manager) NextClientKey(ctx context.Context) (string, error)

NextClientKey returns a new client payer key. The first call returns the static ClientKey (account 1). Subsequent calls generate new ECDSA keys and fund them from the admin account. Use this when a test needs traffic from multiple distinct payer addresses.

func (*Manager) NextGatewayKey

func (m *Manager) NextGatewayKey(ctx context.Context) (string, error)

NextGatewayKey returns the next available gateway key. Returns pre-funded keys from accounts 2-4 first, then generates and funds new keys as needed.

func (*Manager) NextNodeKey

func (m *Manager) NextNodeKey(ctx context.Context) (string, error)

NextNodeKey returns the next available node signer key. Returns pre-funded keys from accounts 5-9 first, then generates and funds new keys as needed.

func (*Manager) Reset

func (m *Manager) Reset()

Reset resets the key allocation counters to zero. Call this between test runs to ensure each test gets the same set of keys, avoiding "public key mismatch" errors when databases persist across tests.

Jump to

Keyboard shortcuts

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