-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into _copy_inputs_hint
- Loading branch information
Showing
18 changed files
with
559 additions
and
290 deletions.
There are no files selected for viewing
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
31 changes: 31 additions & 0 deletions
31
integration_tests/cairo_zero_hint_tests/is_zero.small.cairo
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,31 @@ | ||
// Returns 1 if x == 0 (mod secp256k1_prime), and 0 otherwise. | ||
// Serves as integration test for the following hints : | ||
// isZeroNondetCode | ||
// isZeroPackCode | ||
// isZeroDivModCode | ||
|
||
%builtins range_check | ||
|
||
from starkware.cairo.common.cairo_secp.field import is_zero, SumBigInt3 | ||
|
||
func main{range_check_ptr}() -> () { | ||
|
||
// Test One | ||
let a = SumBigInt3(0, 0, 0); | ||
let (res: felt) = is_zero(a); | ||
assert res = 1; | ||
|
||
// Test Two | ||
let b = SumBigInt3(42, 0, 0); | ||
let (res: felt) = is_zero(b); | ||
assert res = 0; | ||
|
||
// Test Three | ||
let c = SumBigInt3( | ||
77371252455336262886226991, 77371252455336267181195263, 19342813113834066795298815 | ||
); | ||
let (res: felt) = is_zero(c); | ||
assert res = 1; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
%builtins range_check | ||
from starkware.cairo.common.usort import usort | ||
from starkware.cairo.common.alloc import alloc | ||
|
||
func main{range_check_ptr}() -> () { | ||
alloc_locals; | ||
let (input_array: felt*) = alloc(); | ||
assert input_array[0] = 8; | ||
assert input_array[1] = 9; | ||
assert input_array[2] = 7; | ||
|
||
let (output_len, output, multiplicities) = usort(input_len=3, input=input_array); | ||
|
||
assert output_len = 3; | ||
assert output[0] = 7; | ||
assert output[1] = 8; | ||
assert output[2] = 9; | ||
|
||
assert multiplicities[0] = 1; | ||
assert multiplicities[1] = 1; | ||
assert multiplicities[2] = 1; | ||
|
||
let (input_array: felt*) = alloc(); | ||
assert input_array[0] = 11; | ||
assert input_array[1] = 24; | ||
assert input_array[2] = 99; | ||
assert input_array[3] = 2; | ||
assert input_array[4] = 66; | ||
assert input_array[5] = 49; | ||
assert input_array[6] = 11; | ||
assert input_array[7] = 23; | ||
assert input_array[8] = 88; | ||
assert input_array[9] = 7; | ||
|
||
let (output_len, output, multiplicities) = usort(input_len=10, input=input_array); | ||
|
||
assert output_len = 9; | ||
assert output[0] = 2; | ||
assert output[1] = 7; | ||
assert output[2] = 11; | ||
assert output[3] = 23; | ||
assert output[4] = 24; | ||
assert output[5] = 49; | ||
assert output[6] = 66; | ||
assert output[7] = 88; | ||
assert output[8] = 99; | ||
|
||
assert multiplicities[0] = 1; | ||
assert multiplicities[1] = 1; | ||
assert multiplicities[2] = 2; | ||
assert multiplicities[3] = 1; | ||
assert multiplicities[4] = 1; | ||
assert multiplicities[5] = 1; | ||
assert multiplicities[6] = 1; | ||
assert multiplicities[7] = 1; | ||
assert multiplicities[8] = 1; | ||
|
||
return (); | ||
} |
30 changes: 30 additions & 0 deletions
30
integration_tests/cairo_zero_hint_tests_in_progress/poseidon.starknet_with_keccak.cairo
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,30 @@ | ||
%builtins poseidon | ||
from starkware.cairo.common.cairo_builtins import PoseidonBuiltin | ||
from starkware.cairo.common.poseidon_state import PoseidonBuiltinState | ||
from starkware.cairo.common.builtin_poseidon.poseidon import ( | ||
poseidon_hash, | ||
poseidon_hash_single, | ||
poseidon_hash_many, | ||
) | ||
from starkware.cairo.common.alloc import alloc | ||
|
||
func main{poseidon_ptr: PoseidonBuiltin*}() { | ||
// Hash one | ||
let (x) = poseidon_hash_single( | ||
218676008889449692916464780911713710628115973574242889792891157041292792362 | ||
); | ||
assert x = 2835120893146788752888137145656423078969524407843035783270702964188823073934; | ||
// Hash two | ||
let (y) = poseidon_hash(1253795, 18540013156130945068); | ||
assert y = 37282360750367388068593128053386029947772104009544220786084510532118246655; | ||
// Hash five | ||
let felts: felt* = alloc(); | ||
assert felts[0] = 84175983715088675913672849362079546; | ||
assert felts[1] = 9384720329467203286234076408512594689579283578028960384690; | ||
assert felts[2] = 291883989128409324823849293040390493094093; | ||
assert felts[3] = 5849589438543859348593485948598349584395839402940940290490324; | ||
assert felts[4] = 1836254780028456372728992049476335424263474849; | ||
let (z) = poseidon_hash_many(5, felts); | ||
assert z = 47102513329160951064697157194713013753695317629154835326726810042406974264; | ||
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
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.