Skip to content

Commit 3116ffc

Browse files
committed
Merge branch 'querolita/napi-proof' into shigoto/native/napi/oracles
2 parents 2cffb7f + 6d9b2f6 commit 3116ffc

File tree

10 files changed

+195
-114
lines changed

10 files changed

+195
-114
lines changed
Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +0,0 @@
1-
/* global plonk_wasm, tsRustConversion
2-
*/
3-
4-
5-
// Provides: caml_pasta_fp_plonk_proof_batch_verify
6-
// Requires: plonk_wasm, tsRustConversion
7-
var caml_pasta_fp_plonk_proof_batch_verify = function (indexes, proofs) {
8-
indexes = tsRustConversion.mapMlArrayToRustVector(
9-
indexes,
10-
tsRustConversion.fp.verifierIndexToRust
11-
);
12-
proofs = tsRustConversion.mapMlArrayToRustVector(
13-
proofs,
14-
tsRustConversion.fp.proofToRust
15-
);
16-
return plonk_wasm.caml_pasta_fp_plonk_proof_batch_verify(indexes, proofs);
17-
};
18-
19-
// Provides: caml_pasta_fp_plonk_proof_dummy
20-
// Requires: plonk_wasm, tsRustConversion
21-
var caml_pasta_fp_plonk_proof_dummy = function () {
22-
return tsRustConversion.fp.proofFromRust(
23-
plonk_wasm.caml_pasta_fp_plonk_proof_dummy()
24-
);
25-
};
26-
27-
// Provides: caml_pasta_fp_plonk_proof_deep_copy
28-
// Requires: plonk_wasm, tsRustConversion
29-
var caml_pasta_fp_plonk_proof_deep_copy = function (proof) {
30-
return tsRustConversion.fp.proofFromRust(
31-
plonk_wasm.caml_pasta_fp_plonk_proof_deep_copy(
32-
tsRustConversion.fp.proofToRust(proof)
33-
)
34-
);
35-
};
36-
37-
38-
39-
// Provides: caml_pasta_fq_plonk_proof_batch_verify
40-
// Requires: plonk_wasm, tsRustConversion
41-
var caml_pasta_fq_plonk_proof_batch_verify = function (indexes, proofs) {
42-
indexes = tsRustConversion.mapMlArrayToRustVector(
43-
indexes,
44-
tsRustConversion.fq.verifierIndexToRust
45-
);
46-
proofs = tsRustConversion.mapMlArrayToRustVector(
47-
proofs,
48-
tsRustConversion.fq.proofToRust
49-
);
50-
return plonk_wasm.caml_pasta_fq_plonk_proof_batch_verify(indexes, proofs);
51-
};
52-
53-
// Provides: caml_pasta_fq_plonk_proof_dummy
54-
// Requires: plonk_wasm, tsRustConversion
55-
var caml_pasta_fq_plonk_proof_dummy = function () {
56-
return tsRustConversion.fq.proofFromRust(
57-
plonk_wasm.caml_pasta_fq_plonk_proof_dummy()
58-
);
59-
};
60-
61-
// Provides: caml_pasta_fq_plonk_proof_deep_copy
62-
// Requires: plonk_wasm, tsRustConversion
63-
var caml_pasta_fq_plonk_proof_deep_copy = function (proof) {
64-
return tsRustConversion.fq.proofFromRust(
65-
plonk_wasm.caml_pasta_fq_plonk_proof_deep_copy(
66-
tsRustConversion.fq.proofToRust(proof)
67-
)
68-
);
69-
};
70-

