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