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.
Files changed (2) hide show
  1. package/dist/index.js +42 -38
  2. 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
- * Balance Proof Circuit
396
+ * Square Proof Circuit
397
397
  *
398
- * Proves that a private balance is greater than or equal to a public threshold
399
- * without revealing the actual balance.
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
- * @param threshold - The minimum required balance (public)
402
- * @param balance - The actual balance to prove (private, not revealed)
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
- [threshold]: [number],
406
- [balance]: [number]
407
+ [expected]: [number],
408
+ [secret]: [number]
407
409
  ): void {
408
- assert(balance >= threshold);
410
+ assert(secret * secret == expected);
409
411
  }
410
412
  `;
411
413
  }
412
414
  function generateAgeProof() {
413
415
  return `/**
414
- * Age Proof Circuit
416
+ * Another Square Proof Circuit
415
417
  *
416
- * Proves that a private birth year results in an age >= minimum age
417
- * without revealing the actual birth year.
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
- * @param currentYear - The current year (public)
420
- * @param minAge - The minimum required age (public)
421
- * @param birthYear - The actual birth year (private, not revealed)
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
- [currentYear, minAge]: [number, number],
425
- [birthYear]: [number]
427
+ [expected]: [number],
428
+ [secret]: [number]
426
429
  ): void {
427
- const age = currentYear - birthYear;
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
- * Replace this with your own circuit logic.
437
- * Use assert() statements to define constraints.
438
+ * A minimal ZK proof that proves knowledge of a secret whose square
439
+ * equals the public expected value.
438
440
  *
439
- * @param publicInput - A public input value
440
- * @param privateInput - A private input value (not revealed)
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
- [publicInput]: [number],
444
- [privateInput]: [number]
447
+ [expected]: [number],
448
+ [secret]: [number]
445
449
  ): void {
446
- // Example: prove that private input equals public input
447
- assert(privateInput === publicInput);
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: ['publicInput'],
1181
- privateInputKeys: ['privateInput'],
1182
- defaultInputs: { publicInput: '42', privateInput: '42' },
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: ['threshold'],
1191
- privateInputKeys: ['balance'],
1192
- defaultInputs: { threshold: '100', balance: '1500' },
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: ['threshold'],
1201
- privateInputKeys: ['balance'],
1202
- defaultInputs: { threshold: '100', balance: '1500' },
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: ['currentYear', 'minAge'],
1208
- privateInputKeys: ['birthYear'],
1209
- defaultInputs: { currentYear: '2024', minAge: '18', birthYear: '1990' },
1211
+ publicInputKeys: ['expected'],
1212
+ privateInputKeys: ['secret'],
1213
+ defaultInputs: { expected: '16', secret: '4' },
1210
1214
  },
1211
1215
  ]`;
1212
1216
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-izi-noir",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "CLI to scaffold IZI-NOIR ZK projects",
5
5
  "type": "module",
6
6
  "bin": {