diff --git a/src/lib/crypto/kimchi_bindings/js/bindings/oracles.js b/src/lib/crypto/kimchi_bindings/js/bindings/oracles.js index ecd57b9f4861..bc824ee04cc4 100644 --- a/src/lib/crypto/kimchi_bindings/js/bindings/oracles.js +++ b/src/lib/crypto/kimchi_bindings/js/bindings/oracles.js @@ -1,69 +1,5 @@ /* global plonk_wasm, tsRustConversion,*/ -// Provides: fp_oracles_create -// Requires: plonk_wasm, tsRustConversion -var fp_oracles_create = function (lgr_comm, verifier_index, proof) { - return tsRustConversion.fp.oraclesFromRust( - plonk_wasm.fp_oracles_create( - tsRustConversion.fp.polyCommsToRust(lgr_comm), - tsRustConversion.fp.verifierIndexToRust(verifier_index), - tsRustConversion.fp.proofToRust(proof) - ) - ); -}; - -// Provides: fp_oracles_create_no_public -// Requires: fp_oracles_create -var fp_oracles_create_no_public = function (lgr_comm, verifier_index, proof) { - return fp_oracles_create(lgr_comm, verifier_index, [0, 0, proof]); -}; - -// Provides: fp_oracles_dummy -// Requires: plonk_wasm, tsRustConversion -var fp_oracles_dummy = function () { - return tsRustConversion.fp.oraclesFromRust(plonk_wasm.fp_oracles_dummy()); -}; - -// Provides: fp_oracles_deep_copy -// Requires: plonk_wasm, tsRustConversion -var fp_oracles_deep_copy = function (x) { - return tsRustConversion.fp.oraclesFromRust( - plonk_wasm.fp_oracles_deep_copy(tsRustConversion.fp.oraclesToRust(x)) - ); -}; - -// Provides: fq_oracles_create -// Requires: plonk_wasm, tsRustConversion -var fq_oracles_create = function (lgr_comm, verifier_index, proof) { - return tsRustConversion.fq.oraclesFromRust( - plonk_wasm.fq_oracles_create( - tsRustConversion.fq.polyCommsToRust(lgr_comm), - tsRustConversion.fq.verifierIndexToRust(verifier_index), - tsRustConversion.fq.proofToRust(proof) - ) - ); -}; - -// Provides: fq_oracles_create_no_public -// Requires: fq_oracles_create -var fq_oracles_create_no_public = function (lgr_comm, verifier_index, proof) { - return fq_oracles_create(lgr_comm, verifier_index, [0, 0, proof]); -}; - -// Provides: fq_oracles_dummy -// Requires: plonk_wasm, tsRustConversion -var fq_oracles_dummy = function () { - return tsRustConversion.fq.oraclesFromRust(plonk_wasm.fq_oracles_dummy()); -}; - -// Provides: fq_oracles_deep_copy -// Requires: plonk_wasm, tsRustConversion -var fq_oracles_deep_copy = function (x) { - return tsRustConversion.fq.oraclesFromRust( - plonk_wasm.fq_oracles_deep_copy(tsRustConversion.fq.oraclesToRust(x)) - ); -}; - // This is fake -- parameters are only needed on the Rust side, so no need to return something meaningful // Provides: caml_pasta_fp_poseidon_params_create function caml_pasta_fp_poseidon_params_create() { diff --git a/src/lib/crypto/kimchi_bindings/js/bindings/proof.js b/src/lib/crypto/kimchi_bindings/js/bindings/proof.js index 9a58c242c86b..e69de29bb2d1 100644 --- a/src/lib/crypto/kimchi_bindings/js/bindings/proof.js +++ b/src/lib/crypto/kimchi_bindings/js/bindings/proof.js @@ -1,139 +0,0 @@ -/* global plonk_wasm, tsRustConversion - */ - -// Provides: caml_pasta_fp_plonk_proof_create -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fp_plonk_proof_create = function ( - index, - witness_cols, - caml_runtime_tables, - prev_challenges, - prev_sgs -) { - var w = new plonk_wasm.WasmVecVecFp(witness_cols.length - 1); - for (var i = 1; i < witness_cols.length; i++) { - w.push(tsRustConversion.fp.vectorToRust(witness_cols[i])); - } - witness_cols = w; - prev_challenges = tsRustConversion.fp.vectorToRust(prev_challenges); - var wasm_runtime_tables = - tsRustConversion.fp.runtimeTablesToRust(caml_runtime_tables); - prev_sgs = tsRustConversion.fp.pointsToRust(prev_sgs); - var proof = plonk_wasm.caml_pasta_fp_plonk_proof_create( - index, - witness_cols, - wasm_runtime_tables, - prev_challenges, - prev_sgs - ); - return tsRustConversion.fp.proofFromRust(proof); -}; - -// Provides: caml_pasta_fp_plonk_proof_verify -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fp_plonk_proof_verify = function (index, proof) { - index = tsRustConversion.fp.verifierIndexToRust(index); - proof = tsRustConversion.fp.proofToRust(proof); - return plonk_wasm.caml_pasta_fp_plonk_proof_verify(index, proof); -}; - -// Provides: caml_pasta_fp_plonk_proof_batch_verify -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fp_plonk_proof_batch_verify = function (indexes, proofs) { - indexes = tsRustConversion.mapMlArrayToRustVector( - indexes, - tsRustConversion.fp.verifierIndexToRust - ); - proofs = tsRustConversion.mapMlArrayToRustVector( - proofs, - tsRustConversion.fp.proofToRust - ); - return plonk_wasm.caml_pasta_fp_plonk_proof_batch_verify(indexes, proofs); -}; - -// Provides: caml_pasta_fp_plonk_proof_dummy -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fp_plonk_proof_dummy = function () { - return tsRustConversion.fp.proofFromRust( - plonk_wasm.caml_pasta_fp_plonk_proof_dummy() - ); -}; - -// Provides: caml_pasta_fp_plonk_proof_deep_copy -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fp_plonk_proof_deep_copy = function (proof) { - return tsRustConversion.fp.proofFromRust( - plonk_wasm.caml_pasta_fp_plonk_proof_deep_copy( - tsRustConversion.fp.proofToRust(proof) - ) - ); -}; - -// Provides: caml_pasta_fq_plonk_proof_create -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fq_plonk_proof_create = function ( - index, - witness_cols, - caml_runtime_tables, - prev_challenges, - prev_sgs -) { - var w = new plonk_wasm.WasmVecVecFq(witness_cols.length - 1); - for (var i = 1; i < witness_cols.length; i++) { - w.push(tsRustConversion.fq.vectorToRust(witness_cols[i])); - } - witness_cols = w; - prev_challenges = tsRustConversion.fq.vectorToRust(prev_challenges); - var wasm_runtime_tables = - tsRustConversion.fq.runtimeTablesToRust(caml_runtime_tables); - prev_sgs = tsRustConversion.fq.pointsToRust(prev_sgs); - var proof = plonk_wasm.caml_pasta_fq_plonk_proof_create( - index, - witness_cols, - wasm_runtime_tables, - prev_challenges, - prev_sgs - ); - return tsRustConversion.fq.proofFromRust(proof); -}; - -// Provides: caml_pasta_fq_plonk_proof_verify -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fq_plonk_proof_verify = function (index, proof) { - index = tsRustConversion.fq.verifierIndexToRust(index); - proof = tsRustConversion.fq.proofToRust(proof); - return plonk_wasm.caml_pasta_fq_plonk_proof_verify(index, proof); -}; - -// Provides: caml_pasta_fq_plonk_proof_batch_verify -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fq_plonk_proof_batch_verify = function (indexes, proofs) { - indexes = tsRustConversion.mapMlArrayToRustVector( - indexes, - tsRustConversion.fq.verifierIndexToRust - ); - proofs = tsRustConversion.mapMlArrayToRustVector( - proofs, - tsRustConversion.fq.proofToRust - ); - return plonk_wasm.caml_pasta_fq_plonk_proof_batch_verify(indexes, proofs); -}; - -// Provides: caml_pasta_fq_plonk_proof_dummy -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fq_plonk_proof_dummy = function () { - return tsRustConversion.fq.proofFromRust( - plonk_wasm.caml_pasta_fq_plonk_proof_dummy() - ); -}; - -// Provides: caml_pasta_fq_plonk_proof_deep_copy -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fq_plonk_proof_deep_copy = function (proof) { - return tsRustConversion.fq.proofFromRust( - plonk_wasm.caml_pasta_fq_plonk_proof_deep_copy( - tsRustConversion.fq.proofToRust(proof) - ) - ); -}; - diff --git a/src/lib/crypto/kimchi_bindings/js/bindings/verifier-index.js b/src/lib/crypto/kimchi_bindings/js/bindings/verifier-index.js index a14f5b773f24..08819154c87a 100644 --- a/src/lib/crypto/kimchi_bindings/js/bindings/verifier-index.js +++ b/src/lib/crypto/kimchi_bindings/js/bindings/verifier-index.js @@ -20,131 +20,3 @@ var caml_opt_to_rust = function (caml_optional_value, to_rust) { return to_rust(caml_optional_value[1]); } }; - -// Provides: caml_pasta_fp_plonk_verifier_index_create -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fp_plonk_verifier_index_create = function (x) { - console.log("caml_pasta_fp_plonk_verifier_index_create") - var vk = plonk_wasm.caml_pasta_fp_plonk_verifier_index_create(x); - return tsRustConversion.fp.verifierIndexFromRust(vk); -}; - -// Provides: caml_pasta_fp_plonk_verifier_index_read -// Requires: plonk_wasm, caml_jsstring_of_string, tsRustConversion -var caml_pasta_fp_plonk_verifier_index_read = function (offset, urs, path) { - console.log("caml_pasta_fp_plonk_verifier_index_read") - - if (offset === 0) { - offset = undefined; - } else { - offset = offset[1]; - } - return tsRustConversion.fp.verifierIndexFromRust( - plonk_wasm.caml_pasta_fp_plonk_verifier_index_read( - offset, - urs, - caml_jsstring_of_string(path) - ) - ); -}; - -// Provides: caml_pasta_fp_plonk_verifier_index_write -// Requires: plonk_wasm, caml_jsstring_of_string, tsRustConversion -var caml_pasta_fp_plonk_verifier_index_write = function (append, t, path) { - console.log("caml_pasta_fp_plonk_verifier_index_write") - - if (append === 0) { - append = undefined; - } else { - append = append[1]; - } - return plonk_wasm.caml_pasta_fp_plonk_verifier_index_write( - append, - tsRustConversion.fp.verifierIndexToRust(t), - caml_jsstring_of_string(path) - ); -}; - - -// Provides: caml_pasta_fp_plonk_verifier_index_dummy -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fp_plonk_verifier_index_dummy = function () { - console.log("caml_pasta_fp_plonk_verifier_index_dummy") - - var res = plonk_wasm.caml_pasta_fp_plonk_verifier_index_dummy(); - return tsRustConversion.fp.verifierIndexFromRust(res); -}; - -// Provides: caml_pasta_fp_plonk_verifier_index_deep_copy -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fp_plonk_verifier_index_deep_copy = function (x) { - console.log("caml_pasta_fp_plonk_verifier_index_deep_copy") - return tsRustConversion.fp.verifierIndexFromRust( - plonk_wasm.caml_pasta_fp_plonk_verifier_index_deep_copy( - tsRustConversion.fp.verifierIndexToRust(x) - ) - ); -}; - -// Provides: caml_pasta_fq_plonk_verifier_index_create -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fq_plonk_verifier_index_create = function (x) { - console.log("caml_pasta_fq_plonk_verifier_index_create") - return tsRustConversion.fq.verifierIndexFromRust( - plonk_wasm.caml_pasta_fq_plonk_verifier_index_create(x) - ); -}; - -// Provides: caml_pasta_fq_plonk_verifier_index_read -// Requires: plonk_wasm, caml_jsstring_of_string, tsRustConversion -var caml_pasta_fq_plonk_verifier_index_read = function (offset, urs, path) { - console.log("caml_pasta_fq_plonk_verifier_index_read") - if (offset === 0) { - offset = undefined; - } else { - offset = offset[1]; - } - return tsRustConversion.fq.verifierIndexFromRust( - plonk_wasm.caml_pasta_fq_plonk_verifier_index_read( - offset, - urs, - caml_jsstring_of_string(path) - ) - ); -}; - -// Provides: caml_pasta_fq_plonk_verifier_index_write -// Requires: plonk_wasm, caml_jsstring_of_string, tsRustConversion -var caml_pasta_fq_plonk_verifier_index_write = function (append, t, path) { - console.log("caml_pasta_fq_plonk_verifier_index_write") - if (append === 0) { - append = undefined; - } else { - append = append[1]; - } - return plonk_wasm.caml_pasta_fq_plonk_verifier_index_write( - append, - tsRustConversion.fq.verifierIndexToRust(t), - caml_jsstring_of_string(path) - ); -}; - -// Provides: caml_pasta_fq_plonk_verifier_index_dummy -// Requires: plonk_wasm, tsRustConversion -var caml_pasta_fq_plonk_verifier_index_dummy = function () { - console.log("caml_pasta_fq_plonk_verifier_index_dummy") - return tsRustConversion.fq.verifierIndexFromRust( - plonk_wasm.caml_pasta_fq_plonk_verifier_index_dummy() - ); -}; - -// Provides: caml_pasta_fq_plonk_verifier_index_deep_copy -// Requires: plonk_wasm, tsRustConversion, tsRustConversion -var caml_pasta_fq_plonk_verifier_index_deep_copy = function (x) { - console.log("caml_pasta_fq_plonk_verifier_index_deep_copy") - return tsRustConversion.fq.verifierIndexFromRust( - plonk_wasm.caml_pasta_fq_plonk_verifier_index_deep_copy( - tsRustConversion.fq.verifierIndexToRust(x) - ) - ); -}; diff --git a/src/lib/crypto/kimchi_bindings/js/dune b/src/lib/crypto/kimchi_bindings/js/dune index 84584c588b4e..29c5460622ce 100644 --- a/src/lib/crypto/kimchi_bindings/js/dune +++ b/src/lib/crypto/kimchi_bindings/js/dune @@ -21,7 +21,8 @@ native/native-overrides/prover-index.js native/native-overrides/srs.js native/native-overrides/util.js - native/native-overrides/proof.js)) + native/native-overrides/proof.js + native/native-overrides/verifier-index.js)) (instrumentation (backend bisect_ppx)) (preprocess diff --git a/src/lib/crypto/kimchi_bindings/js/native/header-d.ts b/src/lib/crypto/kimchi_bindings/js/native/header-d.ts index dbcbdb2185fd..3fd3d74b1e57 100644 --- a/src/lib/crypto/kimchi_bindings/js/native/header-d.ts +++ b/src/lib/crypto/kimchi_bindings/js/native/header-d.ts @@ -4,14 +4,20 @@ // This file gets auto-included in the generated plonk-napi types to supplement // external pointer types. +type WasmGVesta = {}; +type WasmGPallas = {}; +type WasmPastaFp = {}; +type WasmPastaFq = {}; +type WasmLookupInfo = {}; type WasmPastaFpPlonkIndex = {}; -type NapiVector = {}; -type NapiGVesta = {}; -type NapiGPallas = {}; -type NapiPastaFpPlonkIndex = {}; -type NapiPastaFqPlonkIndex = {}; -type NapiLookupInfo = {}; -type NapiPastaFp = {}; -type NapiPastaFq = {}; +type WasmPastaFqPlonkIndex = {}; +type Proof = {} +type WasmVector = {}; +type WasmFlatVector = {}; +type WasmVecVecFp = {}; +type WasmVecVecFq = {}; +type WasmFpSrs = {}; +type WasmFqSrs = {}; +type Self = {}; // Header section end \ No newline at end of file diff --git a/src/lib/crypto/kimchi_bindings/js/native/native-overrides/oracles.js b/src/lib/crypto/kimchi_bindings/js/native/native-overrides/oracles.js index 795c518f1ca1..3ccde404c09b 100644 --- a/src/lib/crypto/kimchi_bindings/js/native/native-overrides/oracles.js +++ b/src/lib/crypto/kimchi_bindings/js/native/native-overrides/oracles.js @@ -1,5 +1,68 @@ /* global plonk_wasm, tsRustConversionNative,*/ +// Provides: fp_oracles_create +// Requires: plonk_wasm, tsRustConversionNative +var fp_oracles_create = function (lgr_comm, verifier_index, proof) { + return tsRustConversionNative.fp.oraclesFromRust( + plonk_wasm.fp_oracles_create( + tsRustConversionNative.fp.polyCommsToRust(lgr_comm), + tsRustConversionNative.fp.verifierIndexToRust(verifier_index), + tsRustConversionNative.fp.proofToRust(proof) + ) + ); +}; + +// Provides: fp_oracles_create_no_public +// Requires: fp_oracles_create +var fp_oracles_create_no_public = function (lgr_comm, verifier_index, proof) { + return fp_oracles_create(lgr_comm, verifier_index, [0, 0, proof]); +}; + +// Provides: fp_oracles_dummy +// Requires: plonk_wasm, tsRustConversionNative +var fp_oracles_dummy = function () { + return tsRustConversionNative.fp.oraclesFromRust(plonk_wasm.fp_oracles_dummy()); +}; + +// Provides: fp_oracles_deep_copy +// Requires: plonk_wasm, tsRustConversionNative +var fp_oracles_deep_copy = function (x) { + return tsRustConversionNative.fp.oraclesFromRust( + plonk_wasm.fp_oracles_deep_copy(tsRustConversionNative.fp.oraclesToRust(x)) + ); +}; + +// Provides: fq_oracles_create +// Requires: plonk_wasm, tsRustConversionNative +var fq_oracles_create = function (lgr_comm, verifier_index, proof) { + return tsRustConversionNative.fq.oraclesFromRust( + plonk_wasm.fq_oracles_create( + tsRustConversionNative.fq.polyCommsToRust(lgr_comm), + tsRustConversionNative.fq.verifierIndexToRust(verifier_index), + tsRustConversionNative.fq.proofToRust(proof) + ) + ); +}; + +// Provides: fq_oracles_create_no_public +// Requires: fq_oracles_create +var fq_oracles_create_no_public = function (lgr_comm, verifier_index, proof) { + return fq_oracles_create(lgr_comm, verifier_index, [0, 0, proof]); +}; + +// Provides: fq_oracles_dummy +// Requires: plonk_wasm, tsRustConversionNative +var fq_oracles_dummy = function () { + return tsRustConversionNative.fq.oraclesFromRust(plonk_wasm.fq_oracles_dummy()); +}; + +// Provides: fq_oracles_deep_copy +// Requires: plonk_wasm, tsRustConversionNative +var fq_oracles_deep_copy = function (x) { + return tsRustConversionNative.fq.oraclesFromRust( + plonk_wasm.fq_oracles_deep_copy(tsRustConversionNative.fq.oraclesToRust(x)) + ); +}; // Provides: caml_pasta_fq_poseidon_block_cipher // Requires: plonk_wasm, tsRustConversionNative diff --git a/src/lib/crypto/kimchi_bindings/js/native/native-overrides/proof.js b/src/lib/crypto/kimchi_bindings/js/native/native-overrides/proof.js index 782c416d69b0..2a81aa0c3990 100644 --- a/src/lib/crypto/kimchi_bindings/js/native/native-overrides/proof.js +++ b/src/lib/crypto/kimchi_bindings/js/native/native-overrides/proof.js @@ -1,9 +1,9 @@ -/* global plonk_wasm, tsRustConversion +/* global plonk_wasm, tsRustConversionNative */ // Provides: caml_pasta_fp_plonk_proof_create -// Requires: plonk_wasm, tsRustConversion +// Requires: plonk_wasm, tsRustConversionNative var caml_pasta_fp_plonk_proof_create = function ( index, witness_cols, @@ -12,14 +12,30 @@ var caml_pasta_fp_plonk_proof_create = function ( prev_sgs ) { var w = new plonk_wasm.WasmVecVecFp(witness_cols.length - 1); + var ww = new w.WasmVecVecFp(witness_cols.length - 1) for (var i = 1; i < witness_cols.length; i++) { - w.push(tsRustConversion.fp.vectorToRust(witness_cols[i])); + ww.push(tsRustConversionNative.fp.vectorToRust(witness_cols[i])); } - witness_cols = w; - prev_challenges = tsRustConversion.fp.vectorToRust(prev_challenges); + + witness_cols = ww; + prev_challenges = tsRustConversionNative.fp.vectorToRust(prev_challenges); var wasm_runtime_tables = - tsRustConversion.fp.runtimeTablesToRust(caml_runtime_tables); - prev_sgs = tsRustConversion.fp.pointsToRust(prev_sgs); + tsRustConversionNative.fp.runtimeTablesToRust(caml_runtime_tables); + prev_sgs = tsRustConversionNative.fp.pointsToRust(prev_sgs); + + /* + index: &External<$NapiIndex>, + witness: $NapiVecVec, + runtime_tables: NapiVector, + prev_challenges: NapiFlatVector<$NapiF>, + prev_sgs: NapiVector<$NapiG>, + */ + + console.log('index: ', index); + console.log('witness cols: ', witness_cols) + console.log("wasm_runtime_tables: ", wasm_runtime_tables) + console.log('prev challenges: ', prev_challenges) + console.log('prev_sgs: ', prev_sgs) var proof = plonk_wasm.caml_pasta_fp_plonk_proof_create( index, witness_cols, @@ -27,5 +43,115 @@ var caml_pasta_fp_plonk_proof_create = function ( prev_challenges, prev_sgs ); - return tsRustConversion.fp.proofFromRust(proof); + console.log('proof?') + return tsRustConversionNative.fp.proofFromRust(proof); +}; + +// Provides: caml_pasta_fp_plonk_proof_verify +// Requires: plonk_wasm, tsRustConversionNative +var caml_pasta_fp_plonk_proof_verify = function (index, proof) { + index = tsRustConversionNative.fp.verifierIndexToRust(index); + proof = tsRustConversionNative.fp.proofToRust(proof); + return plonk_wasm.caml_pasta_fp_plonk_proof_verify(index, proof); +}; + +// Provides: caml_pasta_fp_plonk_proof_batch_verify +// Requires: plonk_wasm, tsRustConversionNative +var caml_pasta_fp_plonk_proof_batch_verify = function (indexes, proofs) { + indexes = tsRustConversionNative.mapMlArrayToRustVector( + indexes, + tsRustConversionNative.fp.verifierIndexToRust + ); + proofs = tsRustConversionNative.mapMlArrayToRustVector( + proofs, + tsRustConversionNative.fp.proofToRust + ); + return plonk_wasm.caml_pasta_fp_plonk_proof_batch_verify(indexes, proofs); +}; + +// Provides: caml_pasta_fp_plonk_proof_dummy +// Requires: plonk_wasm, tsRustConversionNative +var caml_pasta_fp_plonk_proof_dummy = function () { + return tsRustConversionNative.fp.proofFromRust( + plonk_wasm.caml_pasta_fp_plonk_proof_dummy() + ); +}; + +// Provides: caml_pasta_fp_plonk_proof_deep_copy +// Requires: plonk_wasm, tsRustConversionNative +var caml_pasta_fp_plonk_proof_deep_copy = function (proof) { + return tsRustConversionNative.fp.proofFromRust( + plonk_wasm.caml_pasta_fp_plonk_proof_deep_copy( + tsRustConversionNative.fp.proofToRust(proof) + ) + ); +}; + +// Provides: caml_pasta_fq_plonk_proof_create +// Requires: plonk_wasm, tsRustConversionNative +var caml_pasta_fq_plonk_proof_create = function ( + index, + witness_cols, + caml_runtime_tables, + prev_challenges, + prev_sgs +) { + var w = new plonk_wasm.WasmVecVecFq(witness_cols.length - 1); + for (var i = 1; i < witness_cols.length; i++) { + w.push(tsRustConversionNative.fq.vectorToRust(witness_cols[i])); + } + witness_cols = w; + prev_challenges = tsRustConversionNative.fq.vectorToRust(prev_challenges); + var wasm_runtime_tables = + tsRustConversionNative.fq.runtimeTablesToRust(caml_runtime_tables); + prev_sgs = tsRustConversionNative.fq.pointsToRust(prev_sgs); + var proof = plonk_wasm.caml_pasta_fq_plonk_proof_create( + index, + witness_cols, + wasm_runtime_tables, + prev_challenges, + prev_sgs + ); + return tsRustConversionNative.fq.proofFromRust(proof); +}; + +// Provides: caml_pasta_fq_plonk_proof_verify +// Requires: plonk_wasm, tsRustConversionNative +var caml_pasta_fq_plonk_proof_verify = function (index, proof) { + index = tsRustConversionNative.fq.verifierIndexToRust(index); + proof = tsRustConversionNative.fq.proofToRust(proof); + return plonk_wasm.caml_pasta_fq_plonk_proof_verify(index, proof); }; + +// Provides: caml_pasta_fq_plonk_proof_batch_verify +// Requires: plonk_wasm, tsRustConversionNative +var caml_pasta_fq_plonk_proof_batch_verify = function (indexes, proofs) { + indexes = tsRustConversionNative.mapMlArrayToRustVector( + indexes, + tsRustConversionNative.fq.verifierIndexToRust + ); + proofs = tsRustConversionNative.mapMlArrayToRustVector( + proofs, + tsRustConversionNative.fq.proofToRust + ); + return plonk_wasm.caml_pasta_fq_plonk_proof_batch_verify(indexes, proofs); +}; + +// Provides: caml_pasta_fq_plonk_proof_dummy +// Requires: plonk_wasm, tsRustConversionNative +var caml_pasta_fq_plonk_proof_dummy = function () { + return tsRustConversionNative.fq.proofFromRust( + plonk_wasm.caml_pasta_fq_plonk_proof_dummy() + ); +}; + +// Provides: caml_pasta_fq_plonk_proof_deep_copy +// Requires: plonk_wasm, tsRustConversionNative +var caml_pasta_fq_plonk_proof_deep_copy = function (proof) { + return tsRustConversionNative.fq.proofFromRust( + plonk_wasm.caml_pasta_fq_plonk_proof_deep_copy( + tsRustConversionNative.fq.proofToRust(proof) + ) + ); +}; + diff --git a/src/lib/crypto/kimchi_bindings/js/native/native-overrides/prover-index.js b/src/lib/crypto/kimchi_bindings/js/native/native-overrides/prover-index.js index 56794d71f912..6a74a29dc2b1 100644 --- a/src/lib/crypto/kimchi_bindings/js/native/native-overrides/prover-index.js +++ b/src/lib/crypto/kimchi_bindings/js/native/native-overrides/prover-index.js @@ -4,7 +4,7 @@ // Requires: plonk_wasm function caml_pasta_fp_plonk_index_max_degree(prover_index) { var bytes = prover_index.serialize() - var index = plonk_wasm.prover_index_fp_from_bytes(bytes); + var index = plonk_wasm.prover_index_fp_deserialize(bytes); // TODO: ^ remove the round trip when napi has direct access to the object return plonk_wasm.caml_pasta_fp_plonk_index_max_degree(index); @@ -14,7 +14,7 @@ function caml_pasta_fp_plonk_index_max_degree(prover_index) { // Requires: plonk_wasm function caml_pasta_fp_plonk_index_public_inputs(prover_index) { var bytes = prover_index.serialize() - var index = plonk_wasm.prover_index_fp_from_bytes(bytes); + var index = plonk_wasm.prover_index_fp_deserialize(bytes); // TODO: ^ remove the round trip when napi has direct access to the object return plonk_wasm.caml_pasta_fp_plonk_index_public_inputs(index); @@ -24,7 +24,7 @@ function caml_pasta_fp_plonk_index_public_inputs(prover_index) { // Requires: plonk_wasm function caml_pasta_fp_plonk_index_domain_d1_size(prover_index) { var bytes = prover_index.serialize() - var index = plonk_wasm.prover_index_fp_from_bytes(bytes); + var index = plonk_wasm.prover_index_fp_deserialize(bytes); // TODO: ^ remove the round trip when napi has direct access to the object return plonk_wasm.caml_pasta_fp_plonk_index_domain_d1_size(index); @@ -34,7 +34,7 @@ function caml_pasta_fp_plonk_index_domain_d1_size(prover_index) { // Requires: plonk_wasm function caml_pasta_fp_plonk_index_domain_d4_size(prover_index) { var bytes = prover_index.serialize() - var index = plonk_wasm.prover_index_fp_from_bytes(bytes); + var index = plonk_wasm.prover_index_fp_deserialize(bytes); // TODO: ^ remove the round trip when napi has direct access to the object return plonk_wasm.caml_pasta_fp_plonk_index_domain_d4_size(index); @@ -44,7 +44,7 @@ function caml_pasta_fp_plonk_index_domain_d4_size(prover_index) { // Requires: plonk_wasm function caml_pasta_fp_plonk_index_domain_d8_size(prover_index) { var bytes = prover_index.serialize() - var index = plonk_wasm.prover_index_fp_from_bytes(bytes); + var index = plonk_wasm.prover_index_fp_deserialize(bytes); // TODO: ^ remove the round trip when napi has direct access to the object return plonk_wasm.caml_pasta_fp_plonk_index_domain_d8_size(index); @@ -58,7 +58,7 @@ function caml_pasta_fp_plonk_index_domain_d8_size(prover_index) { // Requires: plonk_wasm function caml_pasta_fq_plonk_index_max_degree(prover_index) { var bytes = prover_index.serialize() - var index = plonk_wasm.prover_index_fq_from_bytes(bytes); + var index = plonk_wasm.prover_index_fq_deserialize(bytes); // TODO: ^ remove the round trip when napi has direct access to the object return plonk_wasm.caml_pasta_fq_plonk_index_max_degree(index); @@ -68,7 +68,7 @@ function caml_pasta_fq_plonk_index_max_degree(prover_index) { // Requires: plonk_wasm function caml_pasta_fq_plonk_index_public_inputs(prover_index) { var bytes = prover_index.serialize() - var index = plonk_wasm.prover_index_fq_from_bytes(bytes); + var index = plonk_wasm.prover_index_fq_deserialize(bytes); // TODO: ^ remove the round trip when napi has direct access to the object return plonk_wasm.caml_pasta_fq_plonk_index_public_inputs(index); @@ -78,7 +78,7 @@ function caml_pasta_fq_plonk_index_public_inputs(prover_index) { // Requires: plonk_wasm function caml_pasta_fq_plonk_index_domain_d1_size(prover_index) { var bytes = prover_index.serialize() - var index = plonk_wasm.prover_index_fq_from_bytes(bytes); + var index = plonk_wasm.prover_index_fq_deserialize(bytes); // TODO: ^ remove the round trip when napi has direct access to the object return plonk_wasm.caml_pasta_fq_plonk_index_domain_d1_size(index); @@ -88,7 +88,7 @@ function caml_pasta_fq_plonk_index_domain_d1_size(prover_index) { // Requires: plonk_wasm function caml_pasta_fq_plonk_index_domain_d4_size(prover_index) { var bytes = prover_index.serialize() - var index = plonk_wasm.prover_index_fq_from_bytes(bytes); + var index = plonk_wasm.prover_index_fq_deserialize(bytes); // TODO: ^ remove the round trip when napi has direct access to the object return plonk_wasm.caml_pasta_fq_plonk_index_domain_d4_size(index); @@ -98,15 +98,35 @@ function caml_pasta_fq_plonk_index_domain_d4_size(prover_index) { // Requires: plonk_wasm function caml_pasta_fq_plonk_index_domain_d8_size(prover_index) { var bytes = prover_index.serialize() - var index = plonk_wasm.prover_index_fq_from_bytes(bytes); + var index = plonk_wasm.prover_index_fq_deserialize(bytes); // TODO: ^ remove the round trip when napi has direct access to the object return plonk_wasm.caml_pasta_fq_plonk_index_domain_d8_size(index); } +// Provides: caml_pasta_fp_plonk_index_serialize +// Requires: plonk_wasm +var caml_pasta_fp_plonk_index_serialize = function (index) { + // Workaround for napi issue where methods on External objects are not accessible + if (typeof index.serialize === 'function') { + return index.serialize(); + } + return plonk_wasm.prover_index_fp_serialize(index); +}; + +// Provides: caml_pasta_fp_plonk_index_deserialize +// Requires: plonk_wasm +var caml_pasta_fp_plonk_index_deserialize = function (index) { + // Workaround for napi issue where methods on External objects are not accessible + if (typeof index.deserialize === 'function') { + return index.deserialize(); + } + return plonk_wasm.prover_index_fp_deserialize(index); +}; + // Provides: caml_pasta_fp_plonk_index_create -// Requires: plonk_wasm, free_on_finalize, tsRustConversionNative +// Requires: plonk_wasm, tsRustConversionNative var caml_pasta_fp_plonk_index_create = function ( gates, public_inputs, @@ -116,15 +136,16 @@ var caml_pasta_fp_plonk_index_create = function ( urs, lazy_mode ) { + console.log('passing through wasm lookup tables') var wasm_lookup_tables = tsRustConversionNative.fp.lookupTablesToRust(caml_lookup_tables); var wasm_runtime_table_cfgs = tsRustConversionNative.fp.runtimeTableCfgsToRust( caml_runtime_table_cfgs ); - console.time("conversion") + console.time("conversion plonk index create") var gate_vec = plonk_wasm.caml_pasta_fp_plonk_gate_vector_from_bytes(gates.serialize()); var urs_ser = plonk_wasm.caml_fp_srs_from_bytes_external(urs.serialize()) - console.timeEnd("conversion") + console.timeEnd("conversion plonk index create") console.time("index_create") var t = plonk_wasm.caml_pasta_fp_plonk_index_create( @@ -138,11 +159,7 @@ var caml_pasta_fp_plonk_index_create = function ( ); console.timeEnd("index_create"); - console.time("finalize_conversion") - var wasm_t = plonk_wasm.WasmPastaFpPlonkIndex.deserialize(plonk_wasm.prover_index_fp_to_bytes(t)) - console.timeEnd("finalize_conversion") - - return free_on_finalize(wasm_t); + return t; }; // Provides: caml_pasta_fp_plonk_index_create_bytecode @@ -197,8 +214,28 @@ var caml_pasta_fp_plonk_index_write = function (append, t, path) { ); }; +// Provides: caml_pasta_fq_plonk_index_serialize +// Requires: plonk_wasm +var caml_pasta_fq_plonk_index_serialize = function (index) { + // Workaround for napi issue where methods on External objects are not accessible + if (typeof index.serialize === 'function') { + return index.serialize(); + } + return plonk_wasm.prover_index_fq_serialize(index); +}; + +// Provides: caml_pasta_fq_plonk_index_deserialize +// Requires: plonk_wasm +var caml_pasta_fq_plonk_index_deserialize = function (index) { + // Workaround for napi issue where methods on External objects are not accessible + if (typeof index.deserialize === 'function') { + return index.deserialize(); + } + return plonk_wasm.prover_index_fq_deserialize(index); +}; + // Provides: caml_pasta_fq_plonk_index_create -// Requires: plonk_wasm, free_on_finalize, tsRustConversionNative +// Requires: plonk_wasm, tsRustConversionNative var caml_pasta_fq_plonk_index_create = function ( gates, public_inputs, @@ -208,16 +245,20 @@ var caml_pasta_fq_plonk_index_create = function ( urs, lazy_mode ) { + console.log("anais: 1"); var wasm_lookup_tables = tsRustConversionNative.fq.lookupTablesToRust(caml_lookup_tables); + console.log("anais: 2"); var wasm_runtime_table_cfgs = tsRustConversionNative.fq.runtimeTableCfgsToRust( caml_runtime_table_cfgs ); + console.log("anais: 3"); console.time("conversion") - var gate_vec = plonk_wasm.caml_pasta_fq_plonk_gate_vector_from_bytes(gates.serialize()); + var gate_vec = plonk_wasm.caml_pasta_fq_plonk_gate_vector_deserialize(gates.serialize()); var urs_ser = plonk_wasm.caml_fq_srs_from_bytes_external(urs.serialize()) console.timeEnd("conversion") + console.log("anais: 4"); console.time("index_create") var t = plonk_wasm.caml_pasta_fq_plonk_index_create( @@ -231,11 +272,7 @@ var caml_pasta_fq_plonk_index_create = function ( ); console.timeEnd("index_create"); - console.time("finalize_conversion") - var wasm_t = plonk_wasm.WasmPastaFqPlonkIndex.deserialize(plonk_wasm.prover_index_fq_to_bytes(t)) - console.timeEnd("finalize_conversion") - - return free_on_finalize(wasm_t); + return t; }; // Provides: caml_pasta_fq_plonk_index_create_bytecode @@ -288,4 +325,4 @@ var caml_pasta_fq_plonk_index_write = function (append, t, path) { t, caml_jsstring_of_string(path) ); -}; +}; \ No newline at end of file diff --git a/src/lib/crypto/kimchi_bindings/js/native/native-overrides/srs.js b/src/lib/crypto/kimchi_bindings/js/native/native-overrides/srs.js index fae6debacf57..b0d73dd21bff 100644 --- a/src/lib/crypto/kimchi_bindings/js/native/native-overrides/srs.js +++ b/src/lib/crypto/kimchi_bindings/js/native/native-overrides/srs.js @@ -1,16 +1,19 @@ /* global plonk_wasm, caml_jsstring_of_string, - tsBindings, tsRustConversion + tsBindings, tsRustConversionNative */ // Provides: tsSrs // Requires: tsBindings, plonk_wasm -var tsSrs = tsBindings.srs(plonk_wasm); +var tsSrs = tsBindings.srsNative(plonk_wasm); // srs // Provides: caml_fp_srs_create // Requires: tsSrs -var caml_fp_srs_create = tsSrs.fp.create; +var caml_fp_srs_create = function (log_size) { + console.log("native caml_fp_srs_create"); + return tsSrs.fp.create(log_size); +} // Provides: caml_fp_srs_write // Requires: plonk_wasm, caml_jsstring_of_string @@ -43,17 +46,56 @@ var caml_fp_srs_read = function (offset, path) { // Provides: caml_fp_srs_lagrange_commitments_whole_domain // Requires: tsSrs -var caml_fp_srs_lagrange_commitments_whole_domain = - tsSrs.fp.lagrangeCommitmentsWholeDomain; +var caml_fp_srs_lagrange_commitments_whole_domain = function (srs, domain_size) { + console.log("native caml_fp_srs_lagrange_commitments_whole_domain"); + return tsSrs.fp.lagrangeCommitmentsWholeDomain(srs, domain_size); +} // Provides: caml_fq_srs_lagrange_commitments_whole_domain // Requires: tsSrs var caml_fq_srs_lagrange_commitments_whole_domain = - tsSrs.fq.lagrangeCommitmentsWholeDomain; + function (srs, domain_size) { + console.log("native caml_fq_srs_lagrange_commitments_whole_domain"); + return tsSrs.fq.lagrangeCommitmentsWholeDomain(srs, domain_size); + } // Provides: caml_fp_srs_lagrange_commitment // Requires: tsSrs var caml_fp_srs_lagrange_commitment = tsSrs.fp.lagrangeCommitment; + +// Provides: caml_fp_srs_to_bytes_external +// Requires: plonk_wasm +var caml_fp_srs_to_bytes_external = function (srs) { + console.log("native caml_fp_srs_to_bytes_external"); + return plonk_wasm.caml_fp_srs_to_bytes_external(srs); +}; + +// Provides: caml_fp_srs_from_bytes_external +// Requires: plonk_wasm +var caml_fp_srs_from_bytes_external = function (bytes) { + console.log("native caml_fp_srs_from_bytes_external"); + return plonk_wasm.caml_fp_srs_from_bytes_external(bytes); +}; + +// Provides: caml_fp_srs_lagrange_commitment +// Requires: tsSrs +var caml_fp_srs_lagrange_commitment = function (srs, i) { + console.log("native caml_fp_srs_lagrange_commitment"); + return tsSrs.fp.lagrangeCommitment(srs, i); +} + +// Provides: caml_fp_srs_maybe_lagrange_commitment +// Requires: plonk_wasm, tsRustConversionNative +var caml_fp_srs_maybe_lagrange_commitment = function (srs, domain_size, i) { + console.log("native caml_fp_srs_maybe_lagrange_commitment"); + var result = plonk_wasm.caml_fp_srs_maybe_lagrange_commitment(srs, domain_size, i); + console.log("result", result); + if (result == null) return 0; // None + var polyComm = tsRustConversionNative.fp.polyCommFromRust(result); + console.log("polyComm", polyComm); + if (polyComm == undefined) return 0; // None + return [0, polyComm]; // Some(...) +}; // Provides: caml_fp_srs_commit_evaluations // Requires: plonk_wasm, tsRustConversionNative @@ -114,11 +156,17 @@ var caml_fp_srs_h = function (t) { // Provides: caml_fp_srs_add_lagrange_basis // Requires: tsSrs -var caml_fp_srs_add_lagrange_basis = tsSrs.fp.addLagrangeBasis; +var caml_fp_srs_add_lagrange_basis = function (srs, domain_size) { + console.log("native caml_fp_srs_add_lagrange_basis"); + return tsSrs.fp.addLagrangeBasis(srs, domain_size); +}; // Provides: caml_fq_srs_create // Requires: tsSrs -var caml_fq_srs_create = tsSrs.fq.create; +var caml_fq_srs_create = function (log_size) { + console.log("native caml_fq_srs_create"); + return tsSrs.fq.create(log_size); +} // Provides: caml_fq_srs_write // Requires: plonk_wasm, caml_jsstring_of_string @@ -153,6 +201,24 @@ var caml_fq_srs_read = function (offset, path) { // Requires: tsSrs var caml_fq_srs_lagrange_commitment = tsSrs.fq.lagrangeCommitment; +// Provides: caml_fq_srs_lagrange_commitment +// Requires: tsSrs +var caml_fq_srs_lagrange_commitment = function (srs, i) { + console.log("native caml_fq_srs_lagrange_commitment"); + return tsSrs.fq.lagrangeCommitment(srs, i); +}; + +// Provides: caml_fq_srs_maybe_lagrange_commitment +// Requires: plonk_wasm, tsRustConversionNative +var caml_fq_srs_maybe_lagrange_commitment = function (srs, domain_size, i) { + console.log("native caml_fq_srs_maybe_lagrange_commitment"); + var result = plonk_wasm.caml_fq_srs_maybe_lagrange_commitment(srs, domain_size, i); + if (result == null) return 0; // None + var polyComm = tsRustConversionNative.fq.polyCommFromRust(result); + if (polyComm == undefined) return 0; // None + return [0, polyComm]; // Some(...) +}; + // Provides: caml_fq_srs_commit_evaluations // Requires: plonk_wasm, tsRustConversionNative var caml_fq_srs_commit_evaluations = function (t, domain_size, fqs) { @@ -216,4 +282,7 @@ var caml_fq_srs_h = function (t) { // Provides: caml_fq_srs_add_lagrange_basis // Requires: tsSrs -var caml_fq_srs_add_lagrange_basis = tsSrs.fq.addLagrangeBasis; +var caml_fq_srs_add_lagrange_basis = function (srs, domain_size) { + console.log("native caml_fq_srs_add_lagrange_basis"); + return tsSrs.fq.addLagrangeBasis(srs, domain_size); +}; diff --git a/src/lib/crypto/kimchi_bindings/js/native/native-overrides/verifier-index.js b/src/lib/crypto/kimchi_bindings/js/native/native-overrides/verifier-index.js index 683751701676..25c004b00d62 100644 --- a/src/lib/crypto/kimchi_bindings/js/native/native-overrides/verifier-index.js +++ b/src/lib/crypto/kimchi_bindings/js/native/native-overrides/verifier-index.js @@ -1,14 +1,101 @@ /* global plonk_wasm, tsRustConversionNative */ +// Provides: caml_pasta_fp_plonk_verifier_index_create +// Requires: plonk_wasm, tsRustConversionNative +var caml_pasta_fp_plonk_verifier_index_create = function (x) { + console.log("jsoo caml_pasta_fp_plonk_verifier_index_create x", x); + var vk = plonk_wasm.caml_pasta_fp_plonk_verifier_index_create(x); + console.log("vk", vk) + return tsRustConversionNative.fp.verifierIndexFromRust(vk); +}; // Provides: caml_pasta_fq_plonk_verifier_index_shifts // Requires: plonk_wasm, tsRustConversionNative var caml_pasta_fq_plonk_verifier_index_shifts = function (log2_size) { - return tsRustConversionNative.fq.shiftsFromRust( - plonk_wasm.caml_pasta_fq_plonk_verifier_index_shifts(log2_size) + console.log("log2_size", log2_size); + try { + var shifts = plonk_wasm.caml_pasta_fq_plonk_verifier_index_shifts(log2_size); + console.log("shifts", shifts); + console.log("shiftsFromRust", tsRustConversionNative.fq.shiftsFromRust( + shifts + )) + return tsRustConversionNative.fq.shiftsFromRust( + shifts + ); + } catch (e) { + console.error("Error calling caml_pasta_fq_plonk_verifier_index_shifts:", e); + throw e; + } +}; + +// Provides: caml_pasta_fp_plonk_verifier_index_read +// Requires: plonk_wasm, caml_jsstring_of_string, tsRustConversionNative +var caml_pasta_fp_plonk_verifier_index_read = function (offset, urs, path) { + console.log("caml_pasta_fp_plonk_verifier_index_read") + + if (offset === 0) { + offset = undefined; + } else { + offset = offset[1]; + } + return tsRustConversionNative.fp.verifierIndexFromRust( + plonk_wasm.caml_pasta_fp_plonk_verifier_index_read( + offset, + urs, + caml_jsstring_of_string(path) + ) ); }; +// Provides: caml_pasta_fp_plonk_verifier_index_write +// Requires: plonk_wasm, caml_jsstring_of_string, tsRustConversionNative +var caml_pasta_fp_plonk_verifier_index_write = function (append, t, path) { + console.log("caml_pasta_fp_plonk_verifier_index_write") + + if (append === 0) { + append = undefined; + } else { + append = append[1]; + } + return plonk_wasm.caml_pasta_fp_plonk_verifier_index_write( + append, + tsRustConversionNative.fp.verifierIndexToRust(t), + caml_jsstring_of_string(path) + ); +}; + + +// Provides: caml_pasta_fp_plonk_verifier_index_dummy +// Requires: plonk_wasm, tsRustConversionNative +var caml_pasta_fp_plonk_verifier_index_dummy = function () { + console.log("caml_pasta_fp_plonk_verifier_index_dummy") + + var res = plonk_wasm.caml_pasta_fp_plonk_verifier_index_dummy(); + return tsRustConversionNative.fp.verifierIndexFromRust(res); +}; + +// Provides: caml_pasta_fp_plonk_verifier_index_deep_copy +// Requires: plonk_wasm, tsRustConversionNative +var caml_pasta_fp_plonk_verifier_index_deep_copy = function (x) { + console.log("caml_pasta_fp_plonk_verifier_index_deep_copy") + return tsRustConversionNative.fp.verifierIndexFromRust( + plonk_wasm.caml_pasta_fp_plonk_verifier_index_deep_copy( + tsRustConversionNative.fp.verifierIndexToRust(x) + ) + ); +}; + + +// Provides: caml_pasta_fq_plonk_verifier_index_create +// Requires: plonk_wasm, tsRustConversionNative +var caml_pasta_fq_plonk_verifier_index_create = function (x) { + console.log("caml_pasta_fq_plonk_verifier_index_create") + return tsRustConversionNative.fq.verifierIndexFromRust( + plonk_wasm.caml_pasta_fq_plonk_verifier_index_create(x) + ); +}; + + // Provides: caml_pasta_fp_plonk_verifier_index_shifts // Requires: plonk_wasm, tsRustConversionNative var caml_pasta_fp_plonk_verifier_index_shifts = function (log2_size) { @@ -16,3 +103,57 @@ var caml_pasta_fp_plonk_verifier_index_shifts = function (log2_size) { plonk_wasm.caml_pasta_fp_plonk_verifier_index_shifts(log2_size) ); }; + +// Provides: caml_pasta_fq_plonk_verifier_index_read +// Requires: plonk_wasm, caml_jsstring_of_string, tsRustConversionNative +var caml_pasta_fq_plonk_verifier_index_read = function (offset, urs, path) { + console.log("caml_pasta_fq_plonk_verifier_index_read") + if (offset === 0) { + offset = undefined; + } else { + offset = offset[1]; + } + return tsRustConversionNative.fq.verifierIndexFromRust( + plonk_wasm.caml_pasta_fq_plonk_verifier_index_read( + offset, + urs, + caml_jsstring_of_string(path) + ) + ); +}; + +// Provides: caml_pasta_fq_plonk_verifier_index_write +// Requires: plonk_wasm, caml_jsstring_of_string, tsRustConversionNative +var caml_pasta_fq_plonk_verifier_index_write = function (append, t, path) { + console.log("caml_pasta_fq_plonk_verifier_index_write") + if (append === 0) { + append = undefined; + } else { + append = append[1]; + } + return plonk_wasm.caml_pasta_fq_plonk_verifier_index_write( + append, + tsRustConversionNative.fq.verifierIndexToRust(t), + caml_jsstring_of_string(path) + ); +}; + +// Provides: caml_pasta_fq_plonk_verifier_index_dummy +// Requires: plonk_wasm, tsRustConversionNative +var caml_pasta_fq_plonk_verifier_index_dummy = function () { + console.log("caml_pasta_fq_plonk_verifier_index_dummy") + return tsRustConversionNative.fq.verifierIndexFromRust( + plonk_wasm.caml_pasta_fq_plonk_verifier_index_dummy() + ); +}; + +// Provides: caml_pasta_fq_plonk_verifier_index_deep_copy +// Requires: plonk_wasm, tsRustConversionNative, tsRustConversionNative +var caml_pasta_fq_plonk_verifier_index_deep_copy = function (x) { + console.log("caml_pasta_fq_plonk_verifier_index_deep_copy") + return tsRustConversionNative.fq.verifierIndexFromRust( + plonk_wasm.caml_pasta_fq_plonk_verifier_index_deep_copy( + tsRustConversionNative.fq.verifierIndexToRust(x) + ) + ); +}; diff --git a/src/lib/crypto/kimchi_bindings/js/node_js/node_backend.js b/src/lib/crypto/kimchi_bindings/js/node_js/node_backend.js index 24c05ccf48a6..1be6af9878cf 100644 --- a/src/lib/crypto/kimchi_bindings/js/node_js/node_backend.js +++ b/src/lib/crypto/kimchi_bindings/js/node_js/node_backend.js @@ -11,16 +11,45 @@ var plonk_wasm = (function() { // IS SET var overrides = [ "prover_to_json", - "prover_index_fp_from_bytes", - "prover_index_fq_from_bytes", - "prover_index_fp_to_bytes", - "prover_index_fq_to_bytes", + "prover_index_fp_deserialize", + "prover_index_fq_deserialize", + "prover_index_fp_serialize", + "prover_index_fq_serialize", + "WasmPastaFpPlonkIndex", + "WasmPastaFqPlonkIndex", "caml_pasta_fp_poseidon_block_cipher", "caml_pasta_fq_poseidon_block_cipher", + "caml_pasta_fp_plonk_proof_create", + "WasmFpPlonkVerifierIndex", + "WasmFqPlonkVerifierIndex", + "WasmFpDomain", + "WasmFqDomain", + "WasmFpShifts", + "WasmFqShifts", + "WasmFpLookupSelectors", + "WasmFqLookupSelectors", + "WasmFpLookupVerifierIndex", + "WasmFqLookupVerifierIndex", + "WasmFpPlonkVerificationEvals", + "WasmFqPlonkVerificationEvals", + "WasmFpPlonkLookupVerifierIndex", + "WasmFqPlonkLookupVerifierIndex", + "caml_pasta_fp_plonk_verifier_index_create", + "caml_pasta_fq_plonk_verifier_index_create", + "caml_pasta_fp_plonk_verifier_index_read", + "caml_pasta_fq_plonk_verifier_index_read", + "caml_pasta_fp_plonk_verifier_index_write", + "caml_pasta_fq_plonk_verifier_index_write", + "caml_pasta_fp_plonk_verifier_index_dummy", + "caml_pasta_fq_plonk_verifier_index_dummy", + "caml_pasta_fp_plonk_verifier_index_serialize", + "caml_pasta_fq_plonk_verifier_index_serialize", + "caml_pasta_fp_plonk_verifier_index_deserialize", + "caml_pasta_fq_plonk_verifier_index_deserialize", + "caml_pasta_fp_plonk_verifier_index_deep_copy", + "caml_pasta_fq_plonk_verifier_index_deep_copy", "caml_pasta_fp_plonk_verifier_index_shifts", "caml_pasta_fq_plonk_verifier_index_shifts", - "WasmFpPolyComm", - "WasmFqPolyComm", "caml_pasta_fp_plonk_gate_vector_create", "caml_pasta_fq_plonk_gate_vector_create", "caml_pasta_fp_plonk_gate_vector_add", @@ -57,11 +86,22 @@ var plonk_wasm = (function() { "caml_pasta_fq_plonk_index_read", "caml_fp_srs_from_bytes", "caml_fq_srs_from_bytes", + "caml_fp_srs_to_bytes_external", + "caml_fq_srs_to_bytes_external", + "caml_fp_srs_from_bytes_external", + "caml_fq_srs_from_bytes_external", + "caml_fp_srs_to_bytes", + "caml_fq_srs_to_bytes", "WasmFpSrs", "caml_fp_srs_create", "caml_fp_srs_create_parallel", - "caml_fq_srs_get", - "caml_fq_srs_set", + "caml_fp_srs_get", + "caml_fp_srs_set", + "caml_fp_srs_lagrange_commitment", + "caml_fp_srs_maybe_lagrange_commitment", + "caml_fp_srs_lagrange_commitments_whole_domain_ptr", + "caml_fp_srs_set_lagrange_basis", + "caml_fp_srs_get_lagrange_basis", "caml_fp_srs_write", "caml_fp_srs_read", "caml_fp_srs_add_lagrange_basis", @@ -75,6 +115,11 @@ var plonk_wasm = (function() { "caml_fq_srs_create_parallel", "caml_fq_srs_get", "caml_fq_srs_set", + "caml_fq_srs_lagrange_commitment", + "caml_fq_srs_maybe_lagrange_commitment", + "caml_fq_srs_lagrange_commitments_whole_domain_ptr", + "caml_fq_srs_set_lagrange_basis", + "caml_fq_srs_get_lagrange_basis", "caml_fq_srs_write", "caml_fq_srs_read", "caml_fq_srs_add_lagrange_basis", @@ -89,10 +134,39 @@ var plonk_wasm = (function() { "WasmGVesta", "WasmPastaFp", "WasmPastaFq", + "caml_pasta_fp_plonk_proof_create", + "caml_pasta_fp_plonk_proof_verify", + "caml_pasta_fq_plonk_proof_create", + "caml_pasta_fq_plonk_proof_verify", + "fp_oracles_create", + "fp_oracles_create_no_public", + "fp_oracles_dummy", + "fp_oracles_deep_copy", + "fq_oracles_create", + "fq_oracles_create_no_public", + "fq_oracles_dummy", + "fq_oracles_deep_copy", + "WasmFpOpeningProof", + "WasmFqOpeningProof", + "WasmFpLookupCommitments", + "WasmFqLookupCommitments", + "WasmFpProverProof", + "WasmFqProverProof", + "WasmFpProofEvaluations", + "WasmFqProofEvaluations", + "WasmFpProverCommitments", + "WasmFqProverCommitments", + "WasmVecVecFp", + "WasmVecVecFq", + "WasmFpRuntimeTable", + "WasmFqRuntimeTable", ]; overrides.forEach(function (override) { - wasm[override] = native[override] + wasm[override] = function(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12) { + console.log("calling native override:", override); + return native[override](x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12); + } }) wasm.native = true; } catch (e) { @@ -101,4 +175,4 @@ var plonk_wasm = (function() { } } return wasm -})() +})() \ No newline at end of file diff --git a/src/lib/crypto/proof-systems b/src/lib/crypto/proof-systems index 27272e22abbe..1d1d52480279 160000 --- a/src/lib/crypto/proof-systems +++ b/src/lib/crypto/proof-systems @@ -1 +1 @@ -Subproject commit 27272e22abbef15bdec175e5e771b87ff1b90730 +Subproject commit 1d1d5248027972bffc553a146877423e2a02854d