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 all existing bindings functions through neon-rs (ffi) artefact #2089

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

Comments

@Trivo25
Copy link
Member

Trivo25 commented Mar 20, 2025

The bindings layer exports a large set of functions that are being used by o1js and OCaml (proving, data conversion, proofs, etc) - these functions need to be ported over to the native rust ffi incrementally to make them accessible to o1js

  • jsoo uses neon-rs artefact to (incrementally) call remaining functions in wasm
  • jsoo converts data coming from js/js-compiled-from-ocaml correctly to a format that neon-rs expects for all remaining functions
    • 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;
  });
}
@mitschabaude
Copy link
Contributor

all the contents in the wasm bindings folder must be ported over to the new native ffi bindings folder so that they can be accessed natively

just want to note that not all of what we export from Rust is really used by o1js (ever since we swapped out the finite field / EC backends for TS versions)

at least the wasm bindings methods tested in this file are no longer used (except in this test, which checks that the TS versions behave the same):
https://github.com/o1-labs/o1js-bindings/blob/e24df862dc4b45f57b7611d4e00777a5b4801cea/crypto/bindings/bindings.unit-test.ts

@Trivo25 Trivo25 changed the title support all needed rust functions through the ffi jsoo calls all existing bindings functions through neon-rs (ffi) 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