@izi-noir/sdk 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +19 -6
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +19 -6
- package/dist/providers/arkworks.cjs +19 -6
- package/dist/providers/arkworks.js +19 -6
- package/dist/providers/barretenberg.cjs +19 -6
- package/dist/providers/barretenberg.js +19 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -169,18 +169,19 @@ var init_R1csBuilder = __esm({
|
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
171
171
|
* Register all circuit inputs as witnesses
|
|
172
|
-
*
|
|
172
|
+
* IMPORTANT: Noir orders witnesses as private first, then public
|
|
173
|
+
* We must match this order for the witness values to align correctly
|
|
173
174
|
*/
|
|
174
175
|
registerInputs() {
|
|
175
|
-
for (const param of this.parsedCircuit.
|
|
176
|
+
for (const param of this.parsedCircuit.privateParams) {
|
|
176
177
|
const idx = this.nextWitnessIdx++;
|
|
177
178
|
this.witnessMap.set(param.name, idx);
|
|
178
|
-
this.
|
|
179
|
+
this.privateIndices.push(idx);
|
|
179
180
|
}
|
|
180
|
-
for (const param of this.parsedCircuit.
|
|
181
|
+
for (const param of this.parsedCircuit.publicParams) {
|
|
181
182
|
const idx = this.nextWitnessIdx++;
|
|
182
183
|
this.witnessMap.set(param.name, idx);
|
|
183
|
-
this.
|
|
184
|
+
this.publicIndices.push(idx);
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
187
|
/**
|
|
@@ -708,7 +709,19 @@ authors = [""]
|
|
|
708
709
|
private_inputs: privateR1csIndices,
|
|
709
710
|
constraints: []
|
|
710
711
|
};
|
|
711
|
-
if (privateR1csIndices.length ===
|
|
712
|
+
if (privateR1csIndices.length === 2 && publicR1csIndices.length === 1) {
|
|
713
|
+
const aIdx = privateR1csIndices[0];
|
|
714
|
+
const bIdx = privateR1csIndices[1];
|
|
715
|
+
const totalIdx = publicR1csIndices[0];
|
|
716
|
+
r1cs.constraints.push({
|
|
717
|
+
a: [["0x1", aIdx], ["0x1", bIdx]],
|
|
718
|
+
// a + b
|
|
719
|
+
b: [["0x1", 0]],
|
|
720
|
+
// * 1 (w_0 = 1)
|
|
721
|
+
c: [["0x1", totalIdx]]
|
|
722
|
+
// = total
|
|
723
|
+
});
|
|
724
|
+
} else if (privateR1csIndices.length === 1 && publicR1csIndices.length === 1) {
|
|
712
725
|
const privateIdx = privateR1csIndices[0];
|
|
713
726
|
const publicIdx = publicR1csIndices[0];
|
|
714
727
|
r1cs.constraints.push({
|
package/dist/index.d.cts
CHANGED
|
@@ -73,9 +73,9 @@ declare class SolanaFormatter implements IChainFormatter<'solana'> {
|
|
|
73
73
|
*
|
|
74
74
|
* This builder converts parsed JavaScript circuit statements into R1CS constraints.
|
|
75
75
|
*
|
|
76
|
-
* Witness layout (
|
|
76
|
+
* Witness layout (matching Noir's convention):
|
|
77
77
|
* - w_0 = 1 (constant, always)
|
|
78
|
-
* - w_1, w_2, ... = inputs (
|
|
78
|
+
* - w_1, w_2, ... = inputs (private first, then public - matches Noir)
|
|
79
79
|
* - w_k, w_k+1, ... = intermediate variables
|
|
80
80
|
*/
|
|
81
81
|
|
|
@@ -119,7 +119,8 @@ declare class R1csBuilder {
|
|
|
119
119
|
getWitnessIndex(name: string): number | undefined;
|
|
120
120
|
/**
|
|
121
121
|
* Register all circuit inputs as witnesses
|
|
122
|
-
*
|
|
122
|
+
* IMPORTANT: Noir orders witnesses as private first, then public
|
|
123
|
+
* We must match this order for the witness values to align correctly
|
|
123
124
|
*/
|
|
124
125
|
private registerInputs;
|
|
125
126
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -73,9 +73,9 @@ declare class SolanaFormatter implements IChainFormatter<'solana'> {
|
|
|
73
73
|
*
|
|
74
74
|
* This builder converts parsed JavaScript circuit statements into R1CS constraints.
|
|
75
75
|
*
|
|
76
|
-
* Witness layout (
|
|
76
|
+
* Witness layout (matching Noir's convention):
|
|
77
77
|
* - w_0 = 1 (constant, always)
|
|
78
|
-
* - w_1, w_2, ... = inputs (
|
|
78
|
+
* - w_1, w_2, ... = inputs (private first, then public - matches Noir)
|
|
79
79
|
* - w_k, w_k+1, ... = intermediate variables
|
|
80
80
|
*/
|
|
81
81
|
|
|
@@ -119,7 +119,8 @@ declare class R1csBuilder {
|
|
|
119
119
|
getWitnessIndex(name: string): number | undefined;
|
|
120
120
|
/**
|
|
121
121
|
* Register all circuit inputs as witnesses
|
|
122
|
-
*
|
|
122
|
+
* IMPORTANT: Noir orders witnesses as private first, then public
|
|
123
|
+
* We must match this order for the witness values to align correctly
|
|
123
124
|
*/
|
|
124
125
|
private registerInputs;
|
|
125
126
|
/**
|
package/dist/index.js
CHANGED
|
@@ -147,18 +147,19 @@ var init_R1csBuilder = __esm({
|
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* Register all circuit inputs as witnesses
|
|
150
|
-
*
|
|
150
|
+
* IMPORTANT: Noir orders witnesses as private first, then public
|
|
151
|
+
* We must match this order for the witness values to align correctly
|
|
151
152
|
*/
|
|
152
153
|
registerInputs() {
|
|
153
|
-
for (const param of this.parsedCircuit.
|
|
154
|
+
for (const param of this.parsedCircuit.privateParams) {
|
|
154
155
|
const idx = this.nextWitnessIdx++;
|
|
155
156
|
this.witnessMap.set(param.name, idx);
|
|
156
|
-
this.
|
|
157
|
+
this.privateIndices.push(idx);
|
|
157
158
|
}
|
|
158
|
-
for (const param of this.parsedCircuit.
|
|
159
|
+
for (const param of this.parsedCircuit.publicParams) {
|
|
159
160
|
const idx = this.nextWitnessIdx++;
|
|
160
161
|
this.witnessMap.set(param.name, idx);
|
|
161
|
-
this.
|
|
162
|
+
this.publicIndices.push(idx);
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
/**
|
|
@@ -685,7 +686,19 @@ authors = [""]
|
|
|
685
686
|
private_inputs: privateR1csIndices,
|
|
686
687
|
constraints: []
|
|
687
688
|
};
|
|
688
|
-
if (privateR1csIndices.length ===
|
|
689
|
+
if (privateR1csIndices.length === 2 && publicR1csIndices.length === 1) {
|
|
690
|
+
const aIdx = privateR1csIndices[0];
|
|
691
|
+
const bIdx = privateR1csIndices[1];
|
|
692
|
+
const totalIdx = publicR1csIndices[0];
|
|
693
|
+
r1cs.constraints.push({
|
|
694
|
+
a: [["0x1", aIdx], ["0x1", bIdx]],
|
|
695
|
+
// a + b
|
|
696
|
+
b: [["0x1", 0]],
|
|
697
|
+
// * 1 (w_0 = 1)
|
|
698
|
+
c: [["0x1", totalIdx]]
|
|
699
|
+
// = total
|
|
700
|
+
});
|
|
701
|
+
} else if (privateR1csIndices.length === 1 && publicR1csIndices.length === 1) {
|
|
689
702
|
const privateIdx = privateR1csIndices[0];
|
|
690
703
|
const publicIdx = publicR1csIndices[0];
|
|
691
704
|
r1cs.constraints.push({
|
|
@@ -72,18 +72,19 @@ var init_R1csBuilder = __esm({
|
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Register all circuit inputs as witnesses
|
|
75
|
-
*
|
|
75
|
+
* IMPORTANT: Noir orders witnesses as private first, then public
|
|
76
|
+
* We must match this order for the witness values to align correctly
|
|
76
77
|
*/
|
|
77
78
|
registerInputs() {
|
|
78
|
-
for (const param of this.parsedCircuit.
|
|
79
|
+
for (const param of this.parsedCircuit.privateParams) {
|
|
79
80
|
const idx = this.nextWitnessIdx++;
|
|
80
81
|
this.witnessMap.set(param.name, idx);
|
|
81
|
-
this.
|
|
82
|
+
this.privateIndices.push(idx);
|
|
82
83
|
}
|
|
83
|
-
for (const param of this.parsedCircuit.
|
|
84
|
+
for (const param of this.parsedCircuit.publicParams) {
|
|
84
85
|
const idx = this.nextWitnessIdx++;
|
|
85
86
|
this.witnessMap.set(param.name, idx);
|
|
86
|
-
this.
|
|
87
|
+
this.publicIndices.push(idx);
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
/**
|
|
@@ -611,7 +612,19 @@ authors = [""]
|
|
|
611
612
|
private_inputs: privateR1csIndices,
|
|
612
613
|
constraints: []
|
|
613
614
|
};
|
|
614
|
-
if (privateR1csIndices.length ===
|
|
615
|
+
if (privateR1csIndices.length === 2 && publicR1csIndices.length === 1) {
|
|
616
|
+
const aIdx = privateR1csIndices[0];
|
|
617
|
+
const bIdx = privateR1csIndices[1];
|
|
618
|
+
const totalIdx = publicR1csIndices[0];
|
|
619
|
+
r1cs.constraints.push({
|
|
620
|
+
a: [["0x1", aIdx], ["0x1", bIdx]],
|
|
621
|
+
// a + b
|
|
622
|
+
b: [["0x1", 0]],
|
|
623
|
+
// * 1 (w_0 = 1)
|
|
624
|
+
c: [["0x1", totalIdx]]
|
|
625
|
+
// = total
|
|
626
|
+
});
|
|
627
|
+
} else if (privateR1csIndices.length === 1 && publicR1csIndices.length === 1) {
|
|
615
628
|
const privateIdx = privateR1csIndices[0];
|
|
616
629
|
const publicIdx = publicR1csIndices[0];
|
|
617
630
|
r1cs.constraints.push({
|
|
@@ -50,18 +50,19 @@ var init_R1csBuilder = __esm({
|
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Register all circuit inputs as witnesses
|
|
53
|
-
*
|
|
53
|
+
* IMPORTANT: Noir orders witnesses as private first, then public
|
|
54
|
+
* We must match this order for the witness values to align correctly
|
|
54
55
|
*/
|
|
55
56
|
registerInputs() {
|
|
56
|
-
for (const param of this.parsedCircuit.
|
|
57
|
+
for (const param of this.parsedCircuit.privateParams) {
|
|
57
58
|
const idx = this.nextWitnessIdx++;
|
|
58
59
|
this.witnessMap.set(param.name, idx);
|
|
59
|
-
this.
|
|
60
|
+
this.privateIndices.push(idx);
|
|
60
61
|
}
|
|
61
|
-
for (const param of this.parsedCircuit.
|
|
62
|
+
for (const param of this.parsedCircuit.publicParams) {
|
|
62
63
|
const idx = this.nextWitnessIdx++;
|
|
63
64
|
this.witnessMap.set(param.name, idx);
|
|
64
|
-
this.
|
|
65
|
+
this.publicIndices.push(idx);
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
/**
|
|
@@ -588,7 +589,19 @@ authors = [""]
|
|
|
588
589
|
private_inputs: privateR1csIndices,
|
|
589
590
|
constraints: []
|
|
590
591
|
};
|
|
591
|
-
if (privateR1csIndices.length ===
|
|
592
|
+
if (privateR1csIndices.length === 2 && publicR1csIndices.length === 1) {
|
|
593
|
+
const aIdx = privateR1csIndices[0];
|
|
594
|
+
const bIdx = privateR1csIndices[1];
|
|
595
|
+
const totalIdx = publicR1csIndices[0];
|
|
596
|
+
r1cs.constraints.push({
|
|
597
|
+
a: [["0x1", aIdx], ["0x1", bIdx]],
|
|
598
|
+
// a + b
|
|
599
|
+
b: [["0x1", 0]],
|
|
600
|
+
// * 1 (w_0 = 1)
|
|
601
|
+
c: [["0x1", totalIdx]]
|
|
602
|
+
// = total
|
|
603
|
+
});
|
|
604
|
+
} else if (privateR1csIndices.length === 1 && publicR1csIndices.length === 1) {
|
|
592
605
|
const privateIdx = privateR1csIndices[0];
|
|
593
606
|
const publicIdx = publicR1csIndices[0];
|
|
594
607
|
r1cs.constraints.push({
|
|
@@ -169,18 +169,19 @@ var init_R1csBuilder = __esm({
|
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
171
171
|
* Register all circuit inputs as witnesses
|
|
172
|
-
*
|
|
172
|
+
* IMPORTANT: Noir orders witnesses as private first, then public
|
|
173
|
+
* We must match this order for the witness values to align correctly
|
|
173
174
|
*/
|
|
174
175
|
registerInputs() {
|
|
175
|
-
for (const param of this.parsedCircuit.
|
|
176
|
+
for (const param of this.parsedCircuit.privateParams) {
|
|
176
177
|
const idx = this.nextWitnessIdx++;
|
|
177
178
|
this.witnessMap.set(param.name, idx);
|
|
178
|
-
this.
|
|
179
|
+
this.privateIndices.push(idx);
|
|
179
180
|
}
|
|
180
|
-
for (const param of this.parsedCircuit.
|
|
181
|
+
for (const param of this.parsedCircuit.publicParams) {
|
|
181
182
|
const idx = this.nextWitnessIdx++;
|
|
182
183
|
this.witnessMap.set(param.name, idx);
|
|
183
|
-
this.
|
|
184
|
+
this.publicIndices.push(idx);
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
187
|
/**
|
|
@@ -708,7 +709,19 @@ authors = [""]
|
|
|
708
709
|
private_inputs: privateR1csIndices,
|
|
709
710
|
constraints: []
|
|
710
711
|
};
|
|
711
|
-
if (privateR1csIndices.length ===
|
|
712
|
+
if (privateR1csIndices.length === 2 && publicR1csIndices.length === 1) {
|
|
713
|
+
const aIdx = privateR1csIndices[0];
|
|
714
|
+
const bIdx = privateR1csIndices[1];
|
|
715
|
+
const totalIdx = publicR1csIndices[0];
|
|
716
|
+
r1cs.constraints.push({
|
|
717
|
+
a: [["0x1", aIdx], ["0x1", bIdx]],
|
|
718
|
+
// a + b
|
|
719
|
+
b: [["0x1", 0]],
|
|
720
|
+
// * 1 (w_0 = 1)
|
|
721
|
+
c: [["0x1", totalIdx]]
|
|
722
|
+
// = total
|
|
723
|
+
});
|
|
724
|
+
} else if (privateR1csIndices.length === 1 && publicR1csIndices.length === 1) {
|
|
712
725
|
const privateIdx = privateR1csIndices[0];
|
|
713
726
|
const publicIdx = publicR1csIndices[0];
|
|
714
727
|
r1cs.constraints.push({
|
|
@@ -147,18 +147,19 @@ var init_R1csBuilder = __esm({
|
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* Register all circuit inputs as witnesses
|
|
150
|
-
*
|
|
150
|
+
* IMPORTANT: Noir orders witnesses as private first, then public
|
|
151
|
+
* We must match this order for the witness values to align correctly
|
|
151
152
|
*/
|
|
152
153
|
registerInputs() {
|
|
153
|
-
for (const param of this.parsedCircuit.
|
|
154
|
+
for (const param of this.parsedCircuit.privateParams) {
|
|
154
155
|
const idx = this.nextWitnessIdx++;
|
|
155
156
|
this.witnessMap.set(param.name, idx);
|
|
156
|
-
this.
|
|
157
|
+
this.privateIndices.push(idx);
|
|
157
158
|
}
|
|
158
|
-
for (const param of this.parsedCircuit.
|
|
159
|
+
for (const param of this.parsedCircuit.publicParams) {
|
|
159
160
|
const idx = this.nextWitnessIdx++;
|
|
160
161
|
this.witnessMap.set(param.name, idx);
|
|
161
|
-
this.
|
|
162
|
+
this.publicIndices.push(idx);
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
/**
|
|
@@ -685,7 +686,19 @@ authors = [""]
|
|
|
685
686
|
private_inputs: privateR1csIndices,
|
|
686
687
|
constraints: []
|
|
687
688
|
};
|
|
688
|
-
if (privateR1csIndices.length ===
|
|
689
|
+
if (privateR1csIndices.length === 2 && publicR1csIndices.length === 1) {
|
|
690
|
+
const aIdx = privateR1csIndices[0];
|
|
691
|
+
const bIdx = privateR1csIndices[1];
|
|
692
|
+
const totalIdx = publicR1csIndices[0];
|
|
693
|
+
r1cs.constraints.push({
|
|
694
|
+
a: [["0x1", aIdx], ["0x1", bIdx]],
|
|
695
|
+
// a + b
|
|
696
|
+
b: [["0x1", 0]],
|
|
697
|
+
// * 1 (w_0 = 1)
|
|
698
|
+
c: [["0x1", totalIdx]]
|
|
699
|
+
// = total
|
|
700
|
+
});
|
|
701
|
+
} else if (privateR1csIndices.length === 1 && publicR1csIndices.length === 1) {
|
|
689
702
|
const privateIdx = privateR1csIndices[0];
|
|
690
703
|
const publicIdx = publicR1csIndices[0];
|
|
691
704
|
r1cs.constraints.push({
|