quoteExactOutput and quoteExactOutputSingle discarded their direction into `_` and returned the exact-input projection, so a caller asking what 1000 token1 costs got what 1000 token0 buys -- wrong by the square of the price, with the fee taken off the wrong side. At price 4 it answered 4000 where the answer is 250. The two questions are inverses of one price-and-fee map: the exact-output side divides where the other multiplies and grosses the fee onto the input rather than deducting it. Every step rounds up, so the quoted input covers the output asked for and no smaller input does -- swept over five fees, five prices, both directions and six amounts, with the one-unit-lower input asserted short. The exact-input answer is unchanged, which is asserted directly. A token move refuses an address carrying no contract code. The EVM answers a CALL into such an address with success and no return data, and that is also how a non-compliant ERC-20 reports success, so the return alone cannot separate them; SafeERC20 separates them by requiring code, and now so does this. It matters on the push leg: withdraw debits the claim before it moves the token, so reading that empty return as delivery retires a claim against a transfer that did not happen. The pull leg was already covered by its delivered-amount check. One moveToken now issues both, so the requirement and the return reading cannot drift apart. Mutation: dropping the code check fails two tests. A token that HAS code and returns nothing still settles, which is asserted separately -- the refusal is bought by the code check alone. getOpenOrders charges for the record loop before running it. The order count comes from the index alone, so the bill is knowable first; the sibling enumeration on 0x9996 already charged at that point. A length read out of a storage word is bounded before it sizes an allocation. int(uint64) is negative above 2^63 and make takes that as a panic, which from a precompile is a halt rather than a refusal. slotLen is the one bound and the three readers -- record, order index, staging -- answer absent above it. This replaces a characterisation test that asserted the panic and asked to be rewritten once the bound existed. reclaim no longer stages a remove it cannot deliver. A remove names a key in the inbound space, where objects a peer exported to this chain live; the intent object went the other way, so the staged remove could never name it, and against a missing key it writes a tombstone into a namespace that has nothing to do with it. What reclaim guarantees on this chain -- the principal exits once, because the zeroed remaining caps any later settlement -- is unchanged and now stated where the comment claimed more.
Lux Precompiled Contracts
Native EVM precompiles for the Lux blockchain. Each precompile is a Go package that implements contract.StatefulPrecompiledContract and registers via modules.RegisterModule() in its init().
Geth provides NewPrecompileAdapter() to wrap these into geth-compatible precompiles. L1 chains select which precompiles to enable via PrecompileOverrider.
Precompiles
Post-Quantum Cryptography (baseline — all Lux chains)
| Package | Address | Description | Gas |
|---|---|---|---|
mldsa |
0x0200...0006 |
ML-DSA-65 signature verify (FIPS 204) | 100k + 10/byte |
slhdsa |
0x0600...0001 |
SLH-DSA signature verify (FIPS 205) | 15k–250k by mode |
mlkem |
0x0200...0007 |
ML-KEM-768 encapsulate/decapsulate | 50k base |
xwing |
0x2221 |
X-Wing hybrid KEM (X25519 + ML-KEM-768) | 40k |
Threshold Signatures
| Package | Address | Description | Gas |
|---|---|---|---|
frost |
0x0800...0002 |
FROST Schnorr threshold verify (secp256k1/Ed25519) | 50k + 5k/signer |
cggmp21 |
0x0800...0003 |
CGGMP21 threshold ECDSA verify (secp256k1) | 75k + 10k/signer |
Corona |
0x0200...000B |
Module-LWE lattice threshold verify (post-quantum) | 150k + 10k/party |
Curves & Signatures
| Package | Address | Description | Gas |
|---|---|---|---|
sr25519 |
0x0A00...0001 |
Schnorrkel verify for Substrate→EVM migration | 9k + 3/byte |
ed25519 |
0x3211...0000 |
Ed25519 signature verify | 3k |
secp256r1 |
0x0100 |
P-256 ECDSA verify (WebAuthn/passkeys) | 3.5k |
Hashing
| Package | Address | Description | Gas |
|---|---|---|---|
blake3 |
0x0500...0004 |
Blake3 hash, Merkle root, KDF, XOF | 100 + 3–5/word |
kzg4844 |
0xB002 |
KZG polynomial commitment (EIP-4844) | 50k |
Privacy & ZK
| Package | Address | Description | Gas |
|---|---|---|---|
zk |
0x0900 |
ZK proof verification (Groth16, PLONK, fflonk, Halo2) | 180k–500k |
fhe |
— | Fully homomorphic encryption ops | variable |
ring |
0x9202 |
Ring signature verification | variable |
ecies |
0x9201 |
ECIES encryption/decryption | variable |
hpke |
0x9200 |
Hybrid public key encryption | variable |
DEX
| Package | Address | Description | Gas |
|---|---|---|---|
dex |
0x0400...0000 |
Native DEX (PoolManager, Router, Hooks, Lending) | variable |
Infrastructure
| Package | Address | Description | Gas |
|---|---|---|---|
ai |
0x0300...0000 |
AI mining (ML-DSA verify, TEE attestation, rewards) | variable |
quasar |
— | Hybrid consensus certificate verification | variable |
dead |
0x0000...0000 |
Dead address interceptor | minimal |
graph |
— | GraphQL query precompile | variable |
bridge |
— | Cross-chain bridge verification | variable |
attestation |
0x0300...0001-05 |
TEE/GPU attestation (NVTrust, TPM, SGX/SEV/TDX) | 25k–75k |
anchor |
0x0700...0010 |
Cross-chain state anchoring | 2.6k–25k |
vrf |
0x3213 |
ECVRF verify (RFC 9381) | 20k |
compute |
0x0300...0010 |
AI compute attestation | variable |
Support Packages
| Package | Purpose |
|---|---|
contract |
Core interfaces (StatefulPrecompiledContract, AccessibleState) |
modules |
Module registration system and reserved address ranges |
precompileconfig |
Config interfaces (Upgrade, Timestamp, IsDisabled) |
registry |
Address-to-LP mapping |
Structure
Each precompile follows this pattern:
<name>/
├── contract.go # Run(), RequiredGas(), Address()
├── contract_test.go # Tests with known vectors
├── module.go # init() → modules.RegisterModule()
└── I<Name>.sol # Solidity interface (optional)
Adding a Precompile
- Pick an address in a reserved range
- Implement
contract.StatefulPrecompiledContract - Register via
modules.RegisterModule()ininit() - Add tests (valid, invalid, gas, edge cases)
- Wire into your L1 via
PrecompileOverrideror geth'sLuxPrecompiles()
Building
go build ./...
go test ./...
go test -bench=. ./sr25519/ # benchmark a specific package
CGO is required for sr25519 (sr25519-donna C library). All other packages are pure Go.
License
Copyright (C) 2025, Lux Industries, Inc. All rights reserved.
ZK-Friendly Curves (0x0500)
| Package | Address | Description | Gas |
|---|---|---|---|
poseidon |
0x0500..05 |
Poseidon/Poseidon2 hash (ZK-optimized, PQ-safe) | 800 |
pedersen |
0x0500..06 |
Pedersen commitment (legacy, NOT PQ-safe) | 6,000 |
babyjubjub |
0x0500..07 |
Baby Jubjub curve (BN254 scalar field, zkEVM) | 3,000 |
pasta |
0x0500..08 |
Pallas + Vesta curves (Halo2 proving) | 5,000 |
Symmetric & Key Exchange
| Package | Address | Description | Gas |
|---|---|---|---|
aes |
0x9210 |
AES-256-GCM authenticated encryption | 5,000 |
chacha20 |
0x9211 |
ChaCha20-Poly1305 stream cipher | 4,000 |
x25519 |
0x9203 |
X25519 Diffie-Hellman key exchange | 10,000 |
xwing |
0x0200..0C |
X-Wing hybrid KEM (X25519 + ML-KEM-768) | 50,000 |
curve25519 |
0x9204 |
Raw Curve25519 point operations | 5,000 |
Math (0x0450)
| Package | Address | Description | Gas |
|---|---|---|---|
math |
0x0450 |
MulDiv, Sqrt, Log2, Exp, Pow (fixed-point) | 50 + 5/word |
Saves ~2000 gas per MulDiv vs Solidity. Used by every DeFi calculation.
StableSwap (0x0460)
| Package | Address | Description | Gas |
|---|---|---|---|
stableswap |
0x0460 |
Curve-style constant-sum AMM | 5,000 |
10x gas savings vs Solidity StableSwap. For pegged-asset pools (LUSD/USDC, LETH/stETH).
Compute Market (0x0310)
| Package | Address | Description | Gas |
|---|---|---|---|
compute |
0x0310 |
AI compute marketplace | 10,000-50,000 |
Integrates with A-Chain TEE attestation. Register GPU providers, submit jobs, verify compute, claim $AI rewards.