create-izi-noir 0.2.17 → 0.2.18
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 +86 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -316,7 +316,7 @@ function createGitProgress() {
|
|
|
316
316
|
function generatePackageJson(options) {
|
|
317
317
|
const isSolana = options.provider === "arkworks";
|
|
318
318
|
const dependencies = {
|
|
319
|
-
"@izi-noir/sdk": "^0.1.
|
|
319
|
+
"@izi-noir/sdk": "^0.1.13",
|
|
320
320
|
"@noir-lang/acvm_js": "1.0.0-beta.13-1d260df.nightly",
|
|
321
321
|
"@noir-lang/noirc_abi": "1.0.0-beta.13-1d260df.nightly",
|
|
322
322
|
"react": "^18.3.1",
|
|
@@ -393,37 +393,39 @@ function generateTsconfig() {
|
|
|
393
393
|
// src/generators/circuits.ts
|
|
394
394
|
function generateBalanceProof() {
|
|
395
395
|
return `/**
|
|
396
|
-
*
|
|
396
|
+
* Balance Proof Circuit
|
|
397
397
|
*
|
|
398
|
-
* Proves
|
|
399
|
-
* This
|
|
398
|
+
* Proves that two private values sum to a public total.
|
|
399
|
+
* This demonstrates a real-world use case: proving you have sufficient balance
|
|
400
|
+
* without revealing the individual amounts.
|
|
400
401
|
*
|
|
401
|
-
* Example:
|
|
402
|
+
* Example: Prove that a=30 + b=20 = total=50
|
|
402
403
|
*
|
|
403
|
-
* @param
|
|
404
|
-
* @param
|
|
404
|
+
* @param total - The expected sum (public)
|
|
405
|
+
* @param a - First private value (not revealed)
|
|
406
|
+
* @param b - Second private value (not revealed)
|
|
405
407
|
*/
|
|
406
408
|
export function balanceProof(
|
|
407
|
-
[
|
|
408
|
-
[
|
|
409
|
+
[total]: [number],
|
|
410
|
+
[a, b]: [number, number]
|
|
409
411
|
): void {
|
|
410
|
-
assert(
|
|
412
|
+
assert(a + b == total);
|
|
411
413
|
}
|
|
412
414
|
`;
|
|
413
415
|
}
|
|
414
|
-
function
|
|
416
|
+
function generateSquareProof() {
|
|
415
417
|
return `/**
|
|
416
|
-
*
|
|
418
|
+
* Square Proof Circuit
|
|
417
419
|
*
|
|
418
|
-
*
|
|
419
|
-
* This
|
|
420
|
+
* Proves knowledge of a secret number whose square equals a public value.
|
|
421
|
+
* This is a fundamental ZK proof pattern.
|
|
420
422
|
*
|
|
421
|
-
* Example: To prove you know the secret
|
|
423
|
+
* Example: To prove you know the secret 7, set expected = 49 (7\xB2)
|
|
422
424
|
*
|
|
423
425
|
* @param expected - The expected result (secret\xB2) (public)
|
|
424
426
|
* @param secret - The secret square root to prove (private, not revealed)
|
|
425
427
|
*/
|
|
426
|
-
export function
|
|
428
|
+
export function squareProof(
|
|
427
429
|
[expected]: [number],
|
|
428
430
|
[secret]: [number]
|
|
429
431
|
): void {
|
|
@@ -462,7 +464,7 @@ function generateCircuitsIndex(template) {
|
|
|
462
464
|
`;
|
|
463
465
|
default:
|
|
464
466
|
return `export { balanceProof } from './balance-proof.js';
|
|
465
|
-
export {
|
|
467
|
+
export { squareProof } from './square-proof.js';
|
|
466
468
|
`;
|
|
467
469
|
}
|
|
468
470
|
}
|
|
@@ -738,7 +740,9 @@ import { Chain, Network, getExplorerTxUrl, getExplorerAccountUrl } from '@izi-no
|
|
|
738
740
|
// Verify state
|
|
739
741
|
const [isVerifying, setIsVerifying] = useState(false);
|
|
740
742
|
const [verified, setVerified] = useState<boolean | null>(null);
|
|
741
|
-
const [verifyError, setVerifyError] = useState<string | null>(null)
|
|
743
|
+
const [verifyError, setVerifyError] = useState<string | null>(null);
|
|
744
|
+
const [verifyTxSignature, setVerifyTxSignature] = useState<string | null>(null);
|
|
745
|
+
const [verifyExplorerUrl, setVerifyExplorerUrl] = useState<string | null>(null);` : "";
|
|
742
746
|
const solanaCircuitResetCode = isSolana ? `
|
|
743
747
|
// Reset deploy state when circuit changes (VK will be different)
|
|
744
748
|
setVkAccount(null);
|
|
@@ -775,10 +779,14 @@ import { Chain, Network, getExplorerTxUrl, getExplorerAccountUrl } from '@izi-no
|
|
|
775
779
|
|
|
776
780
|
setIsVerifying(true);
|
|
777
781
|
setVerifyError(null);
|
|
782
|
+
setVerifyTxSignature(null);
|
|
783
|
+
setVerifyExplorerUrl(null);
|
|
778
784
|
|
|
779
785
|
try {
|
|
780
786
|
const result = await iziInstance.verifyOnChain({ publicKey, sendTransaction }, vkAccount);
|
|
781
787
|
setVerified(result.verified);
|
|
788
|
+
setVerifyTxSignature(result.signature);
|
|
789
|
+
setVerifyExplorerUrl(result.explorerUrl);
|
|
782
790
|
} catch (error) {
|
|
783
791
|
const err = error as Error;
|
|
784
792
|
console.error('Verify error details:', {
|
|
@@ -878,7 +886,21 @@ import { Chain, Network, getExplorerTxUrl, getExplorerAccountUrl } from '@izi-no
|
|
|
878
886
|
{isVerifying ? 'Verifying...' : verified ? 'Verified!' : 'Verify On-Chain'}
|
|
879
887
|
</button>
|
|
880
888
|
{verifyError && <p className="error">{verifyError}</p>}
|
|
881
|
-
{verified &&
|
|
889
|
+
{verified && (
|
|
890
|
+
<div className="success-box">
|
|
891
|
+
<p className="success">\u2713 Proof verified on Solana!</p>
|
|
892
|
+
{verifyTxSignature && (
|
|
893
|
+
<p className="tx-info">
|
|
894
|
+
Tx: <code>{verifyTxSignature.slice(0, 8)}...{verifyTxSignature.slice(-8)}</code>
|
|
895
|
+
{verifyExplorerUrl && (
|
|
896
|
+
<a href={verifyExplorerUrl} target="_blank" rel="noopener noreferrer" className="explorer-link">
|
|
897
|
+
View on Explorer \u2192
|
|
898
|
+
</a>
|
|
899
|
+
)}
|
|
900
|
+
</p>
|
|
901
|
+
)}
|
|
902
|
+
</div>
|
|
903
|
+
)}
|
|
882
904
|
</div>
|
|
883
905
|
</div>
|
|
884
906
|
)}
|
|
@@ -1176,7 +1198,7 @@ function getCircuitImports(template) {
|
|
|
1176
1198
|
case "balance-proof":
|
|
1177
1199
|
return `import { balanceProof } from '../circuits';`;
|
|
1178
1200
|
default:
|
|
1179
|
-
return `import { balanceProof,
|
|
1201
|
+
return `import { balanceProof, squareProof } from '../circuits';`;
|
|
1180
1202
|
}
|
|
1181
1203
|
}
|
|
1182
1204
|
function getCircuitOptions(template) {
|
|
@@ -1196,9 +1218,9 @@ function getCircuitOptions(template) {
|
|
|
1196
1218
|
{
|
|
1197
1219
|
name: 'balanceProof',
|
|
1198
1220
|
fn: balanceProof,
|
|
1199
|
-
publicInputKeys: ['
|
|
1200
|
-
privateInputKeys: ['
|
|
1201
|
-
defaultInputs: {
|
|
1221
|
+
publicInputKeys: ['total'],
|
|
1222
|
+
privateInputKeys: ['a', 'b'],
|
|
1223
|
+
defaultInputs: { total: '50', a: '30', b: '20' },
|
|
1202
1224
|
},
|
|
1203
1225
|
]`;
|
|
1204
1226
|
default:
|
|
@@ -1206,16 +1228,16 @@ function getCircuitOptions(template) {
|
|
|
1206
1228
|
{
|
|
1207
1229
|
name: 'balanceProof',
|
|
1208
1230
|
fn: balanceProof,
|
|
1209
|
-
publicInputKeys: ['
|
|
1210
|
-
privateInputKeys: ['
|
|
1211
|
-
defaultInputs: {
|
|
1231
|
+
publicInputKeys: ['total'],
|
|
1232
|
+
privateInputKeys: ['a', 'b'],
|
|
1233
|
+
defaultInputs: { total: '50', a: '30', b: '20' },
|
|
1212
1234
|
},
|
|
1213
1235
|
{
|
|
1214
|
-
name: '
|
|
1215
|
-
fn:
|
|
1236
|
+
name: 'squareProof',
|
|
1237
|
+
fn: squareProof,
|
|
1216
1238
|
publicInputKeys: ['expected'],
|
|
1217
1239
|
privateInputKeys: ['secret'],
|
|
1218
|
-
defaultInputs: { expected: '
|
|
1240
|
+
defaultInputs: { expected: '49', secret: '7' },
|
|
1219
1241
|
},
|
|
1220
1242
|
]`;
|
|
1221
1243
|
}
|
|
@@ -1546,6 +1568,10 @@ main {
|
|
|
1546
1568
|
.success {
|
|
1547
1569
|
color: var(--solana-green);
|
|
1548
1570
|
font-size: 0.875rem;
|
|
1571
|
+
margin: 0;
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
.success-box {
|
|
1549
1575
|
margin-top: 0.5rem;
|
|
1550
1576
|
padding: 0.75rem 1rem;
|
|
1551
1577
|
background: rgba(20, 241, 149, 0.1);
|
|
@@ -1553,6 +1579,36 @@ main {
|
|
|
1553
1579
|
border-radius: 8px;
|
|
1554
1580
|
}
|
|
1555
1581
|
|
|
1582
|
+
.tx-info {
|
|
1583
|
+
font-size: 0.8rem;
|
|
1584
|
+
color: var(--text-muted);
|
|
1585
|
+
margin-top: 0.5rem;
|
|
1586
|
+
display: flex;
|
|
1587
|
+
align-items: center;
|
|
1588
|
+
gap: 0.5rem;
|
|
1589
|
+
flex-wrap: wrap;
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
.tx-info code {
|
|
1593
|
+
font-family: 'Fira Code', 'SF Mono', Monaco, monospace;
|
|
1594
|
+
background: rgba(255, 255, 255, 0.05);
|
|
1595
|
+
padding: 0.2rem 0.4rem;
|
|
1596
|
+
border-radius: 4px;
|
|
1597
|
+
font-size: 0.75rem;
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
.explorer-link {
|
|
1601
|
+
color: var(--solana-purple);
|
|
1602
|
+
text-decoration: none;
|
|
1603
|
+
font-weight: 500;
|
|
1604
|
+
transition: color 0.2s;
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
.explorer-link:hover {
|
|
1608
|
+
color: var(--solana-green);
|
|
1609
|
+
text-decoration: underline;
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1556
1612
|
.warning {
|
|
1557
1613
|
padding: 0.75rem 1rem;
|
|
1558
1614
|
background: rgba(255, 193, 7, 0.1);
|
|
@@ -2906,7 +2962,7 @@ async function createProjectStructure(projectDir, options, progress) {
|
|
|
2906
2962
|
break;
|
|
2907
2963
|
default:
|
|
2908
2964
|
files.push(["circuits/balance-proof.ts", generateBalanceProof()]);
|
|
2909
|
-
files.push(["circuits/
|
|
2965
|
+
files.push(["circuits/square-proof.ts", generateSquareProof()]);
|
|
2910
2966
|
break;
|
|
2911
2967
|
}
|
|
2912
2968
|
files.push(["circuits/index.ts", generateCircuitsIndex(options.template)]);
|