kimchi_stubs/
pasta_fp_poseidon.rs

1use crate::field_vector::fp::CamlFpVector;
2use mina_curves::pasta::Fp;
3use mina_poseidon::{
4    constants::PlonkSpongeConstantsKimchi, permutation::poseidon_block_cipher,
5    poseidon::ArithmeticSpongeParams,
6};
7
8pub struct CamlPastaFpPoseidonParams(ArithmeticSpongeParams<Fp>);
9pub type CamlPastaFpPoseidonParamsPtr<'a> = ocaml::Pointer<'a, CamlPastaFpPoseidonParams>;
10
11extern "C" fn caml_pasta_fp_poseidon_params_finalize(v: ocaml::Raw) {
12    unsafe {
13        let v: CamlPastaFpPoseidonParamsPtr = v.as_pointer();
14        v.drop_in_place()
15    };
16}
17
18ocaml::custom!(CamlPastaFpPoseidonParams {
19    finalize: caml_pasta_fp_poseidon_params_finalize,
20});
21
22#[ocaml::func]
23pub fn caml_pasta_fp_poseidon_params_create() -> CamlPastaFpPoseidonParams {
24    CamlPastaFpPoseidonParams(mina_poseidon::pasta::fp_kimchi::params())
25}
26
27#[ocaml::func]
28pub fn caml_pasta_fp_poseidon_block_cipher(
29    params: CamlPastaFpPoseidonParamsPtr,
30    mut state: CamlFpVector,
31) {
32    poseidon_block_cipher::<Fp, PlonkSpongeConstantsKimchi>(&params.as_ref().0, state.as_mut())
33}