-
Notifications
You must be signed in to change notification settings - Fork 160
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 newhint13-quad_bit
- Loading branch information
Showing
10 changed files
with
143 additions
and
46 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
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,49 @@ | ||
%builtins range_check | ||
|
||
from starkware.cairo.common.cairo_secp.bigint import BigInt3, UnreducedBigInt3, nondet_bigint3 | ||
from starkware.cairo.common.cairo_secp.field import unreduced_mul, verify_zero | ||
|
||
func is_zero_pack{range_check_ptr}(x: BigInt3) -> (res: felt) { | ||
// just to import SECP_P | ||
%{ | ||
from starkware.cairo.common.cairo_secp.secp_utils import SECP_P, pack | ||
value = pack(ids.x, PRIME) % SECP_P | ||
%} | ||
%{ | ||
from starkware.cairo.common.cairo_secp.secp_utils import pack | ||
x = pack(ids.x, PRIME) % SECP_P | ||
%} | ||
if (nondet %{ x == 0 %} != 0) { | ||
return (res=1); | ||
} | ||
return (res=0); | ||
} | ||
|
||
func test_is_zero_pack{range_check_ptr}() -> () { | ||
let zero = BigInt3(0, 0, 0); | ||
|
||
let (res: felt) = is_zero_pack(zero); | ||
assert res = 1; | ||
|
||
let one = BigInt3(1, 0, 0); | ||
|
||
let (res: felt) = is_zero_pack(one); | ||
assert res = 0; | ||
|
||
let secp256k1_prime = BigInt3( | ||
77371252455336262886226991, 77371252455336267181195263, 19342813113834066795298815 | ||
); | ||
|
||
let (res: felt) = is_zero_pack(secp256k1_prime); | ||
assert res = 1; | ||
|
||
return (); | ||
} | ||
|
||
func main{range_check_ptr}() -> () { | ||
test_is_zero_pack(); | ||
|
||
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