|
1 | 1 | import { fieldsFromRustFlat, fieldsToRustFlat } from './bindings/conversion-base.js'; |
| 2 | +import { Gate, Wire } from './bindings/kimchi-types.js'; |
| 3 | +import { mapTuple } from './bindings/util.js'; |
2 | 4 |
|
3 | 5 | export { bindingsNapi }; |
4 | 6 |
|
5 | 7 | function bindingsNapi(napi: any) { |
6 | 8 | return { |
7 | 9 | fp: { |
8 | 10 | vectorToRust: (fields: any) => { |
9 | | - console.log('values going in ', fields); |
| 11 | + //console.log('values going in ', fields); |
10 | 12 | let res = fieldsToRustFlat(fields); |
11 | | - console.log('values going out ', res); |
| 13 | + //console.log('values going out ', res); |
12 | 14 | return res; |
13 | 15 | }, |
14 | 16 | vectorFromRust: fieldsFromRustFlat, |
| 17 | + wireToRust([, row, col]: Wire) { |
| 18 | + return { row, col }; |
| 19 | + }, |
| 20 | + gateToRust(gate: Gate): any { |
| 21 | + const [, typ, [, ...wires], coeffs] = gate; |
| 22 | + const mapped = mapTuple(wires, (wire) => this.wireToRust(wire)); |
| 23 | + const nativeWires = { |
| 24 | + w0: mapped[0], |
| 25 | + w1: mapped[1], |
| 26 | + w2: mapped[2], |
| 27 | + w3: mapped[3], |
| 28 | + w4: mapped[4], |
| 29 | + w5: mapped[5], |
| 30 | + w6: mapped[6], |
| 31 | + } as const; |
| 32 | + return { |
| 33 | + typ, |
| 34 | + wires: nativeWires, |
| 35 | + coeffs: Array.from(fieldsToRustFlat(coeffs)), |
| 36 | + }; |
| 37 | + }, |
15 | 38 | }, |
16 | 39 | fq: { |
17 | 40 | vectorToRust: (fields: any) => { |
18 | | - console.log('values going in ', fields); |
| 41 | + //console.log('values going in ', fields); |
19 | 42 | let res = fieldsToRustFlat(fields); |
20 | | - console.log('values going out ', res); |
| 43 | + //console.log('values going out ', res); |
21 | 44 | return res; |
22 | 45 | }, |
23 | 46 | vectorFromRust: (fieldBytes: any) => { |
24 | | - console.log('values going in ', fieldBytes); |
| 47 | + //console.log('values going in ', fieldBytes); |
25 | 48 | let res = fieldsFromRustFlat(fieldBytes); |
26 | | - console.log('values going out ', res); |
| 49 | + //console.log('values going out ', res); |
27 | 50 | return res; |
28 | 51 | }, |
| 52 | + wireToRust([, row, col]: Wire) { |
| 53 | + return { row, col }; |
| 54 | + }, |
| 55 | + gateToRust(gate: Gate): any { |
| 56 | + const [, typ, [, ...wires], coeffs] = gate; |
| 57 | + const mapped = mapTuple(wires, (wire) => this.wireToRust(wire)); |
| 58 | + const nativeWires = { |
| 59 | + w0: mapped[0], |
| 60 | + w1: mapped[1], |
| 61 | + w2: mapped[2], |
| 62 | + w3: mapped[3], |
| 63 | + w4: mapped[4], |
| 64 | + w5: mapped[5], |
| 65 | + w6: mapped[6], |
| 66 | + } as const; |
| 67 | + return { |
| 68 | + typ, |
| 69 | + wires: nativeWires, |
| 70 | + coeffs: Array.from(fieldsToRustFlat(coeffs)), |
| 71 | + }; |
| 72 | + }, |
29 | 73 | }, |
30 | 74 | }; |
31 | 75 | } |
0 commit comments