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 T)

🔬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