|
LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
|
Allows LLZK to be lowered to PCL (Picus Constraint Language) for use with the Picus verifier
PCL
Field addition
Syntax:
Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| lhs | Finite field element |
| rhs | Finite field element |
| Result | Description |
|---|---|
| result | Finite field element |
Boolean conjunction (lhs && rhs)
Syntax:
Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| lhs | Boolean in {0,1} |
| rhs | Boolean in {0,1} |
| Result | Description |
|---|---|
| result | Boolean in {0,1} |
Bool to felt conversion
Syntax:
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| value | Boolean in {0,1} |
| Result | Description |
|---|---|
| result | Finite field element |
Assert that a boolean holds
Syntax:
| Operand | Description |
|---|---|
| cond | Boolean in {0,1} |
Assume the given value is deterministic
Syntax:
| Operand | Description |
|---|---|
| v | Finite field element |
Constant felt
Syntax:
Traits: AlwaysSpeculatableImplTrait, ConstantLike
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Attribute | MLIR Type | Description |
|---|---|---|
value | ::pcl::FeltAttr | Field element represented as an arbitrary precision integer |
| Result | Description |
|---|---|
| res | Finite field element |
Returns true iff $expr deterministic
Syntax:
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| value | Finite field element |
| Result | Description |
|---|---|
| result | Boolean in {0,1} |
Lhs == rhs (field equality)
Syntax:
Traits: AlwaysSpeculatableImplTrait, Commutative
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| lhs | Finite field element |
| rhs | Finite field element |
| Result | Description |
|---|---|
| result | Boolean in {0,1} |
Constant false value
Syntax:
Traits: AlwaysSpeculatableImplTrait, ConstantLike
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Result | Description |
|---|---|
| res | Boolean in {0,1} |
Lhs >= rhs
Syntax:
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| lhs | Finite field element |
| rhs | Finite field element |
| Result | Description |
|---|---|
| result | Boolean in {0,1} |
Lhs > rhs
Syntax:
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| lhs | Finite field element |
| rhs | Finite field element |
| Result | Description |
|---|---|
| result | Boolean in {0,1} |
Boolean equivalence (lhs <=> rhs)
Syntax:
Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| lhs | Boolean in {0,1} |
| rhs | Boolean in {0,1} |
| Result | Description |
|---|---|
| result | Boolean in {0,1} |
Boolean implication (lhs => rhs)
Syntax:
Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| lhs | Boolean in {0,1} |
| rhs | Boolean in {0,1} |
| Result | Description |
|---|---|
| result | Boolean in {0,1} |
Lhs <= rhs
Syntax:
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| lhs | Finite field element |
| rhs | Finite field element |
| Result | Description |
|---|---|
| result | Boolean in {0,1} |
Lhs < rhs
Syntax:
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| lhs | Finite field element |
| rhs | Finite field element |
| Result | Description |
|---|---|
| result | Boolean in {0,1} |
Field multiplication
Syntax:
Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| lhs | Finite field element |
| rhs | Finite field element |
| Result | Description |
|---|---|
| result | Finite field element |
Field negation
Syntax:
Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| value | Finite field element |
| Result | Description |
|---|---|
| result | Finite field element |
Boolean negation (!cond)
Syntax:
Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| value | Boolean in {0,1} |
| Result | Description |
|---|---|
| result | Boolean in {0,1} |
Boolean disjunction (lhs || rhs)
Syntax:
Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| lhs | Boolean in {0,1} |
| rhs | Boolean in {0,1} |
| Result | Description |
|---|---|
| result | Boolean in {0,1} |
Post-condition on function outputs
Syntax:
| Operand | Description |
|---|---|
| cond | Boolean in {0,1} |
Field subtraction
Syntax:
Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| lhs | Finite field element |
| rhs | Finite field element |
| Result | Description |
|---|---|
| result | Finite field element |
Constant true value
Syntax:
Traits: AlwaysSpeculatableImplTrait, ConstantLike
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Result | Description |
|---|---|
| res | Boolean in {0,1} |
Declare a felt variable.
Syntax:
The var op creates a new variable associated with a name. It additionally takes a parameter is_output which indicates an output variable if true and an intermediate otherwise.
Example:
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Attribute | MLIR Type | Description |
|---|---|---|
name | ::mlir::StringAttr | string attribute |
is_output | ::mlir::BoolAttr | bool attribute |
| Result | Description |
|---|---|
| res | Finite field element |
Field element represented as an arbitrary precision integer
Syntax:
| Parameter | C++ type | Description |
|---|---|---|
| value | llzk::APIntValue | felt constant value |
boolean value
Syntax:
| Parameter | C++ type | Description |
|---|---|---|
| value | bool |
Prime field modulus for this module
Syntax:
Attach this as a named attribute (e.g. pcl.prime) on builtin.module. Use an APInt literal so very large primes are supported.
| Parameter | C++ type | Description |
|---|---|---|
| value | llzk::APIntValue | field prime modulus |
Boolean in {0,1}
Syntax: !pcl.bool
Finite field element
Syntax: !pcl.felt