dop-wallet-v6 1.3.35 → 1.3.36
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/services/dop/core/prover.js +50 -1
- package/dist/services/dop/core/prover.js.map +1 -1
- package/dist/services/dop/crypto/custom-prover.d.ts +78 -0
- package/dist/services/dop/crypto/custom-prover.js +78 -0
- package/dist/services/dop/crypto/custom-prover.js.map +1 -0
- package/dist/services/dop/crypto/index.d.ts +1 -0
- package/dist/services/dop/crypto/index.js +18 -0
- package/dist/services/dop/crypto/index.js.map +1 -0
- package/dist/services/dop/index.d.ts +1 -0
- package/dist/services/dop/index.js +1 -0
- package/dist/services/dop/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,12 +3,61 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getProver = void 0;
|
|
4
4
|
const engine_1 = require("./engine");
|
|
5
5
|
const dop_sharedmodels_v3_1 = require("dop-sharedmodels-v3");
|
|
6
|
+
const custom_prover_1 = require("../crypto/custom-prover");
|
|
7
|
+
/**
|
|
8
|
+
* Determines circuitId from formatted inputs
|
|
9
|
+
* DOP circuits are named like "3x2" (3 nullifiers, 2 commitments)
|
|
10
|
+
*/
|
|
11
|
+
function getCircuitIdFromInputs(formattedInputs) {
|
|
12
|
+
// Count nullifiers (non-zero entries)
|
|
13
|
+
const nullifierCount = formattedInputs.nullifiers?.filter((n) => n !== undefined && n !== null && BigInt(n) !== BigInt(0)).length || 0;
|
|
14
|
+
// Count commitments (non-zero entries)
|
|
15
|
+
const commitmentCount = formattedInputs.commitmentsOut?.filter((c) => c !== undefined && c !== null && BigInt(c) !== BigInt(0)).length || 0;
|
|
16
|
+
return `${nullifierCount}x${commitmentCount}`;
|
|
17
|
+
}
|
|
18
|
+
let proverIntercepted = false;
|
|
6
19
|
const getProver = () => {
|
|
7
20
|
const engine = (0, engine_1.getEngine)();
|
|
8
21
|
if (!(0, dop_sharedmodels_v3_1.isDefined)(engine)) {
|
|
9
22
|
throw new Error('DOP Engine not yet init. Please reload your app or try again.');
|
|
10
23
|
}
|
|
11
|
-
|
|
24
|
+
const prover = engine.prover;
|
|
25
|
+
// Intercept groth16.fullProveDop only once
|
|
26
|
+
if (!proverIntercepted && prover.groth16) {
|
|
27
|
+
proverIntercepted = true;
|
|
28
|
+
const originalFullProveDop = prover.groth16.fullProveDop;
|
|
29
|
+
// Wrap fullProveDop to check for custom prover
|
|
30
|
+
prover.groth16.fullProveDop = async (formattedInputs, wasm, zkey, logger, dat, progressCallback) => {
|
|
31
|
+
// Check if custom prover is available
|
|
32
|
+
if ((0, custom_prover_1.hasCustomRapidsnarkProver)()) {
|
|
33
|
+
const customProver = (0, custom_prover_1.getCustomRapidsnarkProver)();
|
|
34
|
+
if (!customProver) {
|
|
35
|
+
throw new Error('Custom prover is null');
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
// Determine circuit ID from inputs
|
|
39
|
+
const circuitId = getCircuitIdFromInputs(formattedInputs);
|
|
40
|
+
logger.debug(`[Custom Prover] Using custom prover for circuit ${circuitId}`);
|
|
41
|
+
// Call custom prover (e.g., backend server)
|
|
42
|
+
const proof = await customProver.generateProof(circuitId, new Uint8Array(zkey), formattedInputs, progressCallback);
|
|
43
|
+
logger.debug(`[Custom Prover] Proof generated successfully via custom prover`);
|
|
44
|
+
// Return in expected format
|
|
45
|
+
return {
|
|
46
|
+
proof,
|
|
47
|
+
publicSignals: proof.publicSignals ?? []
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
52
|
+
logger.debug(`[Custom Prover] Error: ${errorMessage}`);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// No custom prover - use original implementation
|
|
57
|
+
return originalFullProveDop(formattedInputs, wasm, zkey, logger, dat, progressCallback);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return prover;
|
|
12
61
|
};
|
|
13
62
|
exports.getProver = getProver;
|
|
14
63
|
//# sourceMappingURL=prover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prover.js","sourceRoot":"","sources":["../../../../src/services/dop/core/prover.ts"],"names":[],"mappings":";;;AAMA,qCAAqC;AACrC,6DAAgD;
|
|
1
|
+
{"version":3,"file":"prover.js","sourceRoot":"","sources":["../../../../src/services/dop/core/prover.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n FormattedCircuitInputsDop,\n SnarkJSGroth16,\n Proof,\n Prover,\n} from 'dop-engine-v3';\nimport { getEngine } from './engine';\nimport { isDefined } from 'dop-sharedmodels-v3';\nimport { \n hasCustomRapidsnarkProver, \n getCustomRapidsnarkProver \n} from '../crypto/custom-prover';\n\ntype ProverProgressCallback = (progress: number) => void;\n\n/**\n * Determines circuitId from formatted inputs\n * DOP circuits are named like \"3x2\" (3 nullifiers, 2 commitments)\n */\nfunction getCircuitIdFromInputs(formattedInputs: FormattedCircuitInputsDop): string {\n // Count nullifiers (non-zero entries)\n const nullifierCount = formattedInputs.nullifiers?.filter(\n (n: any) => n !== undefined && n !== null && BigInt(n) !== BigInt(0)\n ).length || 0;\n \n // Count commitments (non-zero entries)\n const commitmentCount = formattedInputs.commitmentsOut?.filter(\n (c: any) => c !== undefined && c !== null && BigInt(c) !== BigInt(0)\n ).length || 0;\n \n return `${nullifierCount}x${commitmentCount}`;\n}\n\nlet proverIntercepted = false;\n\nexport const getProver = (): Prover => {\n const engine = getEngine();\n if (!isDefined(engine)) {\n throw new Error(\n 'DOP Engine not yet init. Please reload your app or try again.',\n );\n }\n \n const prover = engine.prover;\n \n // Intercept groth16.fullProveDop only once\n if (!proverIntercepted && prover.groth16) {\n proverIntercepted = true;\n \n const originalFullProveDop = prover.groth16.fullProveDop;\n \n // Wrap fullProveDop to check for custom prover\n prover.groth16.fullProveDop = async (\n formattedInputs: FormattedCircuitInputsDop,\n wasm: any,\n zkey: ArrayLike<number>,\n logger: { debug: (log: string) => void },\n dat: any,\n progressCallback: ProverProgressCallback\n ) => {\n // Check if custom prover is available\n if (hasCustomRapidsnarkProver()) {\n const customProver = getCustomRapidsnarkProver();\n \n if (!customProver) {\n throw new Error('Custom prover is null');\n }\n \n try {\n // Determine circuit ID from inputs\n const circuitId = getCircuitIdFromInputs(formattedInputs);\n \n logger.debug(`[Custom Prover] Using custom prover for circuit ${circuitId}`);\n \n // Call custom prover (e.g., backend server)\n const proof = await customProver.generateProof(\n circuitId,\n new Uint8Array(zkey),\n formattedInputs,\n progressCallback\n );\n \n logger.debug(`[Custom Prover] Proof generated successfully via custom prover`);\n \n // Return in expected format\n return {\n proof,\n publicSignals: (proof as any).publicSignals ?? []\n };\n } catch (error: unknown) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n logger.debug(`[Custom Prover] Error: ${errorMessage}`);\n throw error;\n }\n }\n \n // No custom prover - use original implementation\n return originalFullProveDop(\n formattedInputs,\n wasm,\n zkey,\n logger,\n dat,\n progressCallback\n );\n };\n }\n \n return prover;\n};\n\nexport { FormattedCircuitInputsDop, Proof, SnarkJSGroth16 };\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Prover Hook
|
|
3
|
+
*
|
|
4
|
+
* Allows applications (especially React Native) to provide their own proof generation
|
|
5
|
+
* implementation, such as a backend server prover instead of local proving.
|
|
6
|
+
*/
|
|
7
|
+
import { FormattedCircuitInputsDop, Proof } from 'dop-engine-v3';
|
|
8
|
+
/**
|
|
9
|
+
* Custom prover interface that applications can implement
|
|
10
|
+
*
|
|
11
|
+
* Example: Backend server prover for React Native that offloads
|
|
12
|
+
* heavy ZK proof computation to a remote server
|
|
13
|
+
*/
|
|
14
|
+
export interface UserRapidsnarkProver {
|
|
15
|
+
/**
|
|
16
|
+
* Generate a ZK proof for the given circuit and inputs
|
|
17
|
+
*
|
|
18
|
+
* @param circuitId - Circuit identifier (e.g., "3x2" for 3 nullifiers, 2 commitments)
|
|
19
|
+
* @param zkeyBuffer - Circuit zkey file content (may not be needed for backend provers)
|
|
20
|
+
* @param jsonInputs - Formatted circuit inputs (auto-generated by DOP Engine)
|
|
21
|
+
* @param progressCallback - Optional callback for progress updates (0-100)
|
|
22
|
+
* @returns Promise resolving to proof object with pi_a, pi_b, pi_c, and publicSignals
|
|
23
|
+
*/
|
|
24
|
+
generateProof(circuitId: string, zkeyBuffer: Uint8Array, jsonInputs: FormattedCircuitInputsDop, progressCallback?: (progress: number) => void): Promise<Proof>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Set a custom proof generator
|
|
28
|
+
*
|
|
29
|
+
* This allows applications to provide their own proof generation implementation.
|
|
30
|
+
* Common use case: React Native apps using a backend server for proof generation
|
|
31
|
+
* instead of local proving.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Backend prover for React Native
|
|
36
|
+
* const backendProver: UserRapidsnarkProver = {
|
|
37
|
+
* async generateProof(circuitId, zkeyBuffer, jsonInputs, progressCallback) {
|
|
38
|
+
* const response = await fetch('https://your-server.com/api/generate-proof', {
|
|
39
|
+
* method: 'POST',
|
|
40
|
+
* headers: {
|
|
41
|
+
* 'Authorization': 'Bearer YOUR_TOKEN',
|
|
42
|
+
* 'Content-Type': 'application/json',
|
|
43
|
+
* },
|
|
44
|
+
* body: JSON.stringify({
|
|
45
|
+
* circuitId,
|
|
46
|
+
* inputs: jsonInputs,
|
|
47
|
+
* }),
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* const result = await response.json();
|
|
51
|
+
* return {
|
|
52
|
+
* pi_a: result.proof.pi_a,
|
|
53
|
+
* pi_b: result.proof.pi_b,
|
|
54
|
+
* pi_c: result.proof.pi_c,
|
|
55
|
+
* publicSignals: result.publicSignals,
|
|
56
|
+
* };
|
|
57
|
+
* },
|
|
58
|
+
* };
|
|
59
|
+
*
|
|
60
|
+
* // Set it after DOP Engine initialization
|
|
61
|
+
* setCustomRapidsnarkProver(backendProver);
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param prover - Custom prover implementation or null to clear
|
|
65
|
+
*/
|
|
66
|
+
export declare const setCustomRapidsnarkProver: (prover: UserRapidsnarkProver | null) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Get the currently registered custom prover
|
|
69
|
+
*
|
|
70
|
+
* @returns Custom prover if set, null otherwise
|
|
71
|
+
*/
|
|
72
|
+
export declare const getCustomRapidsnarkProver: () => UserRapidsnarkProver | null;
|
|
73
|
+
/**
|
|
74
|
+
* Check if a custom prover is currently registered
|
|
75
|
+
*
|
|
76
|
+
* @returns True if custom prover is set, false otherwise
|
|
77
|
+
*/
|
|
78
|
+
export declare const hasCustomRapidsnarkProver: () => boolean;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Custom Prover Hook
|
|
4
|
+
*
|
|
5
|
+
* Allows applications (especially React Native) to provide their own proof generation
|
|
6
|
+
* implementation, such as a backend server prover instead of local proving.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.hasCustomRapidsnarkProver = exports.getCustomRapidsnarkProver = exports.setCustomRapidsnarkProver = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* Global custom prover storage
|
|
12
|
+
* Set this via setCustomRapidsnarkProver()
|
|
13
|
+
*/
|
|
14
|
+
let customProver = null;
|
|
15
|
+
/**
|
|
16
|
+
* Set a custom proof generator
|
|
17
|
+
*
|
|
18
|
+
* This allows applications to provide their own proof generation implementation.
|
|
19
|
+
* Common use case: React Native apps using a backend server for proof generation
|
|
20
|
+
* instead of local proving.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // Backend prover for React Native
|
|
25
|
+
* const backendProver: UserRapidsnarkProver = {
|
|
26
|
+
* async generateProof(circuitId, zkeyBuffer, jsonInputs, progressCallback) {
|
|
27
|
+
* const response = await fetch('https://your-server.com/api/generate-proof', {
|
|
28
|
+
* method: 'POST',
|
|
29
|
+
* headers: {
|
|
30
|
+
* 'Authorization': 'Bearer YOUR_TOKEN',
|
|
31
|
+
* 'Content-Type': 'application/json',
|
|
32
|
+
* },
|
|
33
|
+
* body: JSON.stringify({
|
|
34
|
+
* circuitId,
|
|
35
|
+
* inputs: jsonInputs,
|
|
36
|
+
* }),
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* const result = await response.json();
|
|
40
|
+
* return {
|
|
41
|
+
* pi_a: result.proof.pi_a,
|
|
42
|
+
* pi_b: result.proof.pi_b,
|
|
43
|
+
* pi_c: result.proof.pi_c,
|
|
44
|
+
* publicSignals: result.publicSignals,
|
|
45
|
+
* };
|
|
46
|
+
* },
|
|
47
|
+
* };
|
|
48
|
+
*
|
|
49
|
+
* // Set it after DOP Engine initialization
|
|
50
|
+
* setCustomRapidsnarkProver(backendProver);
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @param prover - Custom prover implementation or null to clear
|
|
54
|
+
*/
|
|
55
|
+
const setCustomRapidsnarkProver = (prover) => {
|
|
56
|
+
customProver = prover;
|
|
57
|
+
console.log(prover ? '✅ Custom prover registered' : '🔄 Custom prover cleared');
|
|
58
|
+
};
|
|
59
|
+
exports.setCustomRapidsnarkProver = setCustomRapidsnarkProver;
|
|
60
|
+
/**
|
|
61
|
+
* Get the currently registered custom prover
|
|
62
|
+
*
|
|
63
|
+
* @returns Custom prover if set, null otherwise
|
|
64
|
+
*/
|
|
65
|
+
const getCustomRapidsnarkProver = () => {
|
|
66
|
+
return customProver;
|
|
67
|
+
};
|
|
68
|
+
exports.getCustomRapidsnarkProver = getCustomRapidsnarkProver;
|
|
69
|
+
/**
|
|
70
|
+
* Check if a custom prover is currently registered
|
|
71
|
+
*
|
|
72
|
+
* @returns True if custom prover is set, false otherwise
|
|
73
|
+
*/
|
|
74
|
+
const hasCustomRapidsnarkProver = () => {
|
|
75
|
+
return customProver !== null;
|
|
76
|
+
};
|
|
77
|
+
exports.hasCustomRapidsnarkProver = hasCustomRapidsnarkProver;
|
|
78
|
+
//# sourceMappingURL=custom-prover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-prover.js","sourceRoot":"","sources":["../../../../src/services/dop/crypto/custom-prover.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA4BH;;;GAGG;AACH,IAAI,YAAY,GAAgC,IAAI,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACI,MAAM,yBAAyB,GAAG,CAAC,MAAmC,EAAQ,EAAE;IACrF,YAAY,GAAG,MAAM,CAAC;IACtB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC;AAClF,CAAC,CAAC;AAHW,QAAA,yBAAyB,6BAGpC;AAEF;;;;GAIG;AACI,MAAM,yBAAyB,GAAG,GAAgC,EAAE;IACzE,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAFW,QAAA,yBAAyB,6BAEpC;AAEF;;;;GAIG;AACI,MAAM,yBAAyB,GAAG,GAAY,EAAE;IACrD,OAAO,YAAY,KAAK,IAAI,CAAC;AAC/B,CAAC,CAAC;AAFW,QAAA,yBAAyB,6BAEpC","sourcesContent":["/**\n * Custom Prover Hook\n * \n * Allows applications (especially React Native) to provide their own proof generation\n * implementation, such as a backend server prover instead of local proving.\n */\n\nimport { FormattedCircuitInputsDop, Proof } from 'dop-engine-v3';\n\n/**\n * Custom prover interface that applications can implement\n * \n * Example: Backend server prover for React Native that offloads\n * heavy ZK proof computation to a remote server\n */\nexport interface UserRapidsnarkProver {\n /**\n * Generate a ZK proof for the given circuit and inputs\n * \n * @param circuitId - Circuit identifier (e.g., \"3x2\" for 3 nullifiers, 2 commitments)\n * @param zkeyBuffer - Circuit zkey file content (may not be needed for backend provers)\n * @param jsonInputs - Formatted circuit inputs (auto-generated by DOP Engine)\n * @param progressCallback - Optional callback for progress updates (0-100)\n * @returns Promise resolving to proof object with pi_a, pi_b, pi_c, and publicSignals\n */\n generateProof(\n circuitId: string,\n zkeyBuffer: Uint8Array,\n jsonInputs: FormattedCircuitInputsDop,\n progressCallback?: (progress: number) => void\n ): Promise<Proof>;\n}\n\n/**\n * Global custom prover storage\n * Set this via setCustomRapidsnarkProver()\n */\nlet customProver: UserRapidsnarkProver | null = null;\n\n/**\n * Set a custom proof generator\n * \n * This allows applications to provide their own proof generation implementation.\n * Common use case: React Native apps using a backend server for proof generation\n * instead of local proving.\n * \n * @example\n * ```typescript\n * // Backend prover for React Native\n * const backendProver: UserRapidsnarkProver = {\n * async generateProof(circuitId, zkeyBuffer, jsonInputs, progressCallback) {\n * const response = await fetch('https://your-server.com/api/generate-proof', {\n * method: 'POST',\n * headers: {\n * 'Authorization': 'Bearer YOUR_TOKEN',\n * 'Content-Type': 'application/json',\n * },\n * body: JSON.stringify({\n * circuitId,\n * inputs: jsonInputs,\n * }),\n * });\n * \n * const result = await response.json();\n * return {\n * pi_a: result.proof.pi_a,\n * pi_b: result.proof.pi_b,\n * pi_c: result.proof.pi_c,\n * publicSignals: result.publicSignals,\n * };\n * },\n * };\n * \n * // Set it after DOP Engine initialization\n * setCustomRapidsnarkProver(backendProver);\n * ```\n * \n * @param prover - Custom prover implementation or null to clear\n */\nexport const setCustomRapidsnarkProver = (prover: UserRapidsnarkProver | null): void => {\n customProver = prover;\n console.log(prover ? '✅ Custom prover registered' : '🔄 Custom prover cleared');\n};\n\n/**\n * Get the currently registered custom prover\n * \n * @returns Custom prover if set, null otherwise\n */\nexport const getCustomRapidsnarkProver = (): UserRapidsnarkProver | null => {\n return customProver;\n};\n\n/**\n * Check if a custom prover is currently registered\n * \n * @returns True if custom prover is set, false otherwise\n */\nexport const hasCustomRapidsnarkProver = (): boolean => {\n return customProver !== null;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './custom-prover';
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./custom-prover"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/dop/crypto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC","sourcesContent":["export * from './custom-prover';\n"]}
|
|
@@ -20,4 +20,5 @@ __exportStar(require("./dop-txids"), exports);
|
|
|
20
20
|
__exportStar(require("./wallets"), exports);
|
|
21
21
|
__exportStar(require("./process"), exports);
|
|
22
22
|
__exportStar(require("./profile"), exports);
|
|
23
|
+
__exportStar(require("./crypto"), exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/dop/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,4CAA0B;AAC1B,4CAA0B","sourcesContent":["export * from './core';\nexport * from './util';\nexport * from './dop-txids';\nexport * from './wallets';\nexport * from './process';\nexport * from './profile';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/dop/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,4CAA0B;AAC1B,4CAA0B;AAC1B,2CAAyB","sourcesContent":["export * from './core';\nexport * from './util';\nexport * from './dop-txids';\nexport * from './wallets';\nexport * from './process';\nexport * from './profile';\nexport * from './crypto';\n"]}
|