Intent Circuit Design
Intent Circuit Design
Circuit Purpose
Circom Implementation
template IntentCircuit(
MAX_NOTIONAL, // uint256: upper bound for trade size
MAX_LEVERAGE, // uint8: upper bound for leverage
MAX_SLIPPAGE, // uint256: upper bound for slippage
MAX_EXPIRY_BLOCK // uint64: maximum expiry window
) {
// Public output: final Poseidon commitment
signal output intent_commitment;
// Private inputs
signal input side; // 0 or 1
signal input notional_size; // uint256
signal input leverage; // uint8
signal input slippage; // uint256
signal input expiry; // uint64
signal input salt; // uint256
signal input margin_commitment; // field element
signal input nullifier; // field element
// --- Constraints on inputs ---
// Must be a valid direction
side * (1 - side) === 0;
// Notional size must be > 0 and <= MAX_NOTIONAL
notional_size >= 1;
notional_size <= MAX_NOTIONAL;
// Leverage must be >= 1 and <= MAX_LEVERAGE
leverage >= 1;
leverage <= MAX_LEVERAGE;
// Slippage must be >= 0 and <= MAX_SLIPPAGE
slippage >= 0;
slippage <= MAX_SLIPPAGE;
// Expiry block must be > current block and <= MAX_EXPIRY_BLOCK
// Note: actual expiry validation occurs during match time
expiry >= 1;
expiry <= MAX_EXPIRY_BLOCK;
// --- Poseidon commitment ---
// Combine all fields into a deterministic hash
component hasher = Poseidon(8);
hasher.inputs[0] <== side;
hasher.inputs[1] <== notional_size;
hasher.inputs[2] <== slippage;
hasher.inputs[3] <== leverage;
hasher.inputs[4] <== expiry;
hasher.inputs[5] <== salt;
hasher.inputs[6] <== margin_commitment;
hasher.inputs[7] <== nullifier;
intent_commitment <== hasher.output;
}Input Constraints and Boundary Handling
Direction
Notional Size
Slippage
Leverage
Expiry
Cryptographic Soundness
Security Implications
Final Output
Last updated

