Every transaction on the Proof Exchange is authenticated by an Ed25519 signature, and every account address is a 20-byte slice of a keccak256 digest. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Proof-labs/trading-sdk/llms.txt
Use this file to discover all available pages before exploring further.
crypto module exposes the complete set of primitives you need to generate keys, derive addresses, build deterministic signing messages, and verify signatures — all in a form that is byte-for-byte compatible with the Rust crypto.rs reference implementation. These functions are the foundation on which the codec and the ExchangeClient are built; you will need them directly whenever you sign offline or integrate a custom key-management backend.
Key Management
generateKeypair()
Generates a fresh Ed25519 keypair using @noble/ed25519’s cryptographically secure utils.randomSecretKey().
32-byte random Ed25519 secret key. Keep this secret and never transmit it.
32-byte compressed Ed25519 public key derived from
privateKey.getPublicKey(privateKey)
Deterministically derives the 32-byte Ed25519 public key from a private key.
32-byte Ed25519 secret key.
32-byte Ed25519 public key.
Address Derivation
On Proof Exchange, an account’s owner address is the last 20 bytes of the keccak256 hash of its Ed25519 public key — the same derivation used by the Rustpubkey_to_owner function.
pubkeyToOwner(pubkey)
Derives the 20-byte owner address from a 32-byte Ed25519 public key via keccak256(pubkey)[12..32].
32-byte Ed25519 public key.
20-byte owner address. Equivalent to
keccak256(pubkey).slice(12, 32).ownerToHex(owner)
Converts a 20-byte owner address to its lowercase hexadecimal string representation (no 0x prefix).
20-byte owner address, typically produced by
pubkeyToOwner.40-character lowercase hex string with no
0x prefix.Hex Utilities
hexToBytes(hex)
Parses a hex string into a Uint8Array. Accepts strings with or without a 0x prefix.
Hex-encoded string, optionally prefixed with
0x. Length must be even.Raw bytes decoded from the hex string.
bytesToHex(bytes)
Encodes a Uint8Array as a lowercase hex string with no 0x prefix.
Byte array to encode.
Lowercase hex string. Two characters per input byte, no prefix.
Chain ID Helpers
chainIdFromString(chainId)
Hashes a CometBFT chain ID string into the 32-byte binding used by the V3 signing envelope. Matches chain_id_from_string in Rust crypto.rs byte-for-byte.
GET /info. Use fetchChainId (exported from the client module) to retrieve and cache it automatically.
UTF-8 CometBFT chain ID string, e.g.
"proof-mainnet-1".32-byte
keccak256 digest of the UTF-8 encoded chain ID string.UNBOUND_CHAIN_ID
A constant Uint8Array of 32 zero bytes representing an unbound chain. Never submit transactions signed with UNBOUND_CHAIN_ID to a production deployment — signatures are trivially replayable across any chain that shares a zero chain binding.
Signing
signingMessage(chainId, actionType, seq, payload)
Constructs the deterministic byte sequence that is signed (and later verified) for every transaction. The V3 layout is:
"ProofExchange-v3" (16 bytes). This separator was introduced on 2026-04-23 (audit finding B4) when the envelope gained the 32-byte chain ID binding, protecting against cross-chain and post-wipe replay attacks.
32-byte chain ID. Must be exactly 32 bytes — the function throws if the length differs. Use
chainIdFromString or UNBOUND_CHAIN_ID (tests only).Single-byte action type wire value from the
ActionType constant object (e.g. 0x01 for PlaceOrder).Monotonically increasing sequence number encoded as a big-endian unsigned 64-bit integer (8 bytes). Typically
BigInt(Date.now()).MessagePack-encoded action payload bytes, as produced by
encodePayloadBytes.Complete signing message:
16 + 32 + 1 + 8 + payload.length bytes.sign(privateKey, message)
Signs an arbitrary message with an Ed25519 private key using @noble/ed25519. The library requires sha512 to be injected synchronously — crypto.ts handles this automatically at import time.
32-byte Ed25519 secret key.
Raw bytes to sign. Pass the output of
signingMessage for transaction signing.64-byte Ed25519 signature
(R || S).verify(publicKey, signature, message)
Verifies an Ed25519 signature against a public key and message.
32-byte Ed25519 public key of the signer.
64-byte Ed25519 signature to verify.
Original message bytes that were signed.
true if the signature is valid for the given public key and message; false otherwise.Full Offline Signing Example
Underlying Libraries
| Library | Purpose |
|---|---|
@noble/ed25519 | Ed25519 keypair generation, signing (sign), and verification (verify). V3 requires hashes.sha512 to be injected — crypto.ts does this at module load time. |
@noble/hashes/sha3 | keccak_256 used by pubkeyToOwner and chainIdFromString. |
@noble/hashes/sha2 | sha512 injected into @noble/ed25519’s synchronous hash hook. |