Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 0 additions & 133 deletions src/lib/crypto/kimchi_bindings/js/bindings/verifier-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,136 +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", x)
var bytes = plonk_wasm.prover_index_fp_to_bytes(x);
console.log("bytes", bytes)
var index = plonk_wasm.WasmPastaFpPlonkIndex.deserialize(bytes)
console.log("index", index)
var vk = plonk_wasm.caml_pasta_fp_plonk_verifier_index_create(index);
console.log("vk", vk)
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)
)
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,7 @@ var caml_pasta_fp_plonk_proof_create = function (
var wasm_runtime_tables =
tsRustConversionNative.fp.runtimeTablesToRust(caml_runtime_tables);
prev_sgs = tsRustConversionNative.fp.pointsToRust(prev_sgs);
/*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,
Expand All @@ -36,7 +29,6 @@ var caml_pasta_fp_plonk_proof_create = function (
prev_sgs
);
return tsRustConversionNative.fp.proofFromRust(proof);
/* return tsRustConversion.fp.proofFromRust(proof); */
};

// Provides: caml_pasta_fp_plonk_proof_verify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -98,13 +98,33 @@ 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, tsRustConversionNative
var caml_pasta_fp_plonk_index_create = function (
Expand Down Expand Up @@ -138,7 +158,7 @@ var caml_pasta_fp_plonk_index_create = function (
);
console.timeEnd("index_create");

return plonk_wasm.prover_index_fp_to_bytes(t);
return t;
};

// Provides: caml_pasta_fp_plonk_index_create_bytecode
Expand Down Expand Up @@ -193,6 +213,26 @@ 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, tsRustConversionNative
var caml_pasta_fq_plonk_index_create = function (
Expand All @@ -214,7 +254,7 @@ var caml_pasta_fq_plonk_index_create = function (
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");
Expand All @@ -231,7 +271,7 @@ var caml_pasta_fq_plonk_index_create = function (
);
console.timeEnd("index_create");

return plonk_wasm.prover_index_fq_to_bytes(t);
return t;
};

// Provides: caml_pasta_fq_plonk_index_create_bytecode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,40 @@ var caml_fq_srs_lagrange_commitments_whole_domain =
// 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
var caml_fp_srs_commit_evaluations = function (t, domain_size, fps) {
Expand Down Expand Up @@ -181,6 +208,17 @@ var caml_fq_srs_lagrange_commitment = function (srs, i) {
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) {
Expand Down Expand Up @@ -247,4 +285,4 @@ var caml_fq_srs_h = function (t) {
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);
};
};
Loading