lighter.api_key

Documentation for eth_defi.lighter.api_key Python module.

Native Lighter API-key generation.

This module replaces the lighter-sdk dependency for the one operation the Lagoon deployer needs: generating a secret scalar and deriving its public key. It deliberately does not implement Lighter transaction signing, API authentication, nonce management or order submission.

The arithmetic is a small, non-constant-time Python port of the ECgFp5 public key derivation in poseidon_crypto at commit ca0ad1bc8dfe822c61ba7556d1d4d5bcc2ea4a26 (Apache-2.0), as used by lighter-go. It is suitable for one-off local key creation during deployment, not for a general-purpose cryptography API.

Module Attributes

EXTENSION_DEGREE

Degree of the Goldilocks extension field used by ECgFp5.

ECGFP5_SCALAR_ORDER

Prime order of the ECgFp5 group from curve/ecgfp5/scalar_field.go.

Functions

generate_lighter_api_key([api_key_index])

Generate a Lighter API-key pair for deployment registration.

Classes

LighterApiKey

A locally generated Lighter API-key pair.

EXTENSION_DEGREE = 5

Degree of the Goldilocks extension field used by ECgFp5.

ECGFP5_SCALAR_ORDER = 1067993516717146951041484916571792702745057740581727230159139685185762082554198619328292418486241

Prime order of the ECgFp5 group from curve/ecgfp5/scalar_field.go.

class LighterApiKey

Bases: object

A locally generated Lighter API-key pair.

The private scalar is intentionally excluded from repr(). Store it only in an explicitly secret-bearing deployment report.

api_key_index: int

Lighter API-key slot, 4 through 254.

private_key: str

40-byte little-endian private scalar, hex encoded with a 0x prefix.

public_key: str

40-byte little-endian ECgFp5 public key, hex encoded with a 0x prefix.

__init__(api_key_index, private_key, public_key)
Parameters
  • api_key_index (int) –

  • private_key (str) –

  • public_key (str) –

Return type

None

generate_lighter_api_key(api_key_index=4)

Generate a Lighter API-key pair for deployment registration.

Uses Python’s cryptographic random source for a non-zero scalar and derives only its public key locally. The caller must register the public key on L1 before using the private key for Lighter trading.

Parameters

api_key_index (int) – Lighter API-key slot in the user range 4 through 254.

Returns

A private/public API-key pair. Its private key is not included in repr().

Return type

eth_defi.lighter.api_key.LighterApiKey