-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a993318
commit b1a9971
Showing
5 changed files
with
120 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
%builtins range_check | ||
|
||
func get_quad_bit{range_check_ptr}(scalar_u: felt, scalar_v: felt, m: felt) -> felt { | ||
alloc_locals; | ||
local quad_bit: felt; | ||
%{ | ||
ids.quad_bit = ( | ||
8 * ((ids.scalar_v >> ids.m) & 1) | ||
+ 4 * ((ids.scalar_u >> ids.m) & 1) | ||
+ 2 * ((ids.scalar_v >> (ids.m - 1)) & 1) | ||
+ ((ids.scalar_u >> (ids.m - 1)) & 1) | ||
) | ||
%} | ||
return quad_bit; | ||
} | ||
|
||
func test_quad_bit{range_check_ptr}() { | ||
let u = 4194304; // 1 << 22 | ||
let v = 8388608; // 1 << 23 | ||
|
||
// 8 * 1 + 4 * 0 + 2 * 0 + 1 * 1 | ||
assert get_quad_bit(u, v, 23) = 9; | ||
|
||
return (); | ||
} | ||
|
||
func main{range_check_ptr}() { | ||
test_quad_bit(); | ||
|
||
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