solana/programs/sbf/rust
vadorovsky e6dc3dac45
feat(sbf): Add Poseidon syscall (#32680)
Computing Poseidon[0] hashes is too expensive to be done in a Solana
program in one transaction. Poseidon is a zero-knowlege proof friendly
hash function, used by the majority of ZK-based projects, including the
ones built on top of Solana.

This change introduces the `sol_poseidon` syscall which takes 2D byte
slice as an input and then calculates a Poseidon hash using a BN254
curve and the following Poseidon parameters:

* x^5 S-boxes
* width - 2 ≤ t ≤ 13
* inputs - 1 ≤ n ≤ 12
* 8 full rounds and partial rounds depending on t: [56, 57, 56, 60, 60,
  63, 64, 63, 60, 66, 60, 65]

Computation of Poseidon hashes is done with the light-poseidon[1]
crate, which is audited[2] and compatible with Circom[3] (BN254 curve,
the same parameters and constants).

Proposed compute costs depend on number of inputs and are based on
light-poseidon benchmarks[4].

[0] https://www.poseidon-hash.info/
[1] https://crates.io/crates/light-poseidon
[2] https://github.com/Lightprotocol/light-poseidon/blob/main/assets/audit.pdf
[3] https://docs.circom.io/
[4] https://github.com/Lightprotocol/light-poseidon/tree/main#performance
2023-08-30 09:43:31 -07:00
..
128bit ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
128bit_dep ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
alloc ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
alt_bn128 Add alt_bn128 syscall tests (and fix related issues) (#31436) 2023-05-22 14:05:10 -07:00
big_mod_exp chore: workspace inheritance (#30939) 2023-03-29 03:28:56 +00:00
call_depth preliminaries for bumping nightly to 2023-08-25 (#33047) 2023-08-29 23:05:35 +00:00
caller_access chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
curve25519 chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
custom_heap ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
dep_crate chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
deprecated_loader ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
dup_accounts ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
error_handling chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
external_spend ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
finalize chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
get_minimum_delegation chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
inner_instruction_alignment_check ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
instruction_introspection ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
invoke programs: change `borrow_mut` -> `borrow` in two places in test (#31399) 2023-05-05 13:08:17 +02:00
invoke_and_error chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
invoke_and_ok chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
invoke_and_return chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
invoked ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
iter ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
log_data chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
many_args ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
many_args_dep ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
mem ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
membuiltins chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
noop chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
panic ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
param_passing chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
param_passing_dep ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
poseidon feat(sbf): Add Poseidon syscall (#32680) 2023-08-30 09:43:31 -07:00
rand Bump rand to 0.8, rand_chacha to 0.3, getrandom to 0.2 (#32871) 2023-08-21 19:11:21 +02:00
realloc Account data direct mapping (#28053) 2023-04-29 06:54:39 +10:00
realloc_invoke chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
ro_account_modify chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
ro_modify chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
sanity ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
secp256k1_recover Fix - Upcoming `arithmetic_side_effects` lints (#33000) 2023-08-29 20:58:53 +02:00
sha chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
sibling_inner_instruction ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
sibling_instruction chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
simulation ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
spoof1 chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
spoof1_system ci: test-checks.sh all sbf code & use nightly only (#30602) 2023-03-13 14:28:34 +09:00
sysvar fix sbf sysvar test (#32803) 2023-08-21 09:49:48 -06:00
upgradeable chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00
upgraded chore: workspace inheritance (#29893) 2023-02-23 22:01:54 +08:00