cairo_lang_casm::hints

Enum CoreHint

Source
pub enum CoreHint {
Show 30 variants AllocSegment { dst: CellRef, }, TestLessThan { lhs: ResOperand, rhs: ResOperand, dst: CellRef, }, TestLessThanOrEqual { lhs: ResOperand, rhs: ResOperand, dst: CellRef, }, TestLessThanOrEqualAddress { 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 { dividend0: ResOperand, dividend1: ResOperand, divisor0: ResOperand, divisor1: ResOperand, quotient0: CellRef, quotient1: CellRef, remainder0: CellRef, remainder1: 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, }, U256InvModN { b0: ResOperand, b1: ResOperand, n0: ResOperand, n1: ResOperand, g0_or_no_inv: CellRef, g1_option: CellRef, s_or_r0: CellRef, s_or_r1: CellRef, t_or_k0: CellRef, t_or_k1: CellRef, }, EvalCircuit { n_add_mods: ResOperand, add_mod_builtin: ResOperand, n_mul_mods: ResOperand, mul_mod_builtin: ResOperand, },
}

Variants§

§

AllocSegment

Fields

§

TestLessThan

§

TestLessThanOrEqual

§

TestLessThanOrEqualAddress

Variant of TestLessThanOrEqual that compares addresses.

§

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.

Fields

§quotient: CellRef
§remainder: CellRef
§

Uint256DivMod

Divides dividend (represented by 2 128bit limbs) by divisor (represented by 2 128bit limbs). Returns the quotient (represented by 2 128bit limbs) and remainder (represented by 2 128bit limbs). In all cases - name0 is the least significant limb.

Fields

§dividend0: ResOperand
§dividend1: ResOperand
§divisor0: ResOperand
§divisor1: ResOperand
§quotient0: CellRef
§quotient1: CellRef
§remainder0: CellRef
§remainder1: CellRef
§

Uint512DivModByUint256

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 - name0 is the least significant limb.

Fields

§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

Fields

§

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.

Fields

§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

Finds some x and y such that x * scalar + y = value and x <= max_x.

§

AllocFelt252Dict

Allocates a new dict segment, and write its start address into the dict_infos segment.

Fields

§segment_arena_ptr: ResOperand
§

Felt252DictEntryInit

Fetch the previous value of a key in a dict, and write it in a new dict access.

Fields

§dict_ptr: ResOperand
§

Felt252DictEntryUpdate

Similar to Felt252DictWrite, but updates an existing entry and does not write the previous value to the stack.

Fields

§dict_ptr: ResOperand
§

GetSegmentArenaIndex

Retrieves the index of the given dict in the dict_infos segment.

Fields

§dict_end_ptr: ResOperand
§dict_index: CellRef
§

InitSquashData

Initialized the lists of accesses of each key of a dict as a preparation of squash_dict.

Fields

§dict_accesses: ResOperand
§ptr_diff: ResOperand
§n_accesses: ResOperand
§big_keys: CellRef
§first_key: CellRef
§

GetCurrentAccessIndex

Retrieves the current index of a dict access to process.

Fields

§range_check_ptr: ResOperand
§

ShouldSkipSquashLoop

Writes if the squash_dict loop should be skipped.

Fields

§should_skip_loop: CellRef
§

GetCurrentAccessDelta

Writes the delta from the current access index to the next one.

Fields

§index_delta_minus1: CellRef
§

ShouldContinueSquashLoop

Writes if the squash_dict loop should be continued.

Fields

§should_continue: CellRef
§

GetNextDictKey

Writes the next dict key to process.

Fields

§next_key: CellRef
§

AssertLeFindSmallArcs

Finds the two small arcs from within [(0,a),(a,b),(b,PRIME)] and writes it to the range_check segment.

Fields

§range_check_ptr: ResOperand
§

AssertLeIsFirstArcExcluded

Writes if the arc (0,a) was excluded.

Fields

§skip_exclude_a_flag: CellRef
§

AssertLeIsSecondArcExcluded

Writes if the arc (a,b) was excluded.

Fields

§skip_exclude_b_minus_a: CellRef
§

RandomEcPoint

Samples a random point on the EC.

Fields

§

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.

Fields

§sqrt: CellRef
§

DebugPrint

Prints the values from start to end. Both must be pointers.

Fields

§

AllocConstantSize

Returns an address with size free locations afterwards.

Fields

§

U256InvModN

Provides the inverse of b (represented by 2 128-bit limbs) modulo n (represented by 2 128-bit limbs), or a proof that b has no inverse.

In case b has an inverse: Returns r and k such that:

  • r = 1 / b (mod n)
  • k = (r * b - 1) / n
  • g0_or_no_inv = 0

In case b has no inverse: Returns g, s, and t, such that: g > 1 g == 2 || g % 2 == 1 (in particular, g0_or_no_inv = g0 != 0) g * s = b g * t = n

The case n == 1 is considered “no-inverse” (special case). In this case: Returns g == 1, s == b and t == 1. All no-inverse requirements are satisfied, except for g > 1.

In all cases - name0 is the least significant limb.

Fields

§g0_or_no_inv: CellRef
§g1_option: CellRef
§s_or_r0: CellRef
§s_or_r1: CellRef
§t_or_k0: CellRef
§t_or_k1: CellRef
§

EvalCircuit

Fields

§n_add_mods: ResOperand
§add_mod_builtin: ResOperand
§n_mul_mods: ResOperand
§mul_mod_builtin: ResOperand

Trait Implementations§

Source§

impl Clone for CoreHint

Source§

fn clone(&self) -> CoreHint

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CoreHint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<CoreHint> for CoreHintBase

Source§

fn from(value: CoreHint) -> Self

Converts to this type from the input type.
Source§

impl From<CoreHint> for Hint

Source§

fn from(value: CoreHint) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for CoreHint

Source§

fn eq(&self, other: &CoreHint) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PythonicHint for CoreHint

Source§

impl Eq for CoreHint

Source§

impl StructuralPartialEq for CoreHint

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T
where T: ?Sized,

Source§

fn upcast(&self) -> &T

Source§

impl<T> UpcastMut<T> for T
where T: ?Sized,

Source§

fn upcast_mut(&mut self) -> &mut T