Skip to content

Commit 4311de7

Browse files
authored
Merge pull request #18109 from MinaProtocol/querolita/napi-proof
[WIP] (`mina`) Native Prover with Napi - Proof
2 parents a7b1ba0 + 1c7ee27 commit 4311de7

File tree

12 files changed

+582
-396
lines changed

12 files changed

+582
-396
lines changed

src/lib/crypto/kimchi_bindings/js/bindings/oracles.js

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,5 @@
11
/* global plonk_wasm, tsRustConversion,*/
22

3-
// Provides: fp_oracles_create
4-
// Requires: plonk_wasm, tsRustConversion
5-
var fp_oracles_create = function (lgr_comm, verifier_index, proof) {
6-
return tsRustConversion.fp.oraclesFromRust(
7-
plonk_wasm.fp_oracles_create(
8-
tsRustConversion.fp.polyCommsToRust(lgr_comm),
9-
tsRustConversion.fp.verifierIndexToRust(verifier_index),
10-
tsRustConversion.fp.proofToRust(proof)
11-
)
12-
);
13-
};
14-
15-
// Provides: fp_oracles_create_no_public
16-
// Requires: fp_oracles_create
17-
var fp_oracles_create_no_public = function (lgr_comm, verifier_index, proof) {
18-
return fp_oracles_create(lgr_comm, verifier_index, [0, 0, proof]);
19-
};
20-
21-
// Provides: fp_oracles_dummy
22-
// Requires: plonk_wasm, tsRustConversion
23-
var fp_oracles_dummy = function () {
24-
return tsRustConversion.fp.oraclesFromRust(plonk_wasm.fp_oracles_dummy());
25-
};
26-
27-
// Provides: fp_oracles_deep_copy
28-
// Requires: plonk_wasm, tsRustConversion
29-
var fp_oracles_deep_copy = function (x) {
30-
return tsRustConversion.fp.oraclesFromRust(
31-
plonk_wasm.fp_oracles_deep_copy(tsRustConversion.fp.oraclesToRust(x))
32-
);
33-
};
34-
35-
// Provides: fq_oracles_create
36-
// Requires: plonk_wasm, tsRustConversion
37-
var fq_oracles_create = function (lgr_comm, verifier_index, proof) {
38-
return tsRustConversion.fq.oraclesFromRust(
39-
plonk_wasm.fq_oracles_create(
40-
tsRustConversion.fq.polyCommsToRust(lgr_comm),
41-
tsRustConversion.fq.verifierIndexToRust(verifier_index),
42-
tsRustConversion.fq.proofToRust(proof)
43-
)
44-
);
45-
};
46-
47-
// Provides: fq_oracles_create_no_public
48-
// Requires: fq_oracles_create
49-
var fq_oracles_create_no_public = function (lgr_comm, verifier_index, proof) {
50-
return fq_oracles_create(lgr_comm, verifier_index, [0, 0, proof]);
51-
};
52-
53-
// Provides: fq_oracles_dummy
54-
// Requires: plonk_wasm, tsRustConversion
55-
var fq_oracles_dummy = function () {
56-
return tsRustConversion.fq.oraclesFromRust(plonk_wasm.fq_oracles_dummy());
57-
};
58-
59-
// Provides: fq_oracles_deep_copy
60-
// Requires: plonk_wasm, tsRustConversion
61-
var fq_oracles_deep_copy = function (x) {
62-
return tsRustConversion.fq.oraclesFromRust(
63-
plonk_wasm.fq_oracles_deep_copy(tsRustConversion.fq.oraclesToRust(x))
64-
);
65-
};
66-
673
// This is fake -- parameters are only needed on the Rust side, so no need to return something meaningful
684
// Provides: caml_pasta_fp_poseidon_params_create
695
function caml_pasta_fp_poseidon_params_create() {
Lines changed: 0 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +0,0 @@
1-
/* global plonk_wasm, tsRustConversion
2-
*/
3-
4-
// Provides: caml_pasta_fp_plonk_proof_create
5-
// Requires: plonk_wasm, tsRustConversion
6-
var caml_pasta_fp_plonk_proof_create = function (
7-
index,
8-
witness_cols,
9-
caml_runtime_tables,
10-
prev_challenges,
11-
prev_sgs
12-
) {
13-
var w = new plonk_wasm.WasmVecVecFp(witness_cols.length - 1);
14-
for (var i = 1; i < witness_cols.length; i++) {
15-
w.push(tsRustConversion.fp.vectorToRust(witness_cols[i]));
16-
}
17-
witness_cols = w;
18-
prev_challenges = tsRustConversion.fp.vectorToRust(prev_challenges);
19-
var wasm_runtime_tables =
20-
tsRustConversion.fp.runtimeTablesToRust(caml_runtime_tables);
21-
prev_sgs = tsRustConversion.fp.pointsToRust(prev_sgs);
22-
var proof = plonk_wasm.caml_pasta_fp_plonk_proof_create(
23-
index,
24-
witness_cols,
25-
wasm_runtime_tables,
26-
prev_challenges,
27-
prev_sgs
28-
);
29-
return tsRustConversion.fp.proofFromRust(proof);
30-
};
31-
32-
// Provides: caml_pasta_fp_plonk_proof_verify
33-
// Requires: plonk_wasm, tsRustConversion
34-
var caml_pasta_fp_plonk_proof_verify = function (index, proof) {
35-
index = tsRustConversion.fp.verifierIndexToRust(index);
36-
proof = tsRustConversion.fp.proofToRust(proof);
37-
return plonk_wasm.caml_pasta_fp_plonk_proof_verify(index, proof);
38-
};
39-
40-
// Provides: caml_pasta_fp_plonk_proof_batch_verify
41-
// Requires: plonk_wasm, tsRustConversion
42-
var caml_pasta_fp_plonk_proof_batch_verify = function (indexes, proofs) {
43-
indexes = tsRustConversion.mapMlArrayToRustVector(
44-
indexes,
45-
tsRustConversion.fp.verifierIndexToRust
46-
);
47-
proofs = tsRustConversion.mapMlArrayToRustVector(
48-
proofs,
49-
tsRustConversion.fp.proofToRust
50-
);
51-
return plonk_wasm.caml_pasta_fp_plonk_proof_batch_verify(indexes, proofs);
52-
};
53-
54-
// Provides: caml_pasta_fp_plonk_proof_dummy
55-
// Requires: plonk_wasm, tsRustConversion
56-
var caml_pasta_fp_plonk_proof_dummy = function () {
57-
return tsRustConversion.fp.proofFromRust(
58-
plonk_wasm.caml_pasta_fp_plonk_proof_dummy()
59-
);
60-
};
61-
62-
// Provides: caml_pasta_fp_plonk_proof_deep_copy
63-
// Requires: plonk_wasm, tsRustConversion
64-
var caml_pasta_fp_plonk_proof_deep_copy = function (proof) {
65-
return tsRustConversion.fp.proofFromRust(
66-
plonk_wasm.caml_pasta_fp_plonk_proof_deep_copy(
67-
tsRustConversion.fp.proofToRust(proof)
68-
)
69-
);
70-
};
71-
72-
// Provides: caml_pasta_fq_plonk_proof_create
73-
// Requires: plonk_wasm, tsRustConversion
74-
var caml_pasta_fq_plonk_proof_create = function (
75-
index,
76-
witness_cols,
77-
caml_runtime_tables,
78-
prev_challenges,
79-
prev_sgs
80-
) {
81-
var w = new plonk_wasm.WasmVecVecFq(witness_cols.length - 1);
82-
for (var i = 1; i < witness_cols.length; i++) {
83-
w.push(tsRustConversion.fq.vectorToRust(witness_cols[i]));
84-
}
85-
witness_cols = w;
86-
prev_challenges = tsRustConversion.fq.vectorToRust(prev_challenges);
87-
var wasm_runtime_tables =
88-
tsRustConversion.fq.runtimeTablesToRust(caml_runtime_tables);
89-
prev_sgs = tsRustConversion.fq.pointsToRust(prev_sgs);
90-
var proof = plonk_wasm.caml_pasta_fq_plonk_proof_create(
91-
index,
92-
witness_cols,
93-
wasm_runtime_tables,
94-
prev_challenges,
95-
prev_sgs
96-
);
97-
return tsRustConversion.fq.proofFromRust(proof);
98-
};
99-
100-
// Provides: caml_pasta_fq_plonk_proof_verify
101-
// Requires: plonk_wasm, tsRustConversion
102-
var caml_pasta_fq_plonk_proof_verify = function (index, proof) {
103-
index = tsRustConversion.fq.verifierIndexToRust(index);
104-
proof = tsRustConversion.fq.proofToRust(proof);
105-
return plonk_wasm.caml_pasta_fq_plonk_proof_verify(index, proof);
106-
};
107-
108-
// Provides: caml_pasta_fq_plonk_proof_batch_verify
109-
// Requires: plonk_wasm, tsRustConversion
110-
var caml_pasta_fq_plonk_proof_batch_verify = function (indexes, proofs) {
111-
indexes = tsRustConversion.mapMlArrayToRustVector(
112-
indexes,
113-
tsRustConversion.fq.verifierIndexToRust
114-
);
115-
proofs = tsRustConversion.mapMlArrayToRustVector(
116-
proofs,
117-
tsRustConversion.fq.proofToRust
118-
);
119-
return plonk_wasm.caml_pasta_fq_plonk_proof_batch_verify(indexes, proofs);
120-
};
121-
122-
// Provides: caml_pasta_fq_plonk_proof_dummy
123-
// Requires: plonk_wasm, tsRustConversion
124-
var caml_pasta_fq_plonk_proof_dummy = function () {
125-
return tsRustConversion.fq.proofFromRust(
126-
plonk_wasm.caml_pasta_fq_plonk_proof_dummy()
127-
);
128-
};
129-
130-
// Provides: caml_pasta_fq_plonk_proof_deep_copy
131-
// Requires: plonk_wasm, tsRustConversion
132-
var caml_pasta_fq_plonk_proof_deep_copy = function (proof) {
133-
return tsRustConversion.fq.proofFromRust(
134-
plonk_wasm.caml_pasta_fq_plonk_proof_deep_copy(
135-
tsRustConversion.fq.proofToRust(proof)
136-
)
137-
);
138-
};
139-

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

Lines changed: 0 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -20,131 +20,3 @@ var caml_opt_to_rust = function (caml_optional_value, to_rust) {
2020
return to_rust(caml_optional_value[1]);
2121
}
2222
};
23-
24-
// Provides: caml_pasta_fp_plonk_verifier_index_create
25-
// Requires: plonk_wasm, tsRustConversion
26-
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);
29-
return tsRustConversion.fp.verifierIndexFromRust(vk);
30-
};
31-
32-
// Provides: caml_pasta_fp_plonk_verifier_index_read
33-
// Requires: plonk_wasm, caml_jsstring_of_string, tsRustConversion
34-
var caml_pasta_fp_plonk_verifier_index_read = function (offset, urs, path) {
35-
console.log("caml_pasta_fp_plonk_verifier_index_read")
36-
37-
if (offset === 0) {
38-
offset = undefined;
39-
} else {
40-
offset = offset[1];
41-
}
42-
return tsRustConversion.fp.verifierIndexFromRust(
43-
plonk_wasm.caml_pasta_fp_plonk_verifier_index_read(
44-
offset,
45-
urs,
46-
caml_jsstring_of_string(path)
47-
)
48-
);
49-
};
50-
51-
// Provides: caml_pasta_fp_plonk_verifier_index_write
52-
// Requires: plonk_wasm, caml_jsstring_of_string, tsRustConversion
53-
var caml_pasta_fp_plonk_verifier_index_write = function (append, t, path) {
54-
console.log("caml_pasta_fp_plonk_verifier_index_write")
55-
56-
if (append === 0) {
57-
append = undefined;
58-
} else {
59-
append = append[1];
60-
}
61-
return plonk_wasm.caml_pasta_fp_plonk_verifier_index_write(
62-
append,
63-
tsRustConversion.fp.verifierIndexToRust(t),
64-
caml_jsstring_of_string(path)
65-
);
66-
};
67-
68-
69-
// Provides: caml_pasta_fp_plonk_verifier_index_dummy
70-
// Requires: plonk_wasm, tsRustConversion
71-
var caml_pasta_fp_plonk_verifier_index_dummy = function () {
72-
console.log("caml_pasta_fp_plonk_verifier_index_dummy")
73-
74-
var res = plonk_wasm.caml_pasta_fp_plonk_verifier_index_dummy();
75-
return tsRustConversion.fp.verifierIndexFromRust(res);
76-
};
77-
78-
// Provides: caml_pasta_fp_plonk_verifier_index_deep_copy
79-
// Requires: plonk_wasm, tsRustConversion
80-
var caml_pasta_fp_plonk_verifier_index_deep_copy = function (x) {
81-
console.log("caml_pasta_fp_plonk_verifier_index_deep_copy")
82-
return tsRustConversion.fp.verifierIndexFromRust(
83-
plonk_wasm.caml_pasta_fp_plonk_verifier_index_deep_copy(
84-
tsRustConversion.fp.verifierIndexToRust(x)
85-
)
86-
);
87-
};
88-
89-
// Provides: caml_pasta_fq_plonk_verifier_index_create
90-
// Requires: plonk_wasm, tsRustConversion
91-
var caml_pasta_fq_plonk_verifier_index_create = function (x) {
92-
console.log("caml_pasta_fq_plonk_verifier_index_create")
93-
return tsRustConversion.fq.verifierIndexFromRust(
94-
plonk_wasm.caml_pasta_fq_plonk_verifier_index_create(x)
95-
);
96-
};
97-
98-
// Provides: caml_pasta_fq_plonk_verifier_index_read
99-
// Requires: plonk_wasm, caml_jsstring_of_string, tsRustConversion
100-
var caml_pasta_fq_plonk_verifier_index_read = function (offset, urs, path) {
101-
console.log("caml_pasta_fq_plonk_verifier_index_read")
102-
if (offset === 0) {
103-
offset = undefined;
104-
} else {
105-
offset = offset[1];
106-
}
107-
return tsRustConversion.fq.verifierIndexFromRust(
108-
plonk_wasm.caml_pasta_fq_plonk_verifier_index_read(
109-
offset,
110-
urs,
111-
caml_jsstring_of_string(path)
112-
)
113-
);
114-
};
115-
116-
// Provides: caml_pasta_fq_plonk_verifier_index_write
117-
// Requires: plonk_wasm, caml_jsstring_of_string, tsRustConversion
118-
var caml_pasta_fq_plonk_verifier_index_write = function (append, t, path) {
119-
console.log("caml_pasta_fq_plonk_verifier_index_write")
120-
if (append === 0) {
121-
append = undefined;
122-
} else {
123-
append = append[1];
124-
}
125-
return plonk_wasm.caml_pasta_fq_plonk_verifier_index_write(
126-
append,
127-
tsRustConversion.fq.verifierIndexToRust(t),
128-
caml_jsstring_of_string(path)
129-
);
130-
};
131-
132-
// Provides: caml_pasta_fq_plonk_verifier_index_dummy
133-
// Requires: plonk_wasm, tsRustConversion
134-
var caml_pasta_fq_plonk_verifier_index_dummy = function () {
135-
console.log("caml_pasta_fq_plonk_verifier_index_dummy")
136-
return tsRustConversion.fq.verifierIndexFromRust(
137-
plonk_wasm.caml_pasta_fq_plonk_verifier_index_dummy()
138-
);
139-
};
140-
141-
// Provides: caml_pasta_fq_plonk_verifier_index_deep_copy
142-
// Requires: plonk_wasm, tsRustConversion, tsRustConversion
143-
var caml_pasta_fq_plonk_verifier_index_deep_copy = function (x) {
144-
console.log("caml_pasta_fq_plonk_verifier_index_deep_copy")
145-
return tsRustConversion.fq.verifierIndexFromRust(
146-
plonk_wasm.caml_pasta_fq_plonk_verifier_index_deep_copy(
147-
tsRustConversion.fq.verifierIndexToRust(x)
148-
)
149-
);
150-
};

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

0 commit comments

Comments
 (0)