Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsoo calls caml_pasta_fp_poseidon_block_cipher through (native ffi) neon-rs artefact #2088

Open
4 tasks
Trivo25 opened this issue Mar 20, 2025 · 1 comment
Open
4 tasks
Assignees

Comments

@Trivo25
Copy link
Member

Trivo25 commented Mar 20, 2025

Once we have the compile artefacts available through the build pipeline, we need to access them in o1js to call into them and execute native rust functions

  • jsoo has access to native ffi neon-rs artefacts
    • Notes: currently, we inject a plonk_wasm object into o1js and the jsoo bindings for the node version as well as the web version - ideally we maintain the exact same interface and only inject the native prover artefact into the bindings via a third injection specifically for node-native (note: we definitely want to keep web-wasm and we may even consider keeping the node-wasm version as a fallback, so we don't need to change any of the existing implementations and pipelines, only add a new one for node-native)
  • jsoo uses neon-rs artefact to call caml_pasta_fp_poseidon_block_cipher
  • the interface we inject is currently called plonk_wasm, ideally we also refactor this part and rename it to something more generic, such as rust_interface to avoid confusion in the future
  • jsoo converts data coming from js/js-compiled-from-ocaml correctly to a format that neon-rs expects
    • the conversion logic in the jsoo bindings code correctly handles native rust ffi data conversion, here's an example, the integration tests will pass if it works
// Provides: caml_pasta_fp_poseidon_block_cipher
// Requires: plonk_wasm, tsRustConversion, tsRustConversion
function caml_pasta_fp_poseidon_block_cipher(_fake_params, fp_vector) {
  // 1. get permuted field vector from rust
  var wasm_flat_vector = plonk_wasm.caml_pasta_fp_poseidon_block_cipher(
    tsRustConversion.fp.vectorToRust(fp_vector)
  );
  var new_fp_vector = tsRustConversion.fp.vectorFromRust(wasm_flat_vector);
  // 2. write back modified field vector to original one
  new_fp_vector.forEach(function (a, i) {
    fp_vector[i] = a;
  });
}
@Geometer1729 Geometer1729 self-assigned this Mar 26, 2025
@Geometer1729
Copy link
Member

This pr renames plonk_wasm and changes the layout to make it easier to add the rust interface
MinaProtocol/mina#16779

@Trivo25 Trivo25 changed the title integrate rust ffi with o1js jsoo calls caml_pasta_fp_poseidon_block_cipher through (native ffi) neon-rs artefact Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants