Trait o1vm::interpreters::riscv32i::interpreter::InterpreterEnv
source · pub trait InterpreterEnv {
type Position;
type Variable: Clone + Add<Self::Variable, Output = Self::Variable> + Sub<Self::Variable, Output = Self::Variable> + Mul<Self::Variable, Output = Self::Variable> + Debug + Zero + One;
Show 71 methods
// Required methods
fn alloc_scratch(&mut self) -> Self::Position;
fn variable(&self, column: Self::Position) -> Self::Variable;
fn add_constraint(&mut self, assert_equals_zero: Self::Variable);
fn activate_selector(&mut self, selector: Instruction);
fn check_is_zero(assert_equals_zero: &Self::Variable);
fn check_equal(x: &Self::Variable, y: &Self::Variable);
fn check_boolean(x: &Self::Variable);
fn add_lookup(&mut self, lookup: RAMLookup<Self::Variable, LookupTableIDs>);
fn instruction_counter(&self) -> Self::Variable;
fn increase_instruction_counter(&mut self);
unsafe fn fetch_register(
&mut self,
idx: &Self::Variable,
output: Self::Position
) -> Self::Variable;
unsafe fn push_register_if(
&mut self,
idx: &Self::Variable,
value: Self::Variable,
if_is_true: &Self::Variable
);
unsafe fn fetch_register_access(
&mut self,
idx: &Self::Variable,
output: Self::Position
) -> Self::Variable;
unsafe fn push_register_access_if(
&mut self,
idx: &Self::Variable,
value: Self::Variable,
if_is_true: &Self::Variable
);
unsafe fn fetch_memory(
&mut self,
addr: &Self::Variable,
output: Self::Position
) -> Self::Variable;
unsafe fn push_memory(
&mut self,
addr: &Self::Variable,
value: Self::Variable
);
unsafe fn fetch_memory_access(
&mut self,
addr: &Self::Variable,
output: Self::Position
) -> Self::Variable;
unsafe fn push_memory_access(
&mut self,
addr: &Self::Variable,
value: Self::Variable
);
fn constant(x: u32) -> Self::Variable;
unsafe fn bitmask(
&mut self,
x: &Self::Variable,
highest_bit: u32,
lowest_bit: u32,
position: Self::Position
) -> Self::Variable;
unsafe fn shift_left(
&mut self,
x: &Self::Variable,
by: &Self::Variable,
position: Self::Position
) -> Self::Variable;
unsafe fn shift_right(
&mut self,
x: &Self::Variable,
by: &Self::Variable,
position: Self::Position
) -> Self::Variable;
unsafe fn shift_right_arithmetic(
&mut self,
x: &Self::Variable,
by: &Self::Variable,
position: Self::Position
) -> Self::Variable;
unsafe fn test_zero(
&mut self,
x: &Self::Variable,
position: Self::Position
) -> Self::Variable;
unsafe fn inverse_or_zero(
&mut self,
x: &Self::Variable,
position: Self::Position
) -> Self::Variable;
fn is_zero(&mut self, x: &Self::Variable) -> Self::Variable;
fn equal(
&mut self,
x: &Self::Variable,
y: &Self::Variable
) -> Self::Variable;
unsafe fn test_less_than(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position: Self::Position
) -> Self::Variable;
unsafe fn test_less_than_signed(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position: Self::Position
) -> Self::Variable;
unsafe fn and_witness(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position: Self::Position
) -> Self::Variable;
unsafe fn or_witness(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position: Self::Position
) -> Self::Variable;
unsafe fn nor_witness(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position: Self::Position
) -> Self::Variable;
unsafe fn xor_witness(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position: Self::Position
) -> Self::Variable;
unsafe fn add_witness(
&mut self,
y: &Self::Variable,
x: &Self::Variable,
out_position: Self::Position,
overflow_position: Self::Position
) -> (Self::Variable, Self::Variable);
unsafe fn sub_witness(
&mut self,
y: &Self::Variable,
x: &Self::Variable,
out_position: Self::Position,
underflow_position: Self::Position
) -> (Self::Variable, Self::Variable);
unsafe fn mul_signed_witness(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position: Self::Position
) -> Self::Variable;
unsafe fn mul_hi_lo_signed(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position_hi: Self::Position,
position_lo: Self::Position
) -> (Self::Variable, Self::Variable);
unsafe fn mul_hi_lo(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position_hi: Self::Position,
position_lo: Self::Position
) -> (Self::Variable, Self::Variable);
unsafe fn divmod_signed(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position_quotient: Self::Position,
position_remainder: Self::Position
) -> (Self::Variable, Self::Variable);
unsafe fn divmod(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position_quotient: Self::Position,
position_remainder: Self::Position
) -> (Self::Variable, Self::Variable);
unsafe fn count_leading_zeros(
&mut self,
x: &Self::Variable,
position: Self::Position
) -> Self::Variable;
unsafe fn count_leading_ones(
&mut self,
x: &Self::Variable,
position: Self::Position
) -> Self::Variable;
fn copy(
&mut self,
x: &Self::Variable,
position: Self::Position
) -> Self::Variable;
fn set_halted(&mut self, flag: Self::Variable);
fn report_exit(&mut self, exit_code: &Self::Variable);
fn reset(&mut self);
// Provided methods
fn assert_is_zero(&mut self, assert_equals_zero: Self::Variable) { ... }
fn assert_equal(&mut self, x: Self::Variable, y: Self::Variable) { ... }
fn assert_boolean(&mut self, x: Self::Variable) { ... }
unsafe fn push_register(
&mut self,
idx: &Self::Variable,
value: Self::Variable
) { ... }
unsafe fn push_register_access(
&mut self,
idx: &Self::Variable,
value: Self::Variable
) { ... }
unsafe fn access_register_if(
&mut self,
idx: &Self::Variable,
old_value: &Self::Variable,
new_value: &Self::Variable,
if_is_true: &Self::Variable
) { ... }
fn read_register(&mut self, idx: &Self::Variable) -> Self::Variable { ... }
unsafe fn access_register(
&mut self,
idx: &Self::Variable,
old_value: &Self::Variable,
new_value: &Self::Variable
) { ... }
fn write_register_if(
&mut self,
idx: &Self::Variable,
new_value: Self::Variable,
if_is_true: &Self::Variable
) { ... }
fn write_register(
&mut self,
idx: &Self::Variable,
new_value: Self::Variable
) { ... }
unsafe fn access_memory(
&mut self,
addr: &Self::Variable,
old_value: &Self::Variable,
new_value: &Self::Variable
) { ... }
fn read_memory(&mut self, addr: &Self::Variable) -> Self::Variable { ... }
fn write_memory(&mut self, addr: &Self::Variable, new_value: Self::Variable) { ... }
fn lookup_16bits(&mut self, value: &Self::Variable) { ... }
fn range_check16(&mut self, value: &Self::Variable, bits: u32) { ... }
fn lookup_8bits(&mut self, value: &Self::Variable) { ... }
fn range_check8(&mut self, value: &Self::Variable, bits: u32) { ... }
fn lookup_2bits(&mut self, value: &Self::Variable) { ... }
fn range_check64(&mut self, _value: &Self::Variable) { ... }
fn set_instruction_pointer(&mut self, ip: Self::Variable) { ... }
fn get_instruction_pointer(&mut self) -> Self::Variable { ... }
fn set_next_instruction_pointer(&mut self, ip: Self::Variable) { ... }
fn get_next_instruction_pointer(&mut self) -> Self::Variable { ... }
fn increase_heap_pointer(
&mut self,
by_amount: &Self::Variable,
if_is_true: &Self::Variable
) -> Self::Variable { ... }
fn sign_extend(
&mut self,
x: &Self::Variable,
bitlength: u32
) -> Self::Variable { ... }
}
Required Associated Types§
type Variable: Clone + Add<Self::Variable, Output = Self::Variable> + Sub<Self::Variable, Output = Self::Variable> + Mul<Self::Variable, Output = Self::Variable> + Debug + Zero + One
Required Methods§
sourcefn alloc_scratch(&mut self) -> Self::Position
fn alloc_scratch(&mut self) -> Self::Position
Allocate a new abstract variable for the current step. The variable can be used to store temporary values. The variables are “freed” after each step/instruction. The variable allocation can be seen as an allocation on a stack that is popped after each step execution. At the moment, crate::interpreters::riscv32i::SCRATCH_SIZE elements can be allocated. If more temporary variables are required for an instruction, increase the value crate::interpreters::riscv32i::SCRATCH_SIZE
fn variable(&self, column: Self::Position) -> Self::Variable
sourcefn add_constraint(&mut self, assert_equals_zero: Self::Variable)
fn add_constraint(&mut self, assert_equals_zero: Self::Variable)
Add a constraint to the proof system, asserting that
assert_equals_zero
is 0.
sourcefn activate_selector(&mut self, selector: Instruction)
fn activate_selector(&mut self, selector: Instruction)
Activate the selector for the given instruction.
sourcefn check_is_zero(assert_equals_zero: &Self::Variable)
fn check_is_zero(assert_equals_zero: &Self::Variable)
Check that the witness value in assert_equals_zero
is 0; otherwise abort.
sourcefn check_equal(x: &Self::Variable, y: &Self::Variable)
fn check_equal(x: &Self::Variable, y: &Self::Variable)
Check that the witness values in x
and y
are equal; otherwise abort.
sourcefn check_boolean(x: &Self::Variable)
fn check_boolean(x: &Self::Variable)
Check that the witness value x
is a boolean (0
or 1
); otherwise abort.
fn add_lookup(&mut self, lookup: RAMLookup<Self::Variable, LookupTableIDs>)
fn instruction_counter(&self) -> Self::Variable
fn increase_instruction_counter(&mut self)
sourceunsafe fn fetch_register(
&mut self,
idx: &Self::Variable,
output: Self::Position
) -> Self::Variable
unsafe fn fetch_register( &mut self, idx: &Self::Variable, output: Self::Position ) -> Self::Variable
Fetch the value of the general purpose register with index idx
and store it in local
position output
.
Safety
No lookups or other constraints are added as part of this operation. The caller must manually add the lookups for this operation.
sourceunsafe fn push_register_if(
&mut self,
idx: &Self::Variable,
value: Self::Variable,
if_is_true: &Self::Variable
)
unsafe fn push_register_if( &mut self, idx: &Self::Variable, value: Self::Variable, if_is_true: &Self::Variable )
Set the general purpose register with index idx
to value
if if_is_true
is true.
Safety
No lookups or other constraints are added as part of this operation. The caller must manually add the lookups for this operation.
sourceunsafe fn fetch_register_access(
&mut self,
idx: &Self::Variable,
output: Self::Position
) -> Self::Variable
unsafe fn fetch_register_access( &mut self, idx: &Self::Variable, output: Self::Position ) -> Self::Variable
Fetch the last ‘access index’ for the general purpose register with index idx
, and store
it in local position output
.
Safety
No lookups or other constraints are added as part of this operation. The caller must manually add the lookups for this operation.
sourceunsafe fn push_register_access_if(
&mut self,
idx: &Self::Variable,
value: Self::Variable,
if_is_true: &Self::Variable
)
unsafe fn push_register_access_if( &mut self, idx: &Self::Variable, value: Self::Variable, if_is_true: &Self::Variable )
Set the last ‘access index’ for the general purpose register with index idx
to value
if
if_is_true
is true.
Safety
No lookups or other constraints are added as part of this operation. The caller must manually add the lookups for this operation.
sourceunsafe fn fetch_memory(
&mut self,
addr: &Self::Variable,
output: Self::Position
) -> Self::Variable
unsafe fn fetch_memory( &mut self, addr: &Self::Variable, output: Self::Position ) -> Self::Variable
Fetch the memory value at address addr
and store it in local position output
.
Safety
No lookups or other constraints are added as part of this operation. The caller must manually add the lookups for this memory operation.
sourceunsafe fn push_memory(&mut self, addr: &Self::Variable, value: Self::Variable)
unsafe fn push_memory(&mut self, addr: &Self::Variable, value: Self::Variable)
Set the memory value at address addr
to value
.
Safety
No lookups or other constraints are added as part of this operation. The caller must manually add the lookups for this memory operation.
sourceunsafe fn fetch_memory_access(
&mut self,
addr: &Self::Variable,
output: Self::Position
) -> Self::Variable
unsafe fn fetch_memory_access( &mut self, addr: &Self::Variable, output: Self::Position ) -> Self::Variable
Fetch the last ‘access index’ that the memory at address addr
was written at, and store
it in local position output
.
Safety
No lookups or other constraints are added as part of this operation. The caller must manually add the lookups for this memory operation.
sourceunsafe fn push_memory_access(
&mut self,
addr: &Self::Variable,
value: Self::Variable
)
unsafe fn push_memory_access( &mut self, addr: &Self::Variable, value: Self::Variable )
Set the last ‘access index’ for the memory at address addr
to value
.
Safety
No lookups or other constraints are added as part of this operation. The caller must manually add the lookups for this memory operation.
fn constant(x: u32) -> Self::Variable
sourceunsafe fn bitmask(
&mut self,
x: &Self::Variable,
highest_bit: u32,
lowest_bit: u32,
position: Self::Position
) -> Self::Variable
unsafe fn bitmask( &mut self, x: &Self::Variable, highest_bit: u32, lowest_bit: u32, position: Self::Position ) -> Self::Variable
Extract the bits from the variable x
between highest_bit
and lowest_bit
, and store
the result in position
.
lowest_bit
becomes the least-significant bit of the resulting value.
Safety
There are no constraints on the returned value; callers must assert the relationship with
the source variable x
and that the returned value fits in highest_bit - lowest_bit
bits.
Do not call this function with highest_bit - lowest_bit >= 32.
sourceunsafe fn shift_left(
&mut self,
x: &Self::Variable,
by: &Self::Variable,
position: Self::Position
) -> Self::Variable
unsafe fn shift_left( &mut self, x: &Self::Variable, by: &Self::Variable, position: Self::Position ) -> Self::Variable
Return the result of shifting x
by by
, storing the result in position
.
Safety
There are no constraints on the returned value; callers must assert the relationship with
the source variable x
and the shift amount by
.
sourceunsafe fn shift_right(
&mut self,
x: &Self::Variable,
by: &Self::Variable,
position: Self::Position
) -> Self::Variable
unsafe fn shift_right( &mut self, x: &Self::Variable, by: &Self::Variable, position: Self::Position ) -> Self::Variable
Return the result of shifting x
by by
, storing the result in position
.
Safety
There are no constraints on the returned value; callers must assert the relationship with
the source variable x
and the shift amount by
.
sourceunsafe fn shift_right_arithmetic(
&mut self,
x: &Self::Variable,
by: &Self::Variable,
position: Self::Position
) -> Self::Variable
unsafe fn shift_right_arithmetic( &mut self, x: &Self::Variable, by: &Self::Variable, position: Self::Position ) -> Self::Variable
Return the result of shifting x
by by
, storing the result in position
.
Safety
There are no constraints on the returned value; callers must assert the relationship with
the source variable x
and the shift amount by
.
sourceunsafe fn test_zero(
&mut self,
x: &Self::Variable,
position: Self::Position
) -> Self::Variable
unsafe fn test_zero( &mut self, x: &Self::Variable, position: Self::Position ) -> Self::Variable
Returns 1 if x
is 0, or 0 otherwise, storing the result in position
.
Safety
There are no constraints on the returned value; callers must assert the relationship with
x
.
sourceunsafe fn inverse_or_zero(
&mut self,
x: &Self::Variable,
position: Self::Position
) -> Self::Variable
unsafe fn inverse_or_zero( &mut self, x: &Self::Variable, position: Self::Position ) -> Self::Variable
Returns x^(-1)
, or 0
if x
is 0
, storing the result in position
.
Safety
There are no constraints on the returned value; callers must assert the relationship with
x
.
The value returned may be a placeholder; callers should be careful not to depend directly on the value stored in the variable.
fn is_zero(&mut self, x: &Self::Variable) -> Self::Variable
sourcefn equal(&mut self, x: &Self::Variable, y: &Self::Variable) -> Self::Variable
fn equal(&mut self, x: &Self::Variable, y: &Self::Variable) -> Self::Variable
Returns 1 if x
is equal to y
, or 0 otherwise, storing the result in position
.
sourceunsafe fn test_less_than(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position: Self::Position
) -> Self::Variable
unsafe fn test_less_than( &mut self, x: &Self::Variable, y: &Self::Variable, position: Self::Position ) -> Self::Variable
Returns 1 if x < y
as unsigned integers, or 0 otherwise, storing the result in
position
.
Safety
There are no constraints on the returned value; callers must assert that the value
correctly represents the relationship between x
and y
sourceunsafe fn test_less_than_signed(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position: Self::Position
) -> Self::Variable
unsafe fn test_less_than_signed( &mut self, x: &Self::Variable, y: &Self::Variable, position: Self::Position ) -> Self::Variable
Returns 1 if x < y
as signed integers, or 0 otherwise, storing the result in position
.
Safety
There are no constraints on the returned value; callers must assert that the value
correctly represents the relationship between x
and y
sourceunsafe fn and_witness(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position: Self::Position
) -> Self::Variable
unsafe fn and_witness( &mut self, x: &Self::Variable, y: &Self::Variable, position: Self::Position ) -> Self::Variable
Returns x or y
, storing the result in position
.
Safety
There are no constraints on the returned value; callers must manually add constraints to ensure that it is correctly constructed.
sourceunsafe fn or_witness(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position: Self::Position
) -> Self::Variable
unsafe fn or_witness( &mut self, x: &Self::Variable, y: &Self::Variable, position: Self::Position ) -> Self::Variable
Returns x or y
, storing the result in position
.
Safety
There are no constraints on the returned value; callers must manually add constraints to ensure that it is correctly constructed.
sourceunsafe fn nor_witness(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position: Self::Position
) -> Self::Variable
unsafe fn nor_witness( &mut self, x: &Self::Variable, y: &Self::Variable, position: Self::Position ) -> Self::Variable
Returns x nor y
, storing the result in position
.
Safety
There are no constraints on the returned value; callers must manually add constraints to ensure that it is correctly constructed.
sourceunsafe fn xor_witness(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position: Self::Position
) -> Self::Variable
unsafe fn xor_witness( &mut self, x: &Self::Variable, y: &Self::Variable, position: Self::Position ) -> Self::Variable
Returns x xor y
, storing the result in position
.
Safety
There are no constraints on the returned value; callers must manually add constraints to ensure that it is correctly constructed.
sourceunsafe fn add_witness(
&mut self,
y: &Self::Variable,
x: &Self::Variable,
out_position: Self::Position,
overflow_position: Self::Position
) -> (Self::Variable, Self::Variable)
unsafe fn add_witness( &mut self, y: &Self::Variable, x: &Self::Variable, out_position: Self::Position, overflow_position: Self::Position ) -> (Self::Variable, Self::Variable)
Returns x + y
and the overflow bit, storing the results in position_out
and
position_overflow
respectively.
Safety
There are no constraints on the returned values; callers must manually add constraints to ensure that they are correctly constructed.
sourceunsafe fn sub_witness(
&mut self,
y: &Self::Variable,
x: &Self::Variable,
out_position: Self::Position,
underflow_position: Self::Position
) -> (Self::Variable, Self::Variable)
unsafe fn sub_witness( &mut self, y: &Self::Variable, x: &Self::Variable, out_position: Self::Position, underflow_position: Self::Position ) -> (Self::Variable, Self::Variable)
Returns x + y
and the underflow bit, storing the results in position_out
and
position_underflow
respectively.
Safety
There are no constraints on the returned values; callers must manually add constraints to ensure that they are correctly constructed.
sourceunsafe fn mul_signed_witness(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position: Self::Position
) -> Self::Variable
unsafe fn mul_signed_witness( &mut self, x: &Self::Variable, y: &Self::Variable, position: Self::Position ) -> Self::Variable
Returns x * y
, where x
and y
are treated as integers, storing the result in position
.
Safety
There are no constraints on the returned value; callers must manually add constraints to ensure that it is correctly constructed.
sourceunsafe fn mul_hi_lo_signed(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position_hi: Self::Position,
position_lo: Self::Position
) -> (Self::Variable, Self::Variable)
unsafe fn mul_hi_lo_signed( &mut self, x: &Self::Variable, y: &Self::Variable, position_hi: Self::Position, position_lo: Self::Position ) -> (Self::Variable, Self::Variable)
Returns ((x * y) >> 32, (x * y) & ((1 << 32) - 1))
, storing the results in position_hi
and position_lo
respectively.
Safety
There are no constraints on the returned values; callers must manually add constraints to
ensure that the pair of returned values correspond to the given values x
and y
, and
that they fall within the desired range.
sourceunsafe fn mul_hi_lo(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position_hi: Self::Position,
position_lo: Self::Position
) -> (Self::Variable, Self::Variable)
unsafe fn mul_hi_lo( &mut self, x: &Self::Variable, y: &Self::Variable, position_hi: Self::Position, position_lo: Self::Position ) -> (Self::Variable, Self::Variable)
Returns ((x * y) >> 32, (x * y) & ((1 << 32) - 1))
, storing the results in position_hi
and position_lo
respectively.
Safety
There are no constraints on the returned values; callers must manually add constraints to
ensure that the pair of returned values correspond to the given values x
and y
, and
that they fall within the desired range.
sourceunsafe fn divmod_signed(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position_quotient: Self::Position,
position_remainder: Self::Position
) -> (Self::Variable, Self::Variable)
unsafe fn divmod_signed( &mut self, x: &Self::Variable, y: &Self::Variable, position_quotient: Self::Position, position_remainder: Self::Position ) -> (Self::Variable, Self::Variable)
Returns (x / y, x % y)
, storing the results in position_quotient
and
position_remainder
respectively.
Safety
There are no constraints on the returned values; callers must manually add constraints to
ensure that the pair of returned values correspond to the given values x
and y
, and
that they fall within the desired range.
sourceunsafe fn divmod(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position_quotient: Self::Position,
position_remainder: Self::Position
) -> (Self::Variable, Self::Variable)
unsafe fn divmod( &mut self, x: &Self::Variable, y: &Self::Variable, position_quotient: Self::Position, position_remainder: Self::Position ) -> (Self::Variable, Self::Variable)
Returns (x / y, x % y)
, storing the results in position_quotient
and
position_remainder
respectively.
Safety
There are no constraints on the returned values; callers must manually add constraints to
ensure that the pair of returned values correspond to the given values x
and y
, and
that they fall within the desired range.
sourceunsafe fn count_leading_zeros(
&mut self,
x: &Self::Variable,
position: Self::Position
) -> Self::Variable
unsafe fn count_leading_zeros( &mut self, x: &Self::Variable, position: Self::Position ) -> Self::Variable
Returns the number of leading 0s in x
, storing the result in position
.
Safety
There are no constraints on the returned value; callers must manually add constraints to ensure that it is correctly constructed.
sourceunsafe fn count_leading_ones(
&mut self,
x: &Self::Variable,
position: Self::Position
) -> Self::Variable
unsafe fn count_leading_ones( &mut self, x: &Self::Variable, position: Self::Position ) -> Self::Variable
Returns the number of leading 1s in x
, storing the result in position
.
Safety
There are no constraints on the returned value; callers must manually add constraints to ensure that it is correctly constructed.
fn copy( &mut self, x: &Self::Variable, position: Self::Position ) -> Self::Variable
fn set_halted(&mut self, flag: Self::Variable)
fn report_exit(&mut self, exit_code: &Self::Variable)
fn reset(&mut self)
Provided Methods§
sourcefn assert_is_zero(&mut self, assert_equals_zero: Self::Variable)
fn assert_is_zero(&mut self, assert_equals_zero: Self::Variable)
Assert that the value assert_equals_zero
is 0, and add a constraint in the proof system.
sourcefn assert_equal(&mut self, x: Self::Variable, y: Self::Variable)
fn assert_equal(&mut self, x: Self::Variable, y: Self::Variable)
Assert that the values x
and y
are equal, and add a constraint in the proof system.
sourcefn assert_boolean(&mut self, x: Self::Variable)
fn assert_boolean(&mut self, x: Self::Variable)
Assert that the value x
is boolean, and add a constraint in the proof system.
sourceunsafe fn push_register(&mut self, idx: &Self::Variable, value: Self::Variable)
unsafe fn push_register(&mut self, idx: &Self::Variable, value: Self::Variable)
Set the general purpose register with index idx
to value
.
Safety
No lookups or other constraints are added as part of this operation. The caller must manually add the lookups for this operation.
sourceunsafe fn push_register_access(
&mut self,
idx: &Self::Variable,
value: Self::Variable
)
unsafe fn push_register_access( &mut self, idx: &Self::Variable, value: Self::Variable )
Set the last ‘access index’ for the general purpose register with index idx
to value
.
Safety
No lookups or other constraints are added as part of this operation. The caller must manually add the lookups for this operation.
sourceunsafe fn access_register_if(
&mut self,
idx: &Self::Variable,
old_value: &Self::Variable,
new_value: &Self::Variable,
if_is_true: &Self::Variable
)
unsafe fn access_register_if( &mut self, idx: &Self::Variable, old_value: &Self::Variable, new_value: &Self::Variable, if_is_true: &Self::Variable )
Access the general purpose register with index idx
, adding constraints asserting that the
old value was old_value
and that the new value will be new_value
, if if_is_true
is
true.
Safety
Callers of this function must manually update the registers if required, this function will only update the access counter.
fn read_register(&mut self, idx: &Self::Variable) -> Self::Variable
sourceunsafe fn access_register(
&mut self,
idx: &Self::Variable,
old_value: &Self::Variable,
new_value: &Self::Variable
)
unsafe fn access_register( &mut self, idx: &Self::Variable, old_value: &Self::Variable, new_value: &Self::Variable )
Access the general purpose register with index idx
, adding constraints asserting that the
old value was old_value
and that the new value will be new_value
.
Safety
Callers of this function must manually update the registers if required, this function will only update the access counter.
fn write_register_if( &mut self, idx: &Self::Variable, new_value: Self::Variable, if_is_true: &Self::Variable )
fn write_register(&mut self, idx: &Self::Variable, new_value: Self::Variable)
sourceunsafe fn access_memory(
&mut self,
addr: &Self::Variable,
old_value: &Self::Variable,
new_value: &Self::Variable
)
unsafe fn access_memory( &mut self, addr: &Self::Variable, old_value: &Self::Variable, new_value: &Self::Variable )
Access the memory address addr
, adding constraints asserting that the old value was
old_value
and that the new value will be new_value
.
Safety
Callers of this function must manually update the memory if required, this function will only update the access counter.
fn read_memory(&mut self, addr: &Self::Variable) -> Self::Variable
fn write_memory(&mut self, addr: &Self::Variable, new_value: Self::Variable)
sourcefn lookup_16bits(&mut self, value: &Self::Variable)
fn lookup_16bits(&mut self, value: &Self::Variable)
Adds a lookup to the RangeCheck16Lookup table
sourcefn range_check16(&mut self, value: &Self::Variable, bits: u32)
fn range_check16(&mut self, value: &Self::Variable, bits: u32)
Range checks with 2 lookups to the RangeCheck16Lookup table that a value
is at most 2^bits
-1 (bits <= 16).
sourcefn lookup_8bits(&mut self, value: &Self::Variable)
fn lookup_8bits(&mut self, value: &Self::Variable)
Adds a lookup to the ByteLookup table
sourcefn range_check8(&mut self, value: &Self::Variable, bits: u32)
fn range_check8(&mut self, value: &Self::Variable, bits: u32)
Range checks with 2 lookups to the ByteLookup table that a value
is at most 2^bits
-1 (bits <= 8).
sourcefn lookup_2bits(&mut self, value: &Self::Variable)
fn lookup_2bits(&mut self, value: &Self::Variable)
Adds a lookup to the AtMost4Lookup table
fn range_check64(&mut self, _value: &Self::Variable)
fn set_instruction_pointer(&mut self, ip: Self::Variable)
fn get_instruction_pointer(&mut self) -> Self::Variable
fn set_next_instruction_pointer(&mut self, ip: Self::Variable)
fn get_next_instruction_pointer(&mut self) -> Self::Variable
sourcefn increase_heap_pointer(
&mut self,
by_amount: &Self::Variable,
if_is_true: &Self::Variable
) -> Self::Variable
fn increase_heap_pointer( &mut self, by_amount: &Self::Variable, if_is_true: &Self::Variable ) -> Self::Variable
Increases the heap pointer by by_amount
if if_is_true
is 1
, and returns the previous
value of the heap pointer.
sourcefn sign_extend(&mut self, x: &Self::Variable, bitlength: u32) -> Self::Variable
fn sign_extend(&mut self, x: &Self::Variable, bitlength: u32) -> Self::Variable
Given a variable x
, this function extends it to a signed integer of
bitlength
bits.