src/lib/crypto/kimchi_bindings/js/bindings/verifier-index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ var caml_opt_to_rust = function (caml_optional_value, to_rust) {
2424
// Provides: caml_pasta_fp_plonk_verifier_index_create
2525
// Requires: plonk_wasm, tsRustConversion
2626
var caml_pasta_fp_plonk_verifier_index_create = function (x) {
27-
console.log("caml_pasta_fp_plonk_verifier_index_create")
28-
var vk = plonk_wasm.caml_pasta_fp_plonk_verifier_index_create(x);
27+
console.log("caml_pasta_fp_plonk_verifier_index_create", x)
28+
var bytes = plonk_wasm.prover_index_fp_to_bytes(x);
29+
console.log("bytes", bytes)
30+
var index = plonk_wasm.WasmPastaFpPlonkIndex.deserialize(bytes)
31+
console.log("index", index)
32+
var vk = plonk_wasm.caml_pasta_fp_plonk_verifier_index_create(index);
33+
console.log("vk", vk)
2934
return tsRustConversion.fp.verifierIndexFromRust(vk);
3035
};
3136

src/lib/crypto/kimchi_bindings/js/dune

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
native/native-overrides/prover-index.js
2222
native/native-overrides/srs.js
2323
native/native-overrides/util.js
24-
native/native-overrides/proof.js))
24+
native/native-overrides/proof.js
25+
native/native-overrides/verifier-index.js))
2526
(instrumentation
2627
(backend bisect_ppx))
2728
(preprocess

src/lib/crypto/kimchi_bindings/js/native/header-d.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@
44
// This file gets auto-included in the generated plonk-napi types to supplement
55
// external pointer types.
66

7+
type WasmGVesta = {};
8+
type WasmGPallas = {};
9+
type WasmPastaFp = {};
10+
type WasmPastaFq = {};
11+
type WasmLookupInfo = {};
712
type WasmPastaFpPlonkIndex = {};
8-
type NapiVector<T> = {};
9-
type NapiGVesta = {};
10-
type NapiGPallas = {};
11-
type NapiPastaFpPlonkIndex = {};
12-
type NapiPastaFqPlonkIndex = {};
13-
type NapiLookupInfo = {};
14-
type NapiPastaFp = {};
15-
type NapiPastaFq = {};
13+
type WasmPastaFqPlonkIndex = {};
14+
type Proof = {}
15+
type WasmVector<T> = {};
16+
type WasmFlatVector<T> = {};
17+
type WasmVecVecFp = {};
18+
type WasmVecVecFq = {};
19+
type WasmFpSrs = {};
20+
type WasmFqSrs = {};
21+
type Self = {};
1622

1723
// Header section end

src/lib/crypto/kimchi_bindings/js/native/native-overrides/proof.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ var caml_pasta_fp_plonk_proof_create = function (
2020
var wasm_runtime_tables =
2121
tsRustConversionNative.fp.runtimeTablesToRust(caml_runtime_tables);
2222
prev_sgs = tsRustConversionNative.fp.pointsToRust(prev_sgs);
23+
/*w.push(tsRustConversion.fp.vectorToRust(witness_cols[i]));
24+
}
25+
witness_cols = w;
26+
prev_challenges = tsRustConversion.fp.vectorToRust(prev_challenges);
27+
var wasm_runtime_tables =
28+
tsRustConversion.fp.runtimeTablesToRust(caml_runtime_tables);
29+
prev_sgs = tsRustConversion.fp.pointsToRust(prev_sgs);
30+
*/
2331
var proof = plonk_wasm.caml_pasta_fp_plonk_proof_create(
2432
index,
2533
witness_cols,
@@ -28,6 +36,7 @@ var caml_pasta_fp_plonk_proof_create = function (
2836
prev_sgs
2937
);
3038
return tsRustConversionNative.fp.proofFromRust(proof);
39+
/* return tsRustConversion.fp.proofFromRust(proof); */
3140
};
3241

3342
// Provides: caml_pasta_fp_plonk_proof_verify
@@ -38,7 +47,37 @@ var caml_pasta_fp_plonk_proof_verify = function (index, proof) {
3847
return plonk_wasm.caml_pasta_fp_plonk_proof_verify(index, proof);
3948
};
4049

50+
// Provides: caml_pasta_fp_plonk_proof_batch_verify
51+
// Requires: plonk_wasm, tsRustConversionNative
52+
var caml_pasta_fp_plonk_proof_batch_verify = function (indexes, proofs) {
53+
indexes = tsRustConversionNative.mapMlArrayToRustVector(
54+
indexes,
55+
tsRustConversionNative.fp.verifierIndexToRust
56+
);
57+
proofs = tsRustConversionNative.mapMlArrayToRustVector(
58+
proofs,
59+
tsRustConversionNative.fp.proofToRust
60+
);
61+
return plonk_wasm.caml_pasta_fp_plonk_proof_batch_verify(indexes, proofs);
62+
};
63+
64+
// Provides: caml_pasta_fp_plonk_proof_dummy
65+
// Requires: plonk_wasm, tsRustConversionNative
66+
var caml_pasta_fp_plonk_proof_dummy = function () {
67+
return tsRustConversionNative.fp.proofFromRust(
68+
plonk_wasm.caml_pasta_fp_plonk_proof_dummy()
69+
);
70+
};
4171

72+
// Provides: caml_pasta_fp_plonk_proof_deep_copy
73+
// Requires: plonk_wasm, tsRustConversionNative
74+
var caml_pasta_fp_plonk_proof_deep_copy = function (proof) {
75+
return tsRustConversionNative.fp.proofFromRust(
76+
plonk_wasm.caml_pasta_fp_plonk_proof_deep_copy(
77+
tsRustConversionNative.fp.proofToRust(proof)
78+
)
79+
);
80+
};
4281

4382
// Provides: caml_pasta_fq_plonk_proof_create
4483
// Requires: plonk_wasm, tsRustConversionNative
@@ -75,3 +114,36 @@ var caml_pasta_fq_plonk_proof_verify = function (index, proof) {
75114
proof = tsRustConversionNative.fq.proofToRust(proof);
76115
return plonk_wasm.caml_pasta_fq_plonk_proof_verify(index, proof);
77116
};
117+
118+
// Provides: caml_pasta_fq_plonk_proof_batch_verify
119+
// Requires: plonk_wasm, tsRustConversionNative
120+
var caml_pasta_fq_plonk_proof_batch_verify = function (indexes, proofs) {
121+
indexes = tsRustConversionNative.mapMlArrayToRustVector(
122+
indexes,
123+
tsRustConversionNatsRustConversionNativetive.fq.verifierIndexToRust
124+
);
125+
proofs = tsRustConversionNative.mapMlArrayToRustVector(
126+
proofs,
127+
tsRustConversionNative.fq.proofToRust
128+
);
129+
return plonk_wasm.caml_pasta_fq_plonk_proof_batch_verify(indexes, proofs);
130+
};
131+
132+
// Provides: caml_pasta_fq_plonk_proof_dummy
133+
// Requires: plonk_wasm, tsRustConversionNative
134+
var caml_pasta_fq_plonk_proof_dummy = function () {
135+
return tsRustConversionNative.fq.proofFromRust(
136+
plonk_wasm.caml_pasta_fq_plonk_proof_dummy()
137+
);
138+
};
139+
140+
// Provides: caml_pasta_fq_plonk_proof_deep_copy
141+
// Requires: plonk_wasm, tsRustConversionNative
142+
var caml_pasta_fq_plonk_proof_deep_copy = function (proof) {
143+
return tsRustConversionNative.fq.proofFromRust(
144+
plonk_wasm.caml_pasta_fq_plonk_proof_deep_copy(
145+
tsRustConversionNative.fq.proofToRust(proof)
146+
)
147+
);
148+
};
149+

src/lib/crypto/kimchi_bindings/js/native/native-overrides/prover-index.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function caml_pasta_fq_plonk_index_domain_d8_size(prover_index) {
106106

107107

108108
// Provides: caml_pasta_fp_plonk_index_create
109-
// Requires: plonk_wasm, free_on_finalize, tsRustConversionNative
109+
// Requires: plonk_wasm, tsRustConversionNative
110110
var caml_pasta_fp_plonk_index_create = function (
111111
gates,
112112
public_inputs,
@@ -121,10 +121,10 @@ var caml_pasta_fp_plonk_index_create = function (
121121
var wasm_runtime_table_cfgs = tsRustConversionNative.fp.runtimeTableCfgsToRust(
122122
caml_runtime_table_cfgs
123123
);
124-
console.time("conversion")
124+
console.time("conversion plonk index create")
125125
var gate_vec = plonk_wasm.caml_pasta_fp_plonk_gate_vector_from_bytes(gates.serialize());
126126
var urs_ser = plonk_wasm.caml_fp_srs_from_bytes_external(urs.serialize())
127-
console.timeEnd("conversion")
127+
console.timeEnd("conversion plonk index create")
128128

129129
console.time("index_create")
130130
var t = plonk_wasm.caml_pasta_fp_plonk_index_create(
@@ -138,11 +138,7 @@ var caml_pasta_fp_plonk_index_create = function (
138138
);
139139
console.timeEnd("index_create");
140140

141-
console.time("finalize_conversion")
142-
var wasm_t = plonk_wasm.WasmPastaFpPlonkIndex.deserialize(plonk_wasm.prover_index_fp_to_bytes(t))
143-
console.timeEnd("finalize_conversion")
144-
145-
return free_on_finalize(wasm_t);
141+
return plonk_wasm.prover_index_fp_to_bytes(t);
146142
};
147143

148144
// Provides: caml_pasta_fp_plonk_index_create_bytecode
@@ -198,7 +194,7 @@ var caml_pasta_fp_plonk_index_write = function (append, t, path) {
198194
};
199195

200196
// Provides: caml_pasta_fq_plonk_index_create
201-
// Requires: plonk_wasm, free_on_finalize, tsRustConversionNative
197+
// Requires: plonk_wasm, tsRustConversionNative
202198
var caml_pasta_fq_plonk_index_create = function (
203199
gates,
204200
public_inputs,
@@ -208,16 +204,20 @@ var caml_pasta_fq_plonk_index_create = function (
208204
urs,
209205
lazy_mode
210206
) {
207+
console.log("anais: 1");
211208
var wasm_lookup_tables =
212209
tsRustConversionNative.fq.lookupTablesToRust(caml_lookup_tables);
210+
console.log("anais: 2");
213211
var wasm_runtime_table_cfgs = tsRustConversionNative.fq.runtimeTableCfgsToRust(
214212
caml_runtime_table_cfgs
215213
);
214+
console.log("anais: 3");
216215

217216
console.time("conversion")
218217
var gate_vec = plonk_wasm.caml_pasta_fq_plonk_gate_vector_from_bytes(gates.serialize());
219218
var urs_ser = plonk_wasm.caml_fq_srs_from_bytes_external(urs.serialize())
220219
console.timeEnd("conversion")
220+
console.log("anais: 4");
221221

222222
console.time("index_create")
223223
var t = plonk_wasm.caml_pasta_fq_plonk_index_create(
@@ -231,11 +231,7 @@ var caml_pasta_fq_plonk_index_create = function (
231231
);
232232
console.timeEnd("index_create");
233233

234-
console.time("finalize_conversion")
235-
var wasm_t = plonk_wasm.WasmPastaFqPlonkIndex.deserialize(plonk_wasm.prover_index_fq_to_bytes(t))
236-
console.timeEnd("finalize_conversion")
237-
238-
return free_on_finalize(wasm_t);
234+
return plonk_wasm.prover_index_fq_to_bytes(t);
239235
};
240236

241237
// Provides: caml_pasta_fq_plonk_index_create_bytecode

0 commit comments

Comments
 (0)