-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add poseidon builtin (#875) * Add instance def * Add file * Add poseidon instance def to builtin instance def * Add Poseidon to BuiltinRunners * Add simple tests program * Prevent poseidon from being rejected by deserialize * Use modified version of starknet-crypto poseidon hash (need permute fn to be public in order to access full state * Add poseidon builtin impl + remove unreleased AddAssign usage * Fix EOF * Save a step * Add comment before unwrap * Clippy * Reorder files * Add comment * Use constants for cells * Add more test program * Add integration tests * test constant creation doesnt panic * Add tests * Fix failling tests * Use final values for POSEIDON_COMP_CONSTANTS and move calculation to test module * typo * Solve post-merge conflicts * Implement poseidon hints * Add file * Add tests for new hint * Clippy * Fix hint names * Solve post-merge conflicts * Add missing import * Use `starknet-crypto` for poseidon (#890) * ec_op changes 0.11 release (#876) * ec_op changes 0.11 release cairo_lang * Update src/vm/runners/builtin_runner/ec_op.rs Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com> * remove rc and change bigint to felt * debug cache * debug cache * change add_int implementation * cargo fmt --------- Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com> * [WIP] Update keccak-builtin (#873) * Add cache to keccak builtin * Temporaryly unhide recursive layout for debugging * Use same keccak method as the one used in keccak_utils * Make keccak builtin work * Fix visisbility * Small refactor * Refactor * Refactor * Add tests * Fix address management * Add test program * Clippy + Update tests * Remove unused import * Remove uneeded Rc * Make error less specific * Add integration test * Add proposed changes * Re-hide recursive layout * Update layouts to cairo-lang 0.11 release (#874) * update layouts to cairo-lang 0.11 release * update layout all * update benches and makefile * Add instance def * Add file * Add poseidon instance def to builtin instance def * Add Poseidon to BuiltinRunners * Add simple tests program * Prevent poseidon from being rejected by deserialize * Use modified version of starknet-crypto poseidon hash (need permute fn to be public in order to access full state * Add poseidon builtin impl + remove unreleased AddAssign usage * Fix EOF * Save a step * Add comment before unwrap * Clippy * Reorder files * reset run_benchmark script * Add comment * Use constants for cells * Add more test program * Add integration tests * test constant creation doesnt panic * Add tests * Fix failling tests * Use final values for POSEIDON_COMP_CONSTANTS and move calculation to test module * typo * Solve post-merge conflicts * Implement poseidon hints * Add file * Add tests for new hint * Clippy * allow dead code in default poseidon * remove wrong text * Update .github/workflows/rust.yml Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com> * Update src/types/instance_definitions/poseidon_instance_def.rs Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com> * Update src/types/instance_definitions/poseidon_instance_def.rs Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com> * Update src/types/instance_definitions/builtins_instance_def.rs Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com> * Update src/types/instance_definitions/builtins_instance_def.rs Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com> * Update src/types/instance_definitions/builtins_instance_def.rs Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com> --------- Co-authored-by: Federica <fedemoletta@hotmail.com> Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com> * Add new keccak hints + update import paths (#883) * Add cache to keccak builtin * Temporaryly unhide recursive layout for debugging * Use same keccak method as the one used in keccak_utils * Make keccak builtin work * Fix visisbility * Small refactor * Refactor * Refactor * Add tests * Fix address management * Add test program * Clippy + Update tests * Remove unused import * Remove uneeded Rc * Make error less specific * Add integration test * Add proposed changes * Add new hints * Add test program * Move constants * Add keccak hints; * Fix overflowing operation * Add more hints * Add unit tests * Add integration test * Update import paths in cairo programs used for testing * Update hints with new import paths * Add newline at end of file * Clippy * Clean imports * Re-hide recursive layout * Update src/hint_processor/builtin_hint_processor/keccak_utils.rs Co-authored-by: Mario Rugiero <mario.rugiero@lambdaclass.com> * Add suggested change + fix conflicts * Update src/hint_processor/builtin_hint_processor/keccak_utils.rs Co-authored-by: Mario Rugiero <mario.rugiero@lambdaclass.com> * Fix * Use u64 in split_n_bytes hints * Use starknet_with_keccak layout when running cairo-lang * Fix relative path in compare_vm_state script --------- Co-authored-by: Mario Rugiero <mario.rugiero@lambdaclass.com> * Remove typeguard pin * Run cairo-format * Fix program ruined by formatter * Fix wasm compatibility for newer files * Fix wasm compatibility for newer files * Fix wrong version * Fix syntax * Fix wasm compatibility * Tempfix for iai workflow * Fix workflow * Use the same layout for memory trace proof mode comparison * Add dynamic layout (#879) * Change instance def ratios to Option * Move builtin runner ratios to option * Modify methods to accomodate dynamic ratios * Misc fixes * Misc fixes * Fix wrong impl * Fix tests * Fix tests * Add dynamic layout * Fix wrong impl * Fix tests * Expose instances_per_component * Move get_used_cells_and_allocated_sizes to mod * Move get_allocated_memory_units to mod * Finnish prev tasks * Fix test * fix get_perm_range_check_limit * Fix get_range_check_usage * Fix test values * Fix workflows * Update Cargo.lock * Remove comment * [0.11] Add `SegmentArenaBuiltinRunner` (#913) * Change instance def ratios to Option * Move builtin runner ratios to option * Modify methods to accomodate dynamic ratios * Misc fixes * Misc fixes * Fix wrong impl * Fix tests * Fix tests * Add dynamic layout * Fix wrong impl * Fix tests * Expose instances_per_component * Move get_used_cells_and_allocated_sizes to mod * Move get_allocated_memory_units to mod * Finnish prev tasks * Fix test * Initial progress * Add builtin specific methods * Add SegmentArenaBuiltinRunner to BuiltinRunner enum * implement final_stack for segmen arena nuiltin runner * Add other methods * Integrate into runner * Remove error from initialize_segments * Fix comment * Add test * Add tests for segment arena builtin * Fix * fix get_perm_range_check_limit * Fix get_range_check_usage * Fix test values * expose program base for starknet reasons * Update src/vm/runners/builtin_runner/mod.rs Co-authored-by: Mario Rugiero <mario.rugiero@lambdaclass.com> * Fix build * Add nostd Vec import * Fix wasm import --------- Co-authored-by: Mario Rugiero <mario.rugiero@lambdaclass.com> Co-authored-by: Mario Rugiero <mrugiero@gmail.com> * Add suggested changes * Fix overriden run_benchmarks script * Add `program_segment_size` argument to `verify_secure_runner` & `run_from_entrypoint` (#928) * Change instance def ratios to Option * Move builtin runner ratios to option * Modify methods to accomodate dynamic ratios * Misc fixes * Misc fixes * Fix wrong impl * Fix tests * Fix tests * Add dynamic layout * Fix wrong impl * Fix tests * Expose instances_per_component * Move get_used_cells_and_allocated_sizes to mod * Move get_allocated_memory_units to mod * Finnish prev tasks * Fix test * Initial progress * Add builtin specific methods * Add SegmentArenaBuiltinRunner to BuiltinRunner enum * implement final_stack for segmen arena nuiltin runner * Add other methods * Integrate into runner * Remove error from initialize_segments * Fix comment * Add test * Add tests for segment arena builtin * Fix * fix get_perm_range_check_limit * Fix get_range_check_usage * Fix test values * expose program base for starknet reasons * Update src/vm/runners/builtin_runner/mod.rs Co-authored-by: Mario Rugiero <mario.rugiero@lambdaclass.com> * Add optional program_size argument to verify_secure_runner & run_from_entrypoint * Fix build * Add nostd Vec import * Fix wasm import * Expose get_segment_size (#934) --------- Co-authored-by: Mario Rugiero <mario.rugiero@lambdaclass.com> Co-authored-by: Mario Rugiero <mrugiero@gmail.com> * Fix typo * Add misc tests * Add misc tests * Add misc test * Add misc test * Add misc test * Expand misc test * Add wasm attr + misc test --------- Co-authored-by: Jonathan LEI <me@xjonathan.dev> Co-authored-by: Juan Rigada <62958725+Jrigada@users.noreply.github.com> Co-authored-by: Mario Rugiero <mario.rugiero@lambdaclass.com> Co-authored-by: Mario Rugiero <mrugiero@gmail.com>
- Loading branch information
1 parent
cdb5125
commit 1fb4a72
Showing
77 changed files
with
3,101 additions
and
1,218 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,4 +42,3 @@ func main{output_ptr: felt*, range_check_ptr, bitwise_ptr: BitwiseBuiltin*}() { | |
|
||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
%builtins keccak | ||
from starkware.cairo.common.cairo_builtins import KeccakBuiltin | ||
from starkware.cairo.common.keccak_state import KeccakBuiltinState | ||
|
||
func main{keccak_ptr: KeccakBuiltin*}() { | ||
assert keccak_ptr[0].input = KeccakBuiltinState(1, 2, 3, 4, 5, 6, 7, 8); | ||
let result = keccak_ptr[0].output; | ||
let keccak_ptr = keccak_ptr + KeccakBuiltin.SIZE; | ||
assert result.s0 = 528644516554364142278482415480021626364691973678134577961206; | ||
assert result.s1 = 768681319646568210457759892191562701823009052229295869963057; | ||
assert result.s2 = 1439835513376369408063324968379272676079109225238241190228026; | ||
assert result.s3 = 1150396629165612276474514703759718478742374517669870754478270; | ||
assert result.s4 = 1515147102575186161827863034255579930572231617017100845406254; | ||
assert result.s5 = 1412568161597072838250338588041800080889949791225997426843744; | ||
assert result.s6 = 982235455376248641031519404605670648838699214888770304613539; | ||
assert result.s7 = 1339947803093378278438908448344904300127577306141693325151040; | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
%builtins range_check bitwise keccak | ||
from starkware.cairo.common.cairo_builtins import KeccakBuiltin, BitwiseBuiltin | ||
from starkware.cairo.common.builtin_keccak.keccak import keccak_uint256s | ||
from starkware.cairo.common.alloc import alloc | ||
from starkware.cairo.common.uint256 import Uint256 | ||
|
||
func main{range_check_ptr, bitwise_ptr: BitwiseBuiltin*, keccak_ptr: KeccakBuiltin*}() { | ||
let elements: Uint256* = alloc(); | ||
assert elements[0] = Uint256(713458135386519, 18359173571); | ||
assert elements[1] = Uint256(1536741637546373185, 84357893467438914); | ||
assert elements[2] = Uint256(2842949328439284983294, 39248298942938492384); | ||
assert elements[3] = Uint256(27518568234293478923754395731931, 981587843715983274); | ||
assert elements[4] = Uint256(326848123647324823482, 93453458349589345); | ||
let (res) = keccak_uint256s(5, elements); | ||
assert res.high = 23012215180764429403047187376747988760; | ||
assert res.low = 13431206634823648732212765105043225161; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
%builtins poseidon | ||
from starkware.cairo.common.cairo_builtins import PoseidonBuiltin | ||
from starkware.cairo.common.poseidon_state import PoseidonBuiltinState | ||
|
||
func main{poseidon_ptr: PoseidonBuiltin*}() { | ||
assert poseidon_ptr[0].input = PoseidonBuiltinState(1, 2, 3); | ||
let result = poseidon_ptr[0].output; | ||
let poseidon_ptr = poseidon_ptr + PoseidonBuiltin.SIZE; | ||
assert result.s0 = 442682200349489646213731521593476982257703159825582578145778919623645026501; | ||
assert result.s1 = 2233832504250924383748553933071188903279928981104663696710686541536735838182; | ||
assert result.s2 = 2512222140811166287287541003826449032093371832913959128171347018667852712082; | ||
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,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
Oops, something went wrong.