Zokrates / ZoKrates

A toolbox for zkSNARKs on Ethereum
https://zokrates.github.io
GNU Lesser General Public License v3.0
1.81k stars 361 forks source link

Improve setup FFI in zokrates-js #1277

Closed dark64 closed 1 year ago

dark64 commented 1 year ago

Fixes https://github.com/Zokrates/ZoKrates/issues/1276

This issue seems to be because we are serializing the setup keypair directly to JsValue. When calling JsValue::from_serde, the function will serialize the provided value to a JSON string, send the JSON string to JS, parse it into a JS object, and then return a handle to the JS object.

This is fine in most cases, but in some extreme cases with circuits that end up with a large proving key, this serialization method would fail because of a large JSON string that gets produced. This PR solves this issue with the same method we use for compilation artifacts.