-
Notifications
You must be signed in to change notification settings - Fork 168
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 quad hint and integration test #715
Merged
Merged
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
75152d8
Add quad hint and integration test
c760e9f
Fix out of memory bug
de92f72
Implement hint and fix bugs
d9e748c
Add prop test
d037f2b
Add comment to sqrt
e5e89eb
Take smaller root
42d6419
Fix clippy warnings
ba0f03f
Add sqrt prop test
f198e6e
Remove zero from test
91081e6
Merge branch 'main' into is-quad-residue-hint
Juan-M-V 24382ac
Fix and merge with main
cd9f99d
Merge branch 'main' of github.com:lambdaclass/cairo-rs into is-quad-r…
fmoletta bd32cae
Fix qrong sqrt being used
fmoletta fc42539
Fix qrong sqrt being used
fmoletta fdeb24b
Reduce integration test lenght
fmoletta 0854e9b
Fix wasm test
fmoletta 0d91946
Clippy
fmoletta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
%builtins output | ||
from starkware.cairo.common.serialize import serialize_word | ||
from starkware.cairo.common.math import is_quad_residue | ||
from starkware.cairo.common.alloc import alloc | ||
|
||
func fill_array(array_start: felt*, iter: felt) -> () { | ||
if (iter == 32) { | ||
return (); | ||
} | ||
assert array_start[iter] = iter; | ||
return fill_array(array_start, iter + 1); | ||
} | ||
|
||
func check_quad_res{output_ptr: felt*}(inputs: felt*, expected: felt*, iter: felt) { | ||
if (iter == 32) { | ||
return (); | ||
} | ||
serialize_word(inputs[iter]); | ||
serialize_word(expected[iter]); | ||
|
||
assert is_quad_residue(inputs[iter]) = expected[iter]; | ||
return check_quad_res(inputs, expected, iter + 1); | ||
} | ||
|
||
func main{output_ptr: felt*}() { | ||
alloc_locals; | ||
let (inputs: felt*) = alloc(); | ||
fill_array(inputs, 0); | ||
|
||
let (expected: felt*) = alloc(); | ||
assert expected[0] = 1; | ||
assert expected[1] = 1; | ||
assert expected[2] = 1; | ||
assert expected[3] = 0; | ||
assert expected[4] = 1; | ||
assert expected[5] = 1; | ||
assert expected[6] = 0; | ||
assert expected[7] = 1; | ||
assert expected[8] = 1; | ||
assert expected[9] = 1; | ||
assert expected[10] = 1; | ||
assert expected[11] = 1; | ||
assert expected[12] = 0; | ||
assert expected[13] = 1; | ||
assert expected[14] = 1; | ||
assert expected[15] = 0; | ||
assert expected[16] = 1; | ||
assert expected[17] = 1; | ||
assert expected[18] = 1; | ||
assert expected[19] = 0; | ||
assert expected[20] = 1; | ||
assert expected[21] = 0; | ||
assert expected[22] = 1; | ||
assert expected[23] = 0; | ||
assert expected[24] = 0; | ||
assert expected[25] = 1; | ||
assert expected[26] = 1; | ||
assert expected[27] = 0; | ||
assert expected[28] = 1; | ||
assert expected[29] = 0; | ||
assert expected[30] = 0; | ||
assert expected[31] = 1; | ||
|
||
check_quad_res(inputs, expected, 0); | ||
|
||
return(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make a lookup table with the
192
possible powers of2
for this.