Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cairo Zero Hints #164

Closed
89 tasks done
rodrigo-pino opened this issue Nov 14, 2023 · 1 comment
Closed
89 tasks done

Add Cairo Zero Hints #164

rodrigo-pino opened this issue Nov 14, 2023 · 1 comment
Labels
cairo zero Exclusively targets cairo zero enhancement New feature or request vm hint Related with VM hints

Comments

@rodrigo-pino
Copy link
Contributor

rodrigo-pino commented Nov 14, 2023

Cairo Zero Hints

The following is a (big!) list of hints required by Cairo Zero. They might be an overlap between Cairo Zero hints and Cairo One hints #36 .

The list was extracted from sister VM in Go by LambdaClass where they gathered all Pythonic hints.

👀 For specific instructions on how to implement these hints you can check out the readme file in the zero package

Uint256 Operations

Math Operations

  • IsNn: Checks if a value is non-negative within a specific range.
  • IsNnOutOfRange: Checks if the negation of a value (minus one) is non-negative within a specific range.
  • IsLeFelt: Determines if one value is less than or equal to another within a finite field.
  • AssertLtFelt: Asserts that one value is strictly less than another within a finite field.
  • Pow #238
  • IsPositive: Checks if a value is positive within a specific range and prime context.
  • SplitFelt #239
  • SplitInt: Splits an integer based on a base and asserts the result is within a certain range.
  • SplitIntAssertRange: Asserts that the value for SplitInt is within the expected range.
  • AssertNotZero: Asserts that a value is not zero.
  • AssertNn: Asserts that a given integer is non-negative within a specified range.
  • AssertNotEqual: Asserts that two given values are not equal.
  • Assert250Bits: Asserts that a value is within the range of 250 bits.
  • AssertLeFelt: Asserts that one value is less than or equal to another within a finite field.
  • AssertLeFeltExcluded0: Custom assertion related to AssertLeFelt.
  • AssertLeFeltExcluded1: Another custom assertion related to AssertLeFelt.
  • AssertLeFeltExcluded2: Final custom assertion related to AssertLeFelt.
  • Sqrt #240
  • UnsignedDivRem #241
  • SignedDivRem #242
  • IsQuadResidue #243

Usort

Other

Elliptic Curve Operations

Signatures (ECDSA & SEC_P)

Blake Hash

Keccak

Dictionaries

@rodrigo-pino rodrigo-pino added enhancement New feature or request vm hint Related with VM hints cairo zero Exclusively targets cairo zero labels Nov 14, 2023
@cicr99
Copy link
Contributor

cicr99 commented Dec 13, 2023

To implement the hints in this issue you'll need to follow the next steps:

  • Add the string that is the code of the hint in the hintcode file. The code of the hint is always the same string and can be found in the lambdaclass vm or if you look for it in the python vm
  • Then add your hint in the switch-case in the GetHintFromCode method in zerohint file. You'll need to implement a method for your hint there called Create<HintName>Hinter
  • The method Create<HintName>Hinter should check the parameters are correct and should return the corresponding Hinter structure. If the hint is already implemented, as is the case for AllocSegment, you don't need to do anything else, just return it
  • If the hint hasn't been implemented, you'll need to add it in the corresponding file in the zero package of the hintrunner, and add unit tests for it.

⚠️ The description has been updated with a link to the readme inside the hintunner/zero package with more detailed instructions on how to implement new Cairo 0 hints

quasilyte added a commit that referenced this issue Feb 16, 2024
This hint uses the assert_felt_le beneath it, but
it was implemented beforehand.

This PR has no tests included since #204 is not solved yet.
I used a couple of Cairo0 scripts to test this functionality
with a set of different arguments to cover both hints
that are a part of `is_nn` function.
(One of them handles negatives while another is for the non-negatives.)

Refs #164
quasilyte added a commit that referenced this issue Feb 16, 2024
is_nn hint uses the assert_felt_le beneath it, but
it was implemented beforehand.

This PR has no tests included since #204 is not solved yet.
I used a couple of Cairo0 scripts to test this functionality
with a set of different arguments to cover both hints
that are a part of `is_nn` function.
(One of them handles negatives while another is for the non-negatives.)

Refs #164
quasilyte added a commit that referenced this issue Feb 20, 2024
implement several Cairo0 hint

is_nn hint uses the assert_felt_le beneath it, but
it was implemented beforehand.

This PR has no tests included since #204 is not solved yet.
I used a couple of Cairo0 scripts to test this functionality
with a set of different arguments to cover both hints
that are a part of `is_nn` function.
(One of them handles negatives while another is for the non-negatives.)

Refs #164
@cicr99 cicr99 changed the title Add Cairo Zero Hints: Add Cairo Zero Hints Mar 6, 2024
@cicr99 cicr99 pinned this issue Mar 19, 2024
This was referenced Apr 24, 2024
@TAdev0 TAdev0 closed this as completed Jun 20, 2024
@TAdev0 TAdev0 unpinned this issue Jun 25, 2024
@TAdev0 TAdev0 mentioned this issue Jun 25, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cairo zero Exclusively targets cairo zero enhancement New feature or request vm hint Related with VM hints
Projects
None yet
Development

No branches or pull requests

3 participants