Enum cairo_lang_casm::hints::CoreHint
source · pub enum CoreHint {
Show 27 variants
AllocSegment {
dst: CellRef,
},
TestLessThan {
lhs: ResOperand,
rhs: ResOperand,
dst: CellRef,
},
TestLessThanOrEqual {
lhs: ResOperand,
rhs: ResOperand,
dst: CellRef,
},
WideMul128 {
lhs: ResOperand,
rhs: ResOperand,
high: CellRef,
low: CellRef,
},
DivMod {
lhs: ResOperand,
rhs: ResOperand,
quotient: CellRef,
remainder: CellRef,
},
Uint256DivMod {
dividend_low: ResOperand,
dividend_high: ResOperand,
divisor_low: ResOperand,
divisor_high: ResOperand,
quotient0: CellRef,
quotient1: CellRef,
divisor0: CellRef,
divisor1: CellRef,
extra0: CellRef,
extra1: CellRef,
remainder_low: CellRef,
remainder_high: CellRef,
},
Uint512DivModByUint256 {
dividend0: ResOperand,
dividend1: ResOperand,
dividend2: ResOperand,
dividend3: ResOperand,
divisor0: ResOperand,
divisor1: ResOperand,
quotient0: CellRef,
quotient1: CellRef,
quotient2: CellRef,
quotient3: CellRef,
remainder0: CellRef,
remainder1: CellRef,
},
SquareRoot {
value: ResOperand,
dst: CellRef,
},
Uint256SquareRoot {
value_low: ResOperand,
value_high: ResOperand,
sqrt0: CellRef,
sqrt1: CellRef,
remainder_low: CellRef,
remainder_high: CellRef,
sqrt_mul_2_minus_remainder_ge_u128: CellRef,
},
LinearSplit {
value: ResOperand,
scalar: ResOperand,
max_x: ResOperand,
x: CellRef,
y: CellRef,
},
AllocFelt252Dict {
segment_arena_ptr: ResOperand,
},
Felt252DictEntryInit {
dict_ptr: ResOperand,
key: ResOperand,
},
Felt252DictEntryUpdate {
dict_ptr: ResOperand,
value: ResOperand,
},
GetSegmentArenaIndex {
dict_end_ptr: ResOperand,
dict_index: CellRef,
},
InitSquashData {
dict_accesses: ResOperand,
ptr_diff: ResOperand,
n_accesses: ResOperand,
big_keys: CellRef,
first_key: CellRef,
},
GetCurrentAccessIndex {
range_check_ptr: ResOperand,
},
ShouldSkipSquashLoop {
should_skip_loop: CellRef,
},
GetCurrentAccessDelta {
index_delta_minus1: CellRef,
},
ShouldContinueSquashLoop {
should_continue: CellRef,
},
GetNextDictKey {
next_key: CellRef,
},
AssertLeFindSmallArcs {
range_check_ptr: ResOperand,
a: ResOperand,
b: ResOperand,
},
AssertLeIsFirstArcExcluded {
skip_exclude_a_flag: CellRef,
},
AssertLeIsSecondArcExcluded {
skip_exclude_b_minus_a: CellRef,
},
RandomEcPoint {
x: CellRef,
y: CellRef,
},
FieldSqrt {
val: ResOperand,
sqrt: CellRef,
},
DebugPrint {
start: ResOperand,
end: ResOperand,
},
AllocConstantSize {
size: ResOperand,
dst: CellRef,
},
}
Variants§
AllocSegment
TestLessThan
TestLessThanOrEqual
WideMul128
Multiplies two 128-bit integers and returns two 128-bit integers: the high and low parts of the product.
DivMod
Computes lhs/rhs and returns the quotient and remainder.
Note: the hint may be used to write an already assigned memory cell.
Uint256DivMod
Fields
dividend_low: ResOperand
dividend_high: ResOperand
divisor_low: ResOperand
divisor_high: ResOperand
Divides dividend_low<<128+dividend_high by divisor_low<<128+divisor_high. Splits the remainder to 128bit words: remainder_low and remainder_high. Splits the quotient and the divisor to 128bit words. The lower 128 bits of the quotient are written to quotient0 and quotient1. The lower 128 bits of the divisor are written to divisor0 and divisor1. If the divisor is greater than 2^128, the upper 128 bits of the divisor are written to extra0 and extra1. In this case, quotient must be lower than 2^128. Otherwise, the upper 128 bits of the quotient are written to extra0 and extra1.
Uint512DivModByUint256
Fields
dividend0: ResOperand
dividend1: ResOperand
dividend2: ResOperand
dividend3: ResOperand
divisor0: ResOperand
divisor1: ResOperand
Divides dividend (represented by 4 128bit limbs) by divisor (represented by 2 128bit
limbs). Returns the quotient (represented by 4 128bit limbs) and remainder (represented
by 2 128bit limbs).
In all cases - name
0 is the least significant limb.
SquareRoot
Uint256SquareRoot
Computes the square root of value_low<<128+value_high, stores the 64bit limbs of the result
in sqrt0 and sqrt1 as well as the 128bit limbs of the remainder in remainder_low and
remainder_high. The remainder is defined as value - sqrt**2
.
Lastly it checks weather 2*sqrt - remainder >= 2**128
.
LinearSplit
Finds some x
and y
such that x * scalar + y = value
and x <= max_x
.
AllocFelt252Dict
Fields
segment_arena_ptr: ResOperand
Allocates a new dict segment, and write its start address into the dict_infos segment.
Felt252DictEntryInit
Fetch the previous value of a key in a dict, and write it in a new dict access.
Felt252DictEntryUpdate
Similar to Felt252DictWrite, but updates an existing entry and does not wirte the previous value to the stack.
GetSegmentArenaIndex
Retrieves the index of the given dict in the dict_infos segment.
InitSquashData
Initialized the lists of accesses of each key of a dict as a preparation of squash_dict.
GetCurrentAccessIndex
Fields
range_check_ptr: ResOperand
Retrieves the current index of a dict access to process.
ShouldSkipSquashLoop
Writes if the squash_dict loop should be skipped.
GetCurrentAccessDelta
Writes the delta from the current access index to the next one.
ShouldContinueSquashLoop
Writes if the squash_dict loop should be continued.
GetNextDictKey
Writes the next dict key to process.
AssertLeFindSmallArcs
Finds the two small arcs from within [(0,a),(a,b),(b,PRIME)] and writes it to the range_check segment.
AssertLeIsFirstArcExcluded
Writes if the arc (0,a) was excluded.
AssertLeIsSecondArcExcluded
Writes if the arc (a,b) was excluded.
RandomEcPoint
Samples a random point on the EC.
FieldSqrt
Computes the square root of val
, if val
is a quadratic residue, and of 3 * val
otherwise.
Since 3 is not a quadratic residue, exactly one of val
and 3 * val
is a quadratic
residue (unless val
is 0). This allows proving that val
is not a quadratic residue.
DebugPrint
Prints the values from start to end. Both must be pointers.
AllocConstantSize
Returns an address with size
free locations afterwards.
Trait Implementations§
source§impl Decode for CoreHint
impl Decode for CoreHint
source§fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy
) -> Result<Self, Error>
fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy ) -> Result<Self, Error>
source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self> ) -> Result<DecodeFinished, Error>where I: Input,
source§impl<'de> Deserialize<'de> for CoreHint
impl<'de> Deserialize<'de> for CoreHint
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl Encode for CoreHint
impl Encode for CoreHint
source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy )
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn using_encoded<R, F>(&self, f: F) -> Rwhere
F: FnOnce(&[u8]) -> R,
fn using_encoded<R, F>(&self, f: F) -> Rwhere F: FnOnce(&[u8]) -> R,
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl From<CoreHint> for CoreHintBase
impl From<CoreHint> for CoreHintBase
source§impl JsonSchema for CoreHint
impl JsonSchema for CoreHint
source§fn schema_name() -> String
fn schema_name() -> String
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moresource§impl PartialEq<CoreHint> for CoreHint
impl PartialEq<CoreHint> for CoreHint
source§impl PythonicHint for CoreHint
impl PythonicHint for CoreHint
fn get_pythonic_hint(&self) -> String
impl EncodeLike<CoreHint> for CoreHint
impl Eq for CoreHint
impl StructuralEq for CoreHint
impl StructuralPartialEq for CoreHint
Auto Trait Implementations§
impl RefUnwindSafe for CoreHint
impl Send for CoreHint
impl Sync for CoreHint
impl Unpin for CoreHint
impl UnwindSafe for CoreHint
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere T: Decode,
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.