create-izi-noir 0.2.14 → 0.2.15
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.js +42 -38
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -393,39 +393,41 @@ function generateTsconfig() {
|
|
|
393
393
|
// src/generators/circuits.ts
|
|
394
394
|
function generateBalanceProof() {
|
|
395
395
|
return `/**
|
|
396
|
-
*
|
|
396
|
+
* Square Proof Circuit
|
|
397
397
|
*
|
|
398
|
-
* Proves
|
|
399
|
-
*
|
|
398
|
+
* Proves knowledge of a secret number whose square equals a public value.
|
|
399
|
+
* This is a fundamental ZK proof pattern that demonstrates the SDK capabilities.
|
|
400
400
|
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
401
|
+
* Example: To prove you know the secret 7, set expected = 49 (7\xB2)
|
|
402
|
+
*
|
|
403
|
+
* @param expected - The expected result (secret\xB2) (public)
|
|
404
|
+
* @param secret - The secret number to prove (private, not revealed)
|
|
403
405
|
*/
|
|
404
406
|
export function balanceProof(
|
|
405
|
-
[
|
|
406
|
-
[
|
|
407
|
+
[expected]: [number],
|
|
408
|
+
[secret]: [number]
|
|
407
409
|
): void {
|
|
408
|
-
assert(
|
|
410
|
+
assert(secret * secret == expected);
|
|
409
411
|
}
|
|
410
412
|
`;
|
|
411
413
|
}
|
|
412
414
|
function generateAgeProof() {
|
|
413
415
|
return `/**
|
|
414
|
-
*
|
|
416
|
+
* Another Square Proof Circuit
|
|
415
417
|
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
+
* Another example proving knowledge of a secret whose square equals a public value.
|
|
419
|
+
* This demonstrates the same ZK pattern with different default values.
|
|
418
420
|
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
* @param
|
|
421
|
+
* Example: To prove you know the secret 4, set expected = 16 (4\xB2)
|
|
422
|
+
*
|
|
423
|
+
* @param expected - The expected result (secret\xB2) (public)
|
|
424
|
+
* @param secret - The secret square root to prove (private, not revealed)
|
|
422
425
|
*/
|
|
423
426
|
export function ageProof(
|
|
424
|
-
[
|
|
425
|
-
[
|
|
427
|
+
[expected]: [number],
|
|
428
|
+
[secret]: [number]
|
|
426
429
|
): void {
|
|
427
|
-
|
|
428
|
-
assert(age >= minAge);
|
|
430
|
+
assert(secret * secret == expected);
|
|
429
431
|
}
|
|
430
432
|
`;
|
|
431
433
|
}
|
|
@@ -433,18 +435,20 @@ function generateMinimalCircuit() {
|
|
|
433
435
|
return `/**
|
|
434
436
|
* My Custom Circuit
|
|
435
437
|
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
+
* A minimal ZK proof that proves knowledge of a secret whose square
|
|
439
|
+
* equals the public expected value.
|
|
438
440
|
*
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
+
* Replace with your own circuit logic using assert() statements.
|
|
442
|
+
*
|
|
443
|
+
* @param expected - The expected result (secret\xB2) (public)
|
|
444
|
+
* @param secret - The secret value to prove (private, not revealed)
|
|
441
445
|
*/
|
|
442
446
|
export function myCircuit(
|
|
443
|
-
[
|
|
444
|
-
[
|
|
447
|
+
[expected]: [number],
|
|
448
|
+
[secret]: [number]
|
|
445
449
|
): void {
|
|
446
|
-
//
|
|
447
|
-
assert(
|
|
450
|
+
// Prove that secret\xB2 = expected
|
|
451
|
+
assert(secret * secret == expected);
|
|
448
452
|
}
|
|
449
453
|
`;
|
|
450
454
|
}
|
|
@@ -1177,9 +1181,9 @@ function getCircuitOptions(template) {
|
|
|
1177
1181
|
{
|
|
1178
1182
|
name: 'myCircuit',
|
|
1179
1183
|
fn: myCircuit,
|
|
1180
|
-
publicInputKeys: ['
|
|
1181
|
-
privateInputKeys: ['
|
|
1182
|
-
defaultInputs: {
|
|
1184
|
+
publicInputKeys: ['expected'],
|
|
1185
|
+
privateInputKeys: ['secret'],
|
|
1186
|
+
defaultInputs: { expected: '49', secret: '7' },
|
|
1183
1187
|
},
|
|
1184
1188
|
]`;
|
|
1185
1189
|
case "balance-proof":
|
|
@@ -1187,9 +1191,9 @@ function getCircuitOptions(template) {
|
|
|
1187
1191
|
{
|
|
1188
1192
|
name: 'balanceProof',
|
|
1189
1193
|
fn: balanceProof,
|
|
1190
|
-
publicInputKeys: ['
|
|
1191
|
-
privateInputKeys: ['
|
|
1192
|
-
defaultInputs: {
|
|
1194
|
+
publicInputKeys: ['expected'],
|
|
1195
|
+
privateInputKeys: ['secret'],
|
|
1196
|
+
defaultInputs: { expected: '49', secret: '7' },
|
|
1193
1197
|
},
|
|
1194
1198
|
]`;
|
|
1195
1199
|
default:
|
|
@@ -1197,16 +1201,16 @@ function getCircuitOptions(template) {
|
|
|
1197
1201
|
{
|
|
1198
1202
|
name: 'balanceProof',
|
|
1199
1203
|
fn: balanceProof,
|
|
1200
|
-
publicInputKeys: ['
|
|
1201
|
-
privateInputKeys: ['
|
|
1202
|
-
defaultInputs: {
|
|
1204
|
+
publicInputKeys: ['expected'],
|
|
1205
|
+
privateInputKeys: ['secret'],
|
|
1206
|
+
defaultInputs: { expected: '49', secret: '7' },
|
|
1203
1207
|
},
|
|
1204
1208
|
{
|
|
1205
1209
|
name: 'ageProof',
|
|
1206
1210
|
fn: ageProof,
|
|
1207
|
-
publicInputKeys: ['
|
|
1208
|
-
privateInputKeys: ['
|
|
1209
|
-
defaultInputs: {
|
|
1211
|
+
publicInputKeys: ['expected'],
|
|
1212
|
+
privateInputKeys: ['secret'],
|
|
1213
|
+
defaultInputs: { expected: '16', secret: '4' },
|
|
1210
1214
|
},
|
|
1211
1215
|
]`;
|
|
1212
1216
|
}
|