solvoid 1.0.0
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/LICENSE +21 -0
- package/README.md +123 -0
- package/SECURITY.md +174 -0
- package/bin/solvoid-scan +2 -0
- package/dist/cli/privacy-scan.d.ts +11 -0
- package/dist/cli/privacy-scan.d.ts.map +1 -0
- package/dist/cli/privacy-scan.js +112 -0
- package/dist/cli/privacy-scan.js.map +1 -0
- package/dist/cli/solvoid-scan.d.ts +13 -0
- package/dist/cli/solvoid-scan.d.ts.map +1 -0
- package/dist/cli/solvoid-scan.js +174 -0
- package/dist/cli/solvoid-scan.js.map +1 -0
- package/dist/cli/test-forensics.d.ts +2 -0
- package/dist/cli/test-forensics.d.ts.map +1 -0
- package/dist/cli/test-forensics.js +90 -0
- package/dist/cli/test-forensics.js.map +1 -0
- package/dist/cli/test-scenarios.d.ts +2 -0
- package/dist/cli/test-scenarios.d.ts.map +1 -0
- package/dist/cli/test-scenarios.js +96 -0
- package/dist/cli/test-scenarios.js.map +1 -0
- package/dist/examples/enterprise-demo.js +65 -0
- package/dist/sdk/client.d.ts +77 -0
- package/dist/sdk/client.d.ts.map +1 -0
- package/dist/sdk/client.js +180 -0
- package/dist/sdk/client.js.map +1 -0
- package/dist/sdk/compliance/identity.d.ts +34 -0
- package/dist/sdk/compliance/identity.d.ts.map +1 -0
- package/dist/sdk/compliance/identity.js +55 -0
- package/dist/sdk/compliance/identity.js.map +1 -0
- package/dist/sdk/compliance/threat-model.d.ts +14 -0
- package/dist/sdk/compliance/threat-model.d.ts.map +1 -0
- package/dist/sdk/compliance/threat-model.js +101 -0
- package/dist/sdk/compliance/threat-model.js.map +1 -0
- package/dist/sdk/forensics/mev.js +50 -0
- package/dist/sdk/forensics/order-flow.d.ts +20 -0
- package/dist/sdk/forensics/order-flow.d.ts.map +1 -0
- package/dist/sdk/forensics/order-flow.js +104 -0
- package/dist/sdk/forensics/order-flow.js.map +1 -0
- package/dist/sdk/forensics/simulation.d.ts +14 -0
- package/dist/sdk/forensics/simulation.d.ts.map +1 -0
- package/dist/sdk/forensics/simulation.js +45 -0
- package/dist/sdk/forensics/simulation.js.map +1 -0
- package/dist/sdk/index.d.ts +10 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +43 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/sdk/network/shadow-rpc.d.ts +18 -0
- package/dist/sdk/network/shadow-rpc.d.ts.map +1 -0
- package/dist/sdk/network/shadow-rpc.js +32 -0
- package/dist/sdk/network/shadow-rpc.js.map +1 -0
- package/dist/sdk/obfuscator.d.ts +36 -0
- package/dist/sdk/obfuscator.d.ts.map +1 -0
- package/dist/sdk/obfuscator.js +77 -0
- package/dist/sdk/obfuscator.js.map +1 -0
- package/dist/sdk/passport/manager.d.ts +36 -0
- package/dist/sdk/passport/manager.d.ts.map +1 -0
- package/dist/sdk/passport/manager.js +107 -0
- package/dist/sdk/passport/manager.js.map +1 -0
- package/dist/sdk/pipeline.d.ts +34 -0
- package/dist/sdk/pipeline.d.ts.map +1 -0
- package/dist/sdk/pipeline.js +81 -0
- package/dist/sdk/pipeline.js.map +1 -0
- package/dist/sdk/privacy/confidential-transfer.d.ts +81 -0
- package/dist/sdk/privacy/confidential-transfer.d.ts.map +1 -0
- package/dist/sdk/privacy/confidential-transfer.js +158 -0
- package/dist/sdk/privacy/confidential-transfer.js.map +1 -0
- package/dist/sdk/privacy/history.d.ts +11 -0
- package/dist/sdk/privacy/history.d.ts.map +1 -0
- package/dist/sdk/privacy/history.js +110 -0
- package/dist/sdk/privacy/history.js.map +1 -0
- package/dist/sdk/privacy/light-protocol.d.ts +42 -0
- package/dist/sdk/privacy/light-protocol.d.ts.map +1 -0
- package/dist/sdk/privacy/light-protocol.js +83 -0
- package/dist/sdk/privacy/light-protocol.js.map +1 -0
- package/dist/sdk/privacy/relayer.d.ts +12 -0
- package/dist/sdk/privacy/relayer.d.ts.map +1 -0
- package/dist/sdk/privacy/relayer.js +55 -0
- package/dist/sdk/privacy/relayer.js.map +1 -0
- package/dist/sdk/privacy/safe-obfuscator.d.ts +38 -0
- package/dist/sdk/privacy/safe-obfuscator.d.ts.map +1 -0
- package/dist/sdk/privacy/safe-obfuscator.js +101 -0
- package/dist/sdk/privacy/safe-obfuscator.js.map +1 -0
- package/dist/sdk/privacy/shield.d.ts +34 -0
- package/dist/sdk/privacy/shield.d.ts.map +1 -0
- package/dist/sdk/privacy/shield.js +174 -0
- package/dist/sdk/privacy/shield.js.map +1 -0
- package/dist/sdk/privacy/zk.js +43 -0
- package/dist/sdk/privacy-engine.d.ts +11 -0
- package/dist/sdk/privacy-engine.d.ts.map +1 -0
- package/dist/sdk/privacy-engine.js +165 -0
- package/dist/sdk/privacy-engine.js.map +1 -0
- package/dist/sdk/registry/idl-fetcher.d.ts +17 -0
- package/dist/sdk/registry/idl-fetcher.d.ts.map +1 -0
- package/dist/sdk/registry/idl-fetcher.js +98 -0
- package/dist/sdk/registry/idl-fetcher.js.map +1 -0
- package/dist/sdk/registry/programs.d.ts +18 -0
- package/dist/sdk/registry/programs.d.ts.map +1 -0
- package/dist/sdk/registry/programs.js +45 -0
- package/dist/sdk/registry/programs.js.map +1 -0
- package/dist/sdk/rescue/analyzer.d.ts +22 -0
- package/dist/sdk/rescue/analyzer.d.ts.map +1 -0
- package/dist/sdk/rescue/analyzer.js +46 -0
- package/dist/sdk/rescue/analyzer.js.map +1 -0
- package/dist/sdk/rescue/builder.d.ts +16 -0
- package/dist/sdk/rescue/builder.d.ts.map +1 -0
- package/dist/sdk/rescue/builder.js +33 -0
- package/dist/sdk/rescue/builder.js.map +1 -0
- package/dist/sdk/semantics/analyzer.d.ts +1 -0
- package/dist/sdk/semantics/analyzer.d.ts.map +1 -0
- package/dist/sdk/semantics/analyzer.js +2 -0
- package/dist/sdk/semantics/analyzer.js.map +1 -0
- package/dist/sdk/semantics/decoder.d.ts +7 -0
- package/dist/sdk/semantics/decoder.d.ts.map +1 -0
- package/dist/sdk/semantics/decoder.js +30 -0
- package/dist/sdk/semantics/decoder.js.map +1 -0
- package/dist/sdk/semantics/graph.d.ts +1 -0
- package/dist/sdk/semantics/graph.d.ts.map +1 -0
- package/dist/sdk/semantics/graph.js +2 -0
- package/dist/sdk/semantics/graph.js.map +1 -0
- package/dist/sdk/semantics/idl-registry.d.ts +7 -0
- package/dist/sdk/semantics/idl-registry.d.ts.map +1 -0
- package/dist/sdk/semantics/idl-registry.js +95 -0
- package/dist/sdk/semantics/idl-registry.js.map +1 -0
- package/dist/sdk/semantics/types.d.ts +44 -0
- package/dist/sdk/semantics/types.d.ts.map +1 -0
- package/dist/sdk/semantics/types.js +3 -0
- package/dist/sdk/semantics/types.js.map +1 -0
- package/dist/sdk/simulator.d.ts +15 -0
- package/dist/sdk/simulator.d.ts.map +1 -0
- package/dist/sdk/simulator.js +133 -0
- package/dist/sdk/simulator.js.map +1 -0
- package/dist/sdk/types.d.ts +53 -0
- package/dist/sdk/types.d.ts.map +1 -0
- package/dist/sdk/types.js +3 -0
- package/dist/sdk/types.js.map +1 -0
- package/dist/sdk/utils/config.d.ts +15 -0
- package/dist/sdk/utils/config.d.ts.map +1 -0
- package/dist/sdk/utils/config.js +40 -0
- package/dist/sdk/utils/config.js.map +1 -0
- package/dist/sdk/utils/logger.d.ts +3 -0
- package/dist/sdk/utils/logger.d.ts.map +1 -0
- package/dist/sdk/utils/logger.js +17 -0
- package/dist/sdk/utils/logger.js.map +1 -0
- package/dist/tests/unit/idl-registry.test.d.ts +2 -0
- package/dist/tests/unit/idl-registry.test.d.ts.map +1 -0
- package/dist/tests/unit/idl-registry.test.js +35 -0
- package/dist/tests/unit/idl-registry.test.js.map +1 -0
- package/dist/tools/exploit_demonstration.js +99 -0
- package/dist/tools/gen-tx.js +29 -0
- package/dist/tools/get-recent-tx.js +18 -0
- package/package.json +95 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-forensics.d.ts","sourceRoot":"","sources":["../../cli/test-forensics.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const privacy_engine_1 = require("../sdk/privacy-engine");
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
// Setup Mock Identity - using valid keys
|
|
6
|
+
// Victim = MemoV1
|
|
7
|
+
const VICTIM_PUBKEY = new web3_js_1.PublicKey("Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo");
|
|
8
|
+
const VICTIM_B58 = VICTIM_PUBKEY.toBase58();
|
|
9
|
+
// Attacker = MemoV2
|
|
10
|
+
const ATTACKER = "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr";
|
|
11
|
+
// Program = Token Program
|
|
12
|
+
const PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
13
|
+
// PDA = Goki (Arbitrary valid key)
|
|
14
|
+
const PDA_ACCOUNT = "GokivDYuQXPZCWRkwMhdH2h91KpDQXBEmpgBgs55bnpH";
|
|
15
|
+
// Transaction that defines the "User" context
|
|
16
|
+
const tx = {
|
|
17
|
+
signatures: ["sig_forensic"],
|
|
18
|
+
message: {
|
|
19
|
+
accountKeys: [ATTACKER, VICTIM_B58, PROGRAM_ID, PDA_ACCOUNT],
|
|
20
|
+
header: {
|
|
21
|
+
numRequiredSignatures: 2, // Attacker is likely FeePayer here contextually but let's say Victim signed too
|
|
22
|
+
numReadonlySignedAccounts: 0,
|
|
23
|
+
numReadonlyUnsignedAccounts: 1
|
|
24
|
+
},
|
|
25
|
+
instructions: [
|
|
26
|
+
{ programIdIndex: 2, accounts: [1, 3], data: "AQ==" } // Interact with Program, passing Victim(1) and PDA(3)
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
// Construct Malicious State Data
|
|
31
|
+
// [8 bytes discriminator] + [32 bytes innocent] + [32 bytes VICTIM KEY] + [End]
|
|
32
|
+
const innocentBytes = Buffer.alloc(32).fill(0xAA);
|
|
33
|
+
const victimBytes = VICTIM_PUBKEY.toBuffer();
|
|
34
|
+
const maliciousState = Buffer.concat([
|
|
35
|
+
Buffer.from("12345678", "hex"), // Discriminator
|
|
36
|
+
innocentBytes,
|
|
37
|
+
victimBytes, // <--- THE LEAK
|
|
38
|
+
Buffer.from("DEADBEEF", "hex")
|
|
39
|
+
]);
|
|
40
|
+
const events = {
|
|
41
|
+
signature: "sig_forensic",
|
|
42
|
+
accountUpdates: [
|
|
43
|
+
{
|
|
44
|
+
pubkey: PDA_ACCOUNT,
|
|
45
|
+
owner: PROGRAM_ID,
|
|
46
|
+
lamports: 1000000,
|
|
47
|
+
data: maliciousState.toString('base64'),
|
|
48
|
+
executable: false,
|
|
49
|
+
rentEpoch: 0,
|
|
50
|
+
writeVersion: 1
|
|
51
|
+
},
|
|
52
|
+
// Also include a "Safe" update (User updating their own account)
|
|
53
|
+
{
|
|
54
|
+
pubkey: VICTIM_B58, // Updating self
|
|
55
|
+
owner: "11111111111111111111111111111111", // System Owned usually
|
|
56
|
+
lamports: 900000,
|
|
57
|
+
data: victimBytes.toString('base64'), // Contains own key obviously
|
|
58
|
+
executable: false,
|
|
59
|
+
rentEpoch: 0,
|
|
60
|
+
writeVersion: 2
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
function runForensicTest() {
|
|
65
|
+
console.log("--- Running Forensic Analysis (Phase 4) ---");
|
|
66
|
+
const engine = new privacy_engine_1.PrivacyEngine();
|
|
67
|
+
// 1. Analyze
|
|
68
|
+
const leaks = engine.analyzeGeyserEvents(tx, events);
|
|
69
|
+
// 2. Report
|
|
70
|
+
if (leaks.length > 0) {
|
|
71
|
+
console.log(`✅ FOUND ${leaks.length} LEAKS (Expected 1 Critical State Leak):`);
|
|
72
|
+
leaks.forEach((l) => {
|
|
73
|
+
console.log(` [${l.type.toUpperCase()}] Severity: ${l.severity || "Medium"}`);
|
|
74
|
+
console.log(` Scope: ${l.scope}`);
|
|
75
|
+
console.log(` Desc: ${l.description}`);
|
|
76
|
+
if (l.type === 'state-leak' && l.scope.includes(PDA_ACCOUNT)) {
|
|
77
|
+
console.log(" -> VERIFIED: Successfully detected binary leak in PDA.");
|
|
78
|
+
}
|
|
79
|
+
if (l.scope.includes(VICTIM_B58)) {
|
|
80
|
+
console.log(" -> CHECK: Did we flag the user's own account? (Should NOT happen).");
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
console.log("❌ FAILED: No leaks detected in forensic scan.");
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
runForensicTest();
|
|
90
|
+
//# sourceMappingURL=test-forensics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-forensics.js","sourceRoot":"","sources":["../../cli/test-forensics.ts"],"names":[],"mappings":";;AAAA,0DAAsD;AAEtD,6CAA4C;AAE5C,yCAAyC;AACzC,kBAAkB;AAClB,MAAM,aAAa,GAAG,IAAI,mBAAS,CAAC,6CAA6C,CAAC,CAAC;AACnF,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAC;AAE5C,oBAAoB;AACpB,MAAM,QAAQ,GAAG,6CAA6C,CAAC;AAE/D,0BAA0B;AAC1B,MAAM,UAAU,GAAG,6CAA6C,CAAC;AAEjE,mCAAmC;AACnC,MAAM,WAAW,GAAG,8CAA8C,CAAC;AAEnE,8CAA8C;AAC9C,MAAM,EAAE,GAAoB;IACxB,UAAU,EAAE,CAAC,cAAc,CAAC;IAC5B,OAAO,EAAE;QACL,WAAW,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,CAAC;QAC5D,MAAM,EAAE;YACJ,qBAAqB,EAAE,CAAC,EAAE,gFAAgF;YAC1G,yBAAyB,EAAE,CAAC;YA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names":[],"mappings":""}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const privacy_engine_1 = require("../sdk/privacy-engine");
|
|
4
|
+
const MEMO_V1 = "Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo";
|
|
5
|
+
const MEMO_V2 = "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr";
|
|
6
|
+
const SQUADS_ID = "SMPLecH534NA9acpos4G6x7uf3LWbCAwZQE9e8ZekMu";
|
|
7
|
+
const SYSTEM_PROGRAM = "11111111111111111111111111111111";
|
|
8
|
+
const PROXY_PROGRAM = "Proxy11111111111111111111111111111111111111";
|
|
9
|
+
const VICTIM = "VictimUserAddress11111111111111111111111111";
|
|
10
|
+
const ATTACKER = "AttackerAddress111111111111111111111111111";
|
|
11
|
+
function logTest(name, tx) {
|
|
12
|
+
console.log(`\n--- Running Test: ${name} ---`);
|
|
13
|
+
const engine = new privacy_engine_1.PrivacyEngine();
|
|
14
|
+
const leaks = engine.analyzeTransaction(tx);
|
|
15
|
+
if (leaks.length > 0) {
|
|
16
|
+
console.log(`✅ DETECTED ${leaks.length} LEAKS:`);
|
|
17
|
+
leaks.forEach((l) => console.log(` [${l.type}] ${l.scope} \n Description: ${l.description}`));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
console.log("❌ FAILED: No leaks detected!");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// Test 1: Nested Memo via CPI
|
|
24
|
+
const test1 = {
|
|
25
|
+
signatures: ["sig1"],
|
|
26
|
+
message: {
|
|
27
|
+
accountKeys: [ATTACKER, VICTIM, SYSTEM_PROGRAM, PROXY_PROGRAM, MEMO_V2],
|
|
28
|
+
header: { numRequiredSignatures: 1, numReadonlySignedAccounts: 0, numReadonlyUnsignedAccounts: 3 },
|
|
29
|
+
instructions: [
|
|
30
|
+
{ programIdIndex: 2, accounts: [0, 1], data: "" }, // System Transfer
|
|
31
|
+
{ programIdIndex: 3, accounts: [1], data: "AQ==" } // Proxy Call
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
meta: {
|
|
35
|
+
innerInstructions: [
|
|
36
|
+
{
|
|
37
|
+
index: 1, // Inside Proxy Call
|
|
38
|
+
instructions: [
|
|
39
|
+
{ programIdIndex: 4, accounts: [], data: Buffer.from("Secret Data").toString('base64') } // Call Memo v2
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
// Test 2: Memo v1 Evasion
|
|
46
|
+
const test2 = {
|
|
47
|
+
signatures: ["sig2"],
|
|
48
|
+
message: {
|
|
49
|
+
accountKeys: [ATTACKER, MEMO_V1],
|
|
50
|
+
header: { numRequiredSignatures: 1, numReadonlySignedAccounts: 0, numReadonlyUnsignedAccounts: 1 },
|
|
51
|
+
instructions: [
|
|
52
|
+
{ programIdIndex: 1, accounts: [], data: Buffer.from("Secret V1 Data").toString('base64') }
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
// Test 3: Double-Nested CPI
|
|
57
|
+
const test3 = {
|
|
58
|
+
signatures: ["sig3"],
|
|
59
|
+
message: {
|
|
60
|
+
accountKeys: [ATTACKER, PROXY_PROGRAM, "IntermediateProg...", MEMO_V2],
|
|
61
|
+
header: { numRequiredSignatures: 1, numReadonlySignedAccounts: 0, numReadonlyUnsignedAccounts: 3 },
|
|
62
|
+
instructions: [
|
|
63
|
+
{ programIdIndex: 1, accounts: [], data: "" } // Call Proxy
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
meta: {
|
|
67
|
+
innerInstructions: [
|
|
68
|
+
{
|
|
69
|
+
index: 0, // Inside Proxy
|
|
70
|
+
instructions: [
|
|
71
|
+
{ programIdIndex: 2, accounts: [], data: "" }, // Proxy Calls Intermediate
|
|
72
|
+
{ programIdIndex: 3, accounts: [], data: Buffer.from("Deep Secret").toString('base64') } // Intermediate Calls Memo
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
// Test 4: Account Abstraction (Data Leak)
|
|
79
|
+
// Fee Payer = Squads (Index 0)
|
|
80
|
+
// Real User = Victim (Index 1) -> Signer
|
|
81
|
+
const test4 = {
|
|
82
|
+
signatures: ["sig4"],
|
|
83
|
+
message: {
|
|
84
|
+
accountKeys: [SQUADS_ID, VICTIM, MEMO_V2],
|
|
85
|
+
header: { numRequiredSignatures: 2, numReadonlySignedAccounts: 0, numReadonlyUnsignedAccounts: 1 },
|
|
86
|
+
instructions: [
|
|
87
|
+
// Instruction: Memo program with data that includes VICTIM address
|
|
88
|
+
{ programIdIndex: 2, accounts: [], data: Buffer.from(`User Metadata: ${VICTIM}`).toString('base64') }
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
logTest("1. Nested Memo via CPI", test1);
|
|
93
|
+
logTest("2. Memo v1 Evasion", test2);
|
|
94
|
+
logTest("3. Double-Nested CPI", test3);
|
|
95
|
+
logTest("4. Account Abstraction (Data Leak)", test4);
|
|
96
|
+
//# sourceMappingURL=test-scenarios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-scenarios.js","sourceRoot":"","sources":["../../cli/test-scenarios.ts"],"names":[],"mappings":";;AAAA,0DAAsD;AAGtD,MAAM,OAAO,GAAG,6CAA6C,CAAC;AAC9D,MAAM,OAAO,GAAG,6CAA6C,CAAC;AAC9D,MAAM,SAAS,GAAG,6CAA6C,CAAC;AAChE,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAC1D,MAAM,aAAa,GAAG,6CAA6C,CAAC;AAEpE,MAAM,MAAM,GAAG,6CAA6C,CAAC;AAC7D,MAAM,QAAQ,GAAG,4CAA4C,CAAC;AAE9D,SAAS,OAAO,CAAC,IAAY,EAAE,EAAmB;IAC9C,OAA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BAC1E,EAAE,cAAc,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,0BAA0B;iBACtH;aACJ;SACJ;KACJ;CACJ,CAAC;AAEF,0CAA0C;AAC1C,+BAA+B;AAC/B,yCAAyC;AACzC,MAAM,KAAK,GAAoB;IAC3B,UAAU,EAAE,CAAC,MAAM,CAAC;IACpB,OAAO,EAAE;QACL,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC;QACzC,MAAM,EAAE,EAAE,qBAAqB,EAAE,CAAC,EAAE,yBAAyB,EAAE,CAAC,EAAE,2BAA2B,EAAE,CAAC,EAAE;QAClG,YAAY,EAAE;YACV,mEAAmE;YACnE,EAAE,cAAc,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,kBAAkB,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;SACxG;KACJ;CACJ,CAAC;AAEF,OAAO,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;AACzC,OAAO,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;AACrC,OAAO,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;AACvC,OAAO,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const client_1 = require("../sdk/client"); // Adjust path
|
|
4
|
+
// Mock Config
|
|
5
|
+
const client = new client_1.PrivacyZeroClient({
|
|
6
|
+
rpcUrl: "https://api.mainnet-beta.solana.com", // Dummy
|
|
7
|
+
modules: {
|
|
8
|
+
semantic: true, // We want to test this
|
|
9
|
+
mev: true
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
// Mock Transaction: A User (FeePayer) calling "Super Swap"
|
|
13
|
+
// User Wallet: 5ZwJ... (Mock) -> Index 0
|
|
14
|
+
const USER_WALLET = "5ZwJqpwa5u4...UserWallet";
|
|
15
|
+
const DEFI_PROGRAM = "DeFi111111111111111111111111111111111111111"; // Matches Mock Registry
|
|
16
|
+
// Instruction Data for "swap"
|
|
17
|
+
// Discriminator: [100, 100, 100, 100, 100, 100, 100, 100]
|
|
18
|
+
// Arg1 (amount_in u64): 5000 (LE) -> 88 13 00 00 00 00 00 00
|
|
19
|
+
// Arg2 (min_out u64): 0 -> 00 00 00 00 00 00 00 00
|
|
20
|
+
// Total: Disc + 16 bytes.
|
|
21
|
+
const disc = Buffer.alloc(8, 100);
|
|
22
|
+
const arg1 = Buffer.alloc(8);
|
|
23
|
+
arg1.writeBigUInt64LE(5000n);
|
|
24
|
+
const arg2 = Buffer.alloc(8);
|
|
25
|
+
const data = Buffer.concat([disc, arg1, arg2]);
|
|
26
|
+
const transaction = {
|
|
27
|
+
message: {
|
|
28
|
+
header: {
|
|
29
|
+
numRequiredSignatures: 1,
|
|
30
|
+
numReadonlySignedAccounts: 0,
|
|
31
|
+
numReadonlyUnsignedAccounts: 3
|
|
32
|
+
},
|
|
33
|
+
accountKeys: [
|
|
34
|
+
USER_WALLET, // 0: Signer/Payer
|
|
35
|
+
"PoolSourceAdd", // 1: Writable
|
|
36
|
+
"PoolDestAdd", // 2: Writable
|
|
37
|
+
"UserDestAdd", // 3: Writable
|
|
38
|
+
DEFI_PROGRAM // 4: Program
|
|
39
|
+
],
|
|
40
|
+
instructions: [
|
|
41
|
+
{
|
|
42
|
+
programIdIndex: 4, // DeFi Program
|
|
43
|
+
accounts: [0, 0, 1, 2, 3], // 0 is authority. 0 is also user_source.
|
|
44
|
+
data: data.toString('base64')
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
signatures: ["sig1"]
|
|
49
|
+
};
|
|
50
|
+
async function runTest() {
|
|
51
|
+
console.log("Starting Enterprise Scan...");
|
|
52
|
+
const report = await client.scan(transaction);
|
|
53
|
+
console.log("--- GOVERNANCE REPORT ---");
|
|
54
|
+
console.log("Status:", report.status);
|
|
55
|
+
console.log("Score:", report.privacyScore);
|
|
56
|
+
console.log("\n--- UNACCEPTED LIABILITIES ---");
|
|
57
|
+
report.unacceptedLiabilities.forEach(l => {
|
|
58
|
+
console.log(`[${l.leak.severity}] ${l.leak.type}: ${l.leak.description}`);
|
|
59
|
+
console.log(`Recommendation: ${l.leak.remediation}`);
|
|
60
|
+
if (l.leak.context)
|
|
61
|
+
console.log("Context:", l.leak.context);
|
|
62
|
+
console.log("-");
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
runTest();
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
export interface SolVoidConfig {
|
|
3
|
+
rpcUrl: string;
|
|
4
|
+
programId: string;
|
|
5
|
+
relayerUrl?: string;
|
|
6
|
+
mock?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* SolVoidClient
|
|
10
|
+
* High-level orchestration for scanning, shielding, and ZK-withdrawals.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SolVoidClient {
|
|
13
|
+
private pipeline;
|
|
14
|
+
private passport;
|
|
15
|
+
private shadow;
|
|
16
|
+
private connection;
|
|
17
|
+
private protocolShield;
|
|
18
|
+
private config;
|
|
19
|
+
constructor(config: SolVoidConfig, wallet: any);
|
|
20
|
+
/**
|
|
21
|
+
* Scans an address for privacy leaks and prepares remediation shielding.
|
|
22
|
+
*/
|
|
23
|
+
protect(address: PublicKey): Promise<any>;
|
|
24
|
+
/**
|
|
25
|
+
* Retrieve local scoring history and earned badges for a wallet.
|
|
26
|
+
*/
|
|
27
|
+
getPassport(address: string): Promise<import("./passport/manager").PrivacyPassport>;
|
|
28
|
+
/**
|
|
29
|
+
* Automatic scan and atomic shield for all tainted assets.
|
|
30
|
+
*/
|
|
31
|
+
rescue(address: PublicKey): Promise<{
|
|
32
|
+
status: string;
|
|
33
|
+
txid: string;
|
|
34
|
+
leakedAssets: {
|
|
35
|
+
mint: string;
|
|
36
|
+
amount: number;
|
|
37
|
+
}[];
|
|
38
|
+
oldScore: number;
|
|
39
|
+
newScore: number;
|
|
40
|
+
message?: undefined;
|
|
41
|
+
} | {
|
|
42
|
+
status: string;
|
|
43
|
+
message: string;
|
|
44
|
+
txid?: undefined;
|
|
45
|
+
leakedAssets?: undefined;
|
|
46
|
+
oldScore?: undefined;
|
|
47
|
+
newScore?: undefined;
|
|
48
|
+
} | {
|
|
49
|
+
status: string;
|
|
50
|
+
txid: string;
|
|
51
|
+
leakedAssets: import("./rescue/analyzer").LeakedAsset[];
|
|
52
|
+
oldScore: any;
|
|
53
|
+
newScore: number;
|
|
54
|
+
message?: undefined;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Directly shields an amount of SOL.
|
|
58
|
+
*/
|
|
59
|
+
shield(_amount: number): Promise<{
|
|
60
|
+
txid: string;
|
|
61
|
+
commitmentData: {
|
|
62
|
+
secret: NonSharedBuffer;
|
|
63
|
+
nullifier: NonSharedBuffer;
|
|
64
|
+
commitment: NonSharedBuffer;
|
|
65
|
+
nullifierHash: NonSharedBuffer;
|
|
66
|
+
commitmentHex: string;
|
|
67
|
+
};
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* End-to-end withdrawal: Merkle proof -> ZK-proof -> On-chain broadcast.
|
|
71
|
+
*/
|
|
72
|
+
withdraw(secretHex: string, nullifierHex: string, recipient: PublicKey, allCommitments: Buffer[], wasmPath: string, zkeyPath: string, relayerSigner: any, fee?: number): Promise<string | {
|
|
73
|
+
status: string;
|
|
74
|
+
signature: string;
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../sdk/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAUxD,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,cAAc,CAAgB;IAEtC,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG;IA0B9C;;OAEG;IACU,OAAO,CAAC,OAAO,EAAE,SAAS;IA6BvC;;OAEG;IACU,WAAW,CAAC,OAAO,EAAE,MAAM;IAIxC;;OAEG;IACU,MAAM,CAAC,OAAO,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;IAkCtC;;OAEG;IACU,MAAM,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;IASnC;;OAEG;IACU,QAAQ,CACjB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,MAAM,EAAE,EACxB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,GAAG,EAClB,GAAG,GAAE,MAAU;;;;CAgCtB"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.SolVoidClient = void 0;
|
|
40
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
41
|
+
const shield_1 = require("./privacy/shield");
|
|
42
|
+
const pipeline_1 = require("./pipeline");
|
|
43
|
+
const analyzer_1 = require("./rescue/analyzer");
|
|
44
|
+
const builder_1 = require("./rescue/builder");
|
|
45
|
+
const manager_1 = require("./passport/manager");
|
|
46
|
+
const shadow_rpc_1 = require("./network/shadow-rpc");
|
|
47
|
+
const crypto = __importStar(require("crypto"));
|
|
48
|
+
const winston_1 = __importDefault(require("winston"));
|
|
49
|
+
/**
|
|
50
|
+
* SolVoidClient
|
|
51
|
+
* High-level orchestration for scanning, shielding, and ZK-withdrawals.
|
|
52
|
+
*/
|
|
53
|
+
class SolVoidClient {
|
|
54
|
+
constructor(config, wallet) {
|
|
55
|
+
this.config = config;
|
|
56
|
+
this.connection = new web3_js_1.Connection(config.rpcUrl, 'confirmed');
|
|
57
|
+
this.passport = new manager_1.PassportManager();
|
|
58
|
+
const logger = winston_1.default.createLogger({
|
|
59
|
+
level: 'info',
|
|
60
|
+
transports: [new winston_1.default.transports.Console()]
|
|
61
|
+
});
|
|
62
|
+
this.shadow = new shadow_rpc_1.ShadowRPC(this.connection, logger);
|
|
63
|
+
const idl = {
|
|
64
|
+
version: "0.1.0",
|
|
65
|
+
name: "solvoid",
|
|
66
|
+
instructions: [
|
|
67
|
+
{ name: "initialize", accounts: [{ name: "state", isMut: true, isSigner: false }, { name: "admin", isMut: true, isSigner: true }, { name: "systemProgram", isMut: false, isSigner: false }], args: [{ name: "amount", type: "u64" }] },
|
|
68
|
+
{ name: "deposit", accounts: [{ name: "state", isMut: true, isSigner: false }, { name: "depositor", isMut: true, isSigner: true }, { name: "vault", isMut: true, isSigner: false }, { name: "systemProgram", isMut: false, isSigner: false }], args: [{ name: "commitment", type: { array: ["u8", 32] } }] },
|
|
69
|
+
{ name: "withdraw", accounts: [{ name: "state", isMut: true, isSigner: false }, { name: "vault", isMut: true, isSigner: false }, { name: "recipient", isMut: true, isSigner: false }, { name: "nullifierRecord", isMut: true, isSigner: false }, { name: "relayer", isMut: true, isSigner: true }, { name: "systemProgram", isMut: false, isSigner: false }], args: [{ name: "nullifierHash", type: { array: ["u8", 32] } }, { name: "root", type: { array: ["u8", 32] } }, { name: "proof", type: "bytes" }, { name: "fee", type: "u64" }] }
|
|
70
|
+
],
|
|
71
|
+
address: config.programId
|
|
72
|
+
};
|
|
73
|
+
this.protocolShield = new shield_1.PrivacyShield(this.connection, config.programId, idl, wallet);
|
|
74
|
+
this.pipeline = new pipeline_1.PrivacyPipeline(this.connection, this.protocolShield);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Scans an address for privacy leaks and prepares remediation shielding.
|
|
78
|
+
*/
|
|
79
|
+
async protect(address) {
|
|
80
|
+
if (this.config.mock) {
|
|
81
|
+
const mockResult = [{
|
|
82
|
+
signature: '5Qw...zX9',
|
|
83
|
+
privacyScore: 42,
|
|
84
|
+
leaks: [
|
|
85
|
+
{
|
|
86
|
+
type: 'identity',
|
|
87
|
+
scope: 'funding',
|
|
88
|
+
visibility: 'PUBLIC',
|
|
89
|
+
severity: 'CRITICAL',
|
|
90
|
+
description: 'Identity linked to Binance via Jupiter swap.'
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}];
|
|
94
|
+
this.passport.updateScore(address.toBase58(), 42);
|
|
95
|
+
return mockResult;
|
|
96
|
+
}
|
|
97
|
+
const results = await this.pipeline.processAddress(address);
|
|
98
|
+
// Update passport score automatically
|
|
99
|
+
if (results.length > 0) {
|
|
100
|
+
const avgScore = results.reduce((acc, r) => acc + r.privacyScore, 0) / results.length;
|
|
101
|
+
this.passport.updateScore(address.toBase58(), avgScore);
|
|
102
|
+
}
|
|
103
|
+
return results;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Retrieve local scoring history and earned badges for a wallet.
|
|
107
|
+
*/
|
|
108
|
+
async getPassport(address) {
|
|
109
|
+
return this.passport.getPassport(address);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Automatic scan and atomic shield for all tainted assets.
|
|
113
|
+
*/
|
|
114
|
+
async rescue(address) {
|
|
115
|
+
if (this.config.mock) {
|
|
116
|
+
return {
|
|
117
|
+
status: 'success',
|
|
118
|
+
txid: '5eYk...zVq',
|
|
119
|
+
leakedAssets: [{ mint: 'So111...112', amount: 1000000000 }],
|
|
120
|
+
oldScore: 42,
|
|
121
|
+
newScore: 95
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// 1. Scan for leaks
|
|
125
|
+
const results = await this.protect(address);
|
|
126
|
+
const allLeaks = results.flatMap((r) => r.leaks);
|
|
127
|
+
// 2. Identify Leaked Assets
|
|
128
|
+
const leakedAssets = analyzer_1.RescueAnalyzer.identifyLeakedAssets(allLeaks);
|
|
129
|
+
if (leakedAssets.length === 0)
|
|
130
|
+
return { status: 'secure', message: 'No leaked assets found.' };
|
|
131
|
+
// 3. Build Atomic Rescue Transaction
|
|
132
|
+
const builder = new builder_1.RescueBuilder(this.connection, this.protocolShield);
|
|
133
|
+
const rescueTx = await builder.buildAtomicRescueTx(address, leakedAssets);
|
|
134
|
+
// Broadcast via the relay network to hide IP
|
|
135
|
+
const txid = await this.shadow.broadcastPrivately(rescueTx, { hops: 3, stealthMode: true });
|
|
136
|
+
return {
|
|
137
|
+
status: 'success',
|
|
138
|
+
txid,
|
|
139
|
+
leakedAssets,
|
|
140
|
+
oldScore: results.length > 0 ? results[0].privacyScore : 100,
|
|
141
|
+
newScore: 95
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Directly shields an amount of SOL.
|
|
146
|
+
*/
|
|
147
|
+
async shield(_amount) {
|
|
148
|
+
const commitmentData = this.protocolShield.generateCommitment();
|
|
149
|
+
if (this.config.mock) {
|
|
150
|
+
return { txid: '4RzV...aB2', commitmentData };
|
|
151
|
+
}
|
|
152
|
+
const txid = await this.protocolShield.deposit(commitmentData.commitment);
|
|
153
|
+
return { txid, commitmentData };
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* End-to-end withdrawal: Merkle proof -> ZK-proof -> On-chain broadcast.
|
|
157
|
+
*/
|
|
158
|
+
async withdraw(secretHex, nullifierHex, recipient, allCommitments, wasmPath, zkeyPath, relayerSigner, fee = 0) {
|
|
159
|
+
if (this.config.mock) {
|
|
160
|
+
return { status: 'success', signature: '3mKj...nP5' };
|
|
161
|
+
}
|
|
162
|
+
const secret = Buffer.from(secretHex, 'hex');
|
|
163
|
+
const nullifier = Buffer.from(nullifierHex, 'hex');
|
|
164
|
+
// Generate proof of membership in the commitment pool
|
|
165
|
+
const commitment = crypto.createHash('sha256').update(Buffer.concat([secret, nullifier])).digest();
|
|
166
|
+
const index = allCommitments.findIndex(c => c.equals(commitment));
|
|
167
|
+
if (index === -1)
|
|
168
|
+
throw new Error("Commitment not found in state");
|
|
169
|
+
const merklePath = await this.protocolShield.getMerkleProof(index, allCommitments);
|
|
170
|
+
// Final root used for ZK verification
|
|
171
|
+
const root = Buffer.alloc(32); // Placeholder for root calculation logic
|
|
172
|
+
// 3. Generate ZK-Proof
|
|
173
|
+
const { proof } = await this.protocolShield.generateZKProof(secret, nullifier, root, merklePath, wasmPath, zkeyPath);
|
|
174
|
+
// 4. Submit to blockchain (or relayer)
|
|
175
|
+
const nullifierHash = crypto.createHash('sha256').update(nullifier).digest();
|
|
176
|
+
return await this.protocolShield.withdraw(nullifierHash, root, [proof], recipient, relayerSigner, fee);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
exports.SolVoidClient = SolVoidClient;
|
|
180
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../sdk/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwD;AACxD,6CAAiD;AACjD,yCAA6C;AAC7C,gDAAmD;AACnD,8CAAiD;AACjD,gDAAqD;AACrD,qDAAiD;AACjD,+CAAiC;AACjC,sDAA8B;AAS9B;;;GAGG;AACH,MAAa,aAAa;IAStB,YAAY,MAAqB,EAAE,MAAW;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC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CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;QAClE,IAAI,KAAK,KAAK,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAEnE,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QAEnF,sCAAsC;QACtC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,yCAAyC;QAExE,uBAAuB;QACvB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CACvD,MAAM,EACN,SAAS,EACT,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,QAAQ,CACX,CAAC;QAEF,uCAAuC;QACvC,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,CAAC;QAC7E,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;IAC3G,CAAC;CACJ;AAtKD,sCAsKC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TransactionJSON, Leak } from '../types';
|
|
2
|
+
export declare class IdentityComplianceConfig {
|
|
3
|
+
requireCivicPass: boolean;
|
|
4
|
+
allowedCountries: string[];
|
|
5
|
+
constructor(requireCivicPass?: boolean, allowedCountries?: string[]);
|
|
6
|
+
}
|
|
7
|
+
export declare class IdentityManager {
|
|
8
|
+
/**
|
|
9
|
+
* Checks if a transaction interacts with regulated protocols.
|
|
10
|
+
*
|
|
11
|
+
* @todo INTEGRATION REQUIRED: This method is a stub.
|
|
12
|
+
* Real implementation requires integration with:
|
|
13
|
+
* 1. Civic Gateway (Identity/KYC checks)
|
|
14
|
+
* 2. TRM Labs / Chainalysis (Sanctions Screening)
|
|
15
|
+
* 3. On-chain Allowlist Providers
|
|
16
|
+
*/
|
|
17
|
+
checkCompliance(_tx: TransactionJSON, _config: IdentityComplianceConfig): Promise<Leak[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a list of integrations required to enable full compliance mode.
|
|
20
|
+
*/
|
|
21
|
+
getRequiredIntegrations(): string[];
|
|
22
|
+
/**
|
|
23
|
+
* Generates a "Selective Disclosure" proof.
|
|
24
|
+
* @deprecated Stub implementation. Use @civic/solana-gateway-react for real proofs.
|
|
25
|
+
*/
|
|
26
|
+
generateDisclosure(_credentialType: string): {
|
|
27
|
+
proof: string;
|
|
28
|
+
claim: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export declare class MultisigMonitor {
|
|
32
|
+
analyzeMultisigPrivacy(_multisigAddress: string): Promise<Leak[]>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../sdk/compliance/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEjD,qBAAa,wBAAwB;IAEtB,gBAAgB,EAAE,OAAO;IACzB,gBAAgB,EAAE,MAAM,EAAE;gBAD1B,gBAAgB,GAAE,OAAe,EACjC,gBAAgB,GAAE,MAAM,EAAO;CAE7C;AAED,qBAAa,eAAe;IAExB;;;;;;;;OAQG;IACU,eAAe,CAAC,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAStG;;OAEG;IACI,uBAAuB,IAAI,MAAM,EAAE;IAQ1C;;;OAGG;IACI,kBAAkB,CAAC,eAAe,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;CAMvF;AAED,qBAAa,eAAe;IACX,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;CAGjF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MultisigMonitor = exports.IdentityManager = exports.IdentityComplianceConfig = void 0;
|
|
4
|
+
class IdentityComplianceConfig {
|
|
5
|
+
constructor(requireCivicPass = false, allowedCountries = []) {
|
|
6
|
+
this.requireCivicPass = requireCivicPass;
|
|
7
|
+
this.allowedCountries = allowedCountries;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.IdentityComplianceConfig = IdentityComplianceConfig;
|
|
11
|
+
class IdentityManager {
|
|
12
|
+
/**
|
|
13
|
+
* Checks if a transaction interacts with regulated protocols.
|
|
14
|
+
*
|
|
15
|
+
* @todo INTEGRATION REQUIRED: This method is a stub.
|
|
16
|
+
* Real implementation requires integration with:
|
|
17
|
+
* 1. Civic Gateway (Identity/KYC checks)
|
|
18
|
+
* 2. TRM Labs / Chainalysis (Sanctions Screening)
|
|
19
|
+
* 3. On-chain Allowlist Providers
|
|
20
|
+
*/
|
|
21
|
+
async checkCompliance(_tx, _config) {
|
|
22
|
+
const leaks = [];
|
|
23
|
+
// Example logic for "Mock" compliance violation
|
|
24
|
+
// In production, fetch sanctions list here.
|
|
25
|
+
return leaks;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Returns a list of integrations required to enable full compliance mode.
|
|
29
|
+
*/
|
|
30
|
+
getRequiredIntegrations() {
|
|
31
|
+
return [
|
|
32
|
+
"Civic Pass Gateway IDL",
|
|
33
|
+
"TRM Labs API Key",
|
|
34
|
+
"Chainalysis Risk API"
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generates a "Selective Disclosure" proof.
|
|
39
|
+
* @deprecated Stub implementation. Use @civic/solana-gateway-react for real proofs.
|
|
40
|
+
*/
|
|
41
|
+
generateDisclosure(_credentialType) {
|
|
42
|
+
return {
|
|
43
|
+
proof: "integration_required",
|
|
44
|
+
claim: "Identity integration pending"
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.IdentityManager = IdentityManager;
|
|
49
|
+
class MultisigMonitor {
|
|
50
|
+
async analyzeMultisigPrivacy(_multisigAddress) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.MultisigMonitor = MultisigMonitor;
|
|
55
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../sdk/compliance/identity.ts"],"names":[],"mappings":";;;AAEA,MAAa,wBAAwB;IACjC,YACW,mBAA4B,KAAK,EACjC,mBAA6B,EAAE;QAD/B,qBAAgB,GAAhB,gBAAgB,CAAiB;QACjC,qBAAgB,GAAhB,gBAAgB,CAAe;IACtC,CAAC;CACR;AALD,4DAKC;AAED,MAAa,eAAe;IAExB;;;;;;;;OAQG;IACI,KAAK,CAAC,eAAe,CAAC,GAAoB,EAAE,OAAiC;QAChF,MAAM,KAAK,GAAW,EAAE,CAAC;QAEzB,gDAAgD;QAChD,4CAA4C;QAE5C,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,uBAAuB;QAC1B,OAAO;YACH,wBAAwB;YACxB,kBAAkB;YAClB,sBAAsB;SACzB,CAAC;IACN,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,eAAuB;QAC7C,OAAO;YACH,KAAK,EAAE,sBAAsB;YAC7B,KAAK,EAAE,8BAA8B;SACxC,CAAC;IACN,CAAC;CACJ;AAzCD,0CAyCC;AAED,MAAa,eAAe;IACjB,KAAK,CAAC,sBAAsB,CAAC,gBAAwB;QACxD,OAAO,EAAE,CAAC;IACd,CAAC;CACJ;AAJD,0CAIC"}
|