signaturesecp256k1_sign

On-chain secp256k1 ECDSA signing

Sign a message with the secp256k1 signing precompile at 0x69.

Overview

secp256k1_sign() and async_secp256k1_sign():

  • hash the input message with an EIP-191 personal-sign prefix

  • sign the hash using the provided private key

  • return signature bytes (HexBytes)

Signature

def secp256k1_sign(
    w3: Web3,
    *,
    sk: PrivateKey,
    message: str,
) -> HexBytes

async def async_secp256k1_sign(
    w3: AsyncWeb3,
    *,
    sk: PrivateKey,
    message: str,
) -> HexBytes

Parameters

Parameter
Type
Required
Description

w3

Web3 / AsyncWeb3

Yes

Connected Seismic client

sk

Yes

32-byte secp256k1 private key

message

str

Yes

Message text to sign

Returns

Type
Description

HexBytes

Signature bytes (r/s plus recovery byte)

Examples

Basic Usage

Verify Off-Chain

Async Usage

Read Signature Components

Hashing Behavior

The SDK hashes with:

Gas Cost

Fixed cost: 3000.

Notes

  • message is UTF-8 encoded before hashing/signing.

  • Keep private keys out of logs and telemetry.

  • The output format is suitable for typical Ethereum signature verification flows.

See Also

Last updated