|
LLZK 2.0.0
An open-source IR for Zero Knowledge (ZK) circuits
|
R1CS
Add two linear expressions
Syntax:
Traits: AlwaysSpeculatableImplTrait, Commutative
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| lhs | R1CS linear expression type |
| rhs | R1CS linear expression type |
| Result | Description |
|---|---|
| sum | R1CS linear expression type |
Defines an R1CS circuit with labeled inputs and constraints
The r1cs.circuit operation defines a named circuit, with explicit inputs and internally declared signals and constraints.
Signals defined with r1cs.def and marked public are considered outputs.
Example:
Traits: IsolatedFromAbove, NoTerminator, SingleBlock
Interfaces: Symbol
| Attribute | MLIR Type | Description |
|---|---|---|
sym_name | ::mlir::StringAttr | string attribute |
arg_attrs | ::mlir::DictionaryAttr | dictionary of named attribute values |
Create a constant linear value
Syntax:
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Attribute | MLIR Type | Description |
|---|---|---|
value | ::r1cs::FeltAttr | Field element represented as an arbitrary precision integer |
| Result | Description |
|---|---|
| out | R1CS linear expression type |
Enforce a * b - c = 0 R1CS constraint
Syntax:
| Operand | Description |
|---|---|
| a | R1CS linear expression type |
| b | R1CS linear expression type |
| c | R1CS linear expression type |
Define a signal with label and optional public visibility
Syntax:
The def op creates a new signal associated with a numeric label.
If the optional public keyword is present, the signal is treated as a public output of the circuit. Otherwise, it is considered private/internal.
Example:
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Attribute | MLIR Type | Description |
|---|---|---|
label | mlir::IntegerAttr | 32-bit unsigned integer attribute |
pub | ::r1cs::PublicAttr | An attribute to mark a type as public |
| Result | Description |
|---|---|
| out | R1CS signal wire type |
Scale a linear expression by a constant
Syntax:
Traits: AlwaysSpeculatableImplTrait, Commutative
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Attribute | MLIR Type | Description |
|---|---|---|
constValue | ::r1cs::FeltAttr | Field element represented as an arbitrary precision integer |
| Operand | Description |
|---|---|
| input | R1CS linear expression type |
| Result | Description |
|---|---|
| scaled | R1CS linear expression type |
Negate a linear expression
Syntax:
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| input | R1CS linear expression type |
| Result | Description |
|---|---|
| neg | R1CS linear expression type |
Casts a signal to a linear expression
Syntax:
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
| Operand | Description |
|---|---|
| input | R1CS signal wire type |
| Result | Description |
|---|---|
| output | R1CS linear expression type |
Field element represented as an arbitrary precision integer
Syntax:
| Parameter | C++ type | Description |
|---|---|---|
| value | mlir::IntegerAttr |
An attribute to mark a type as public
Syntax: #r1cs.pub
Examples:
R1CS linear expression type
Syntax: !r1cs.linear
R1CS signal wire type
Syntax: !r1cs.signal