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
20 lines
477 B
TOML
20 lines
477 B
TOML
[package]
|
|
name = "solana-sbf-rust-poseidon"
|
|
description = "Solana SBF test program written in Rust"
|
|
version = { workspace = true }
|
|
authors = { workspace = true }
|
|
repository = { workspace = true }
|
|
homepage = { workspace = true }
|
|
license = { workspace = true }
|
|
edition = { workspace = true }
|
|
|
|
[dependencies]
|
|
array-bytes = { workspace = true }
|
|
solana-program = { workspace = true }
|
|
|
|
[lib]
|
|
crate-type = ["cdylib"]
|
|
|
|
[package.metadata.docs.rs]
|
|
targets = ["x86_64-unknown-linux-gnu"]
|