dero-mcp-server 0.1.2 → 0.4.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/POSITIONING.md +94 -0
- package/README.md +132 -31
- package/SKILL.md +264 -0
- package/data/docs-index.json +276 -264
- package/dist/bn254.d.ts +74 -0
- package/dist/bn254.d.ts.map +1 -0
- package/dist/bn254.js +205 -0
- package/dist/bn254.js.map +1 -0
- package/dist/citations.d.ts +140 -0
- package/dist/citations.d.ts.map +1 -0
- package/dist/citations.js +322 -0
- package/dist/citations.js.map +1 -0
- package/dist/composites/_shared.d.ts +119 -0
- package/dist/composites/_shared.d.ts.map +1 -0
- package/dist/composites/_shared.js +152 -0
- package/dist/composites/_shared.js.map +1 -0
- package/dist/composites/audit-chain-artifact-claim.d.ts +128 -0
- package/dist/composites/audit-chain-artifact-claim.d.ts.map +1 -0
- package/dist/composites/audit-chain-artifact-claim.js +305 -0
- package/dist/composites/audit-chain-artifact-claim.js.map +1 -0
- package/dist/composites/diagnose-chain-health.d.ts +64 -0
- package/dist/composites/diagnose-chain-health.d.ts.map +1 -0
- package/dist/composites/diagnose-chain-health.js +144 -0
- package/dist/composites/diagnose-chain-health.js.map +1 -0
- package/dist/composites/estimate-deploy-cost.d.ts +83 -0
- package/dist/composites/estimate-deploy-cost.d.ts.map +1 -0
- package/dist/composites/estimate-deploy-cost.js +116 -0
- package/dist/composites/estimate-deploy-cost.js.map +1 -0
- package/dist/composites/explain-smart-contract.d.ts +64 -0
- package/dist/composites/explain-smart-contract.d.ts.map +1 -0
- package/dist/composites/explain-smart-contract.js +149 -0
- package/dist/composites/explain-smart-contract.js.map +1 -0
- package/dist/composites/forge-demo-proof.d.ts +81 -0
- package/dist/composites/forge-demo-proof.d.ts.map +1 -0
- package/dist/composites/forge-demo-proof.js +204 -0
- package/dist/composites/forge-demo-proof.js.map +1 -0
- package/dist/composites/recommend-docs-path.d.ts +97 -0
- package/dist/composites/recommend-docs-path.d.ts.map +1 -0
- package/dist/composites/recommend-docs-path.js +149 -0
- package/dist/composites/recommend-docs-path.js.map +1 -0
- package/dist/composites/trace-transaction-with-context.d.ts +107 -0
- package/dist/composites/trace-transaction-with-context.d.ts.map +1 -0
- package/dist/composites/trace-transaction-with-context.js +217 -0
- package/dist/composites/trace-transaction-with-context.js.map +1 -0
- package/dist/daemon-base.d.ts +28 -0
- package/dist/daemon-base.d.ts.map +1 -0
- package/dist/daemon-base.js +62 -0
- package/dist/daemon-base.js.map +1 -0
- package/dist/dero-curve.d.ts +79 -0
- package/dist/dero-curve.d.ts.map +1 -0
- package/dist/dero-curve.js +79 -0
- package/dist/dero-curve.js.map +1 -0
- package/dist/docs-parse.d.ts.map +1 -1
- package/dist/docs-parse.js +18 -2
- package/dist/docs-parse.js.map +1 -1
- package/dist/http-server.d.ts +37 -0
- package/dist/http-server.d.ts.map +1 -0
- package/dist/http-server.js +132 -0
- package/dist/http-server.js.map +1 -0
- package/dist/index.js +18 -11
- package/dist/index.js.map +1 -1
- package/dist/proof-decode.d.ts +125 -0
- package/dist/proof-decode.d.ts.map +1 -0
- package/dist/proof-decode.js +619 -0
- package/dist/proof-decode.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +414 -114
- package/dist/server.js.map +1 -1
- package/dist/tool-descriptions.d.ts +53 -0
- package/dist/tool-descriptions.d.ts.map +1 -0
- package/dist/tool-descriptions.js +285 -0
- package/dist/tool-descriptions.js.map +1 -0
- package/dist/tx-parse.d.ts +63 -0
- package/dist/tx-parse.d.ts.map +1 -0
- package/dist/tx-parse.js +183 -0
- package/dist/tx-parse.js.map +1 -0
- package/package.json +27 -2
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streamable HTTP transport entry for dero-mcp-server.
|
|
3
|
+
*
|
|
4
|
+
* Same factory (`createDeroMcpServer`) as the stdio entry — just a
|
|
5
|
+
* different transport on top. Enable via `dero-mcp-server --http`
|
|
6
|
+
* or `DERO_MCP_HTTP=1` (see index.ts dispatcher).
|
|
7
|
+
*
|
|
8
|
+
* Stateless by design: each request is independent. No session
|
|
9
|
+
* tracking, no in-memory state across requests, no logs of query
|
|
10
|
+
* payloads. Pairs cleanly with read-only semantics and the
|
|
11
|
+
* privacy-first brand.
|
|
12
|
+
*
|
|
13
|
+
* Environment:
|
|
14
|
+
* DERO_DAEMON_URL — JSON-RPC base. If unset, resolves local-first:
|
|
15
|
+
* a local derod (127.0.0.1:10102) if reachable,
|
|
16
|
+
* else the baked-in public fallback.
|
|
17
|
+
* DERO_MCP_HTTP_PORT — listen port (default: 8787)
|
|
18
|
+
* DERO_MCP_HTTP_HOST — listen address (default: 127.0.0.1)
|
|
19
|
+
* DERO_MCP_AUTH_TOKEN — if set, require `Authorization: Bearer <token>`
|
|
20
|
+
* on /mcp. Constant-time compared. Recommended
|
|
21
|
+
* when binding to a public address; required
|
|
22
|
+
* if behind a reverse proxy without its own auth.
|
|
23
|
+
*
|
|
24
|
+
* Routes:
|
|
25
|
+
* POST /mcp — MCP streamable HTTP endpoint
|
|
26
|
+
* GET /mcp — same (SSE compat for older clients)
|
|
27
|
+
* GET /health — health check {status, version, daemon_url, daemon_source}
|
|
28
|
+
* anything else → 404
|
|
29
|
+
*
|
|
30
|
+
* Reverse-proxy expectations:
|
|
31
|
+
* - TLS handled upstream (Caddy / Cloudflare / etc.) — this server is
|
|
32
|
+
* plain HTTP.
|
|
33
|
+
* - Original client IP can be passed via X-Forwarded-For for logging;
|
|
34
|
+
* we don't log IPs by default but the middleware reads it if present.
|
|
35
|
+
*/
|
|
36
|
+
import http from 'node:http';
|
|
37
|
+
import { Buffer } from 'node:buffer';
|
|
38
|
+
import { timingSafeEqual } from 'node:crypto';
|
|
39
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
40
|
+
import { createDeroMcpServer } from './server.js';
|
|
41
|
+
import { resolveDaemonBase, describeDaemonResolution } from './daemon-base.js';
|
|
42
|
+
const PACKAGE_VERSION = '0.4.0';
|
|
43
|
+
function readEnv() {
|
|
44
|
+
const port = Number.parseInt(process.env.DERO_MCP_HTTP_PORT ?? '8787', 10);
|
|
45
|
+
const host = process.env.DERO_MCP_HTTP_HOST ?? '127.0.0.1';
|
|
46
|
+
const authToken = process.env.DERO_MCP_AUTH_TOKEN?.trim() || undefined;
|
|
47
|
+
return { port, host, authToken };
|
|
48
|
+
}
|
|
49
|
+
function isAuthorized(req, expectedToken) {
|
|
50
|
+
const header = req.headers['authorization'];
|
|
51
|
+
if (!header || Array.isArray(header))
|
|
52
|
+
return false;
|
|
53
|
+
const m = header.match(/^Bearer\s+(.+)$/i);
|
|
54
|
+
if (!m)
|
|
55
|
+
return false;
|
|
56
|
+
const given = m[1].trim();
|
|
57
|
+
const a = Buffer.from(given);
|
|
58
|
+
const b = Buffer.from(expectedToken);
|
|
59
|
+
if (a.length !== b.length)
|
|
60
|
+
return false;
|
|
61
|
+
return timingSafeEqual(a, b);
|
|
62
|
+
}
|
|
63
|
+
function send(res, status, body, contentType = 'application/json') {
|
|
64
|
+
res.writeHead(status, {
|
|
65
|
+
'content-type': contentType,
|
|
66
|
+
'content-length': Buffer.byteLength(body),
|
|
67
|
+
});
|
|
68
|
+
res.end(body);
|
|
69
|
+
}
|
|
70
|
+
export async function startHttpServer() {
|
|
71
|
+
const { port, host, authToken } = readEnv();
|
|
72
|
+
const resolution = await resolveDaemonBase();
|
|
73
|
+
const daemonUrl = resolution.base;
|
|
74
|
+
const mcpServer = createDeroMcpServer(daemonUrl);
|
|
75
|
+
// Stateless mode: no session IDs, no in-memory state across requests.
|
|
76
|
+
// Fits read-only semantics and minimizes the privacy surface.
|
|
77
|
+
const transport = new StreamableHTTPServerTransport({
|
|
78
|
+
sessionIdGenerator: undefined,
|
|
79
|
+
});
|
|
80
|
+
await mcpServer.connect(transport);
|
|
81
|
+
const httpServer = http.createServer(async (req, res) => {
|
|
82
|
+
const url = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`);
|
|
83
|
+
if (url.pathname === '/health' && req.method === 'GET') {
|
|
84
|
+
send(res, 200, JSON.stringify({
|
|
85
|
+
status: 'ok',
|
|
86
|
+
name: 'dero-daemon-mcp',
|
|
87
|
+
version: PACKAGE_VERSION,
|
|
88
|
+
transport: 'streamable-http',
|
|
89
|
+
daemon_url: daemonUrl,
|
|
90
|
+
daemon_source: resolution.source,
|
|
91
|
+
}));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (url.pathname !== '/mcp') {
|
|
95
|
+
send(res, 404, JSON.stringify({ error: 'not_found', message: 'See /mcp for the MCP endpoint, /health for status.' }));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// Auth (optional but recommended). When DERO_MCP_AUTH_TOKEN is set,
|
|
99
|
+
// every /mcp request must carry Authorization: Bearer <token>.
|
|
100
|
+
if (authToken && !isAuthorized(req, authToken)) {
|
|
101
|
+
res.setHeader('www-authenticate', 'Bearer realm="dero-mcp"');
|
|
102
|
+
send(res, 401, JSON.stringify({ error: 'unauthorized' }));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
await transport.handleRequest(req, res);
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
110
|
+
process.stderr.write(`[dero-mcp-server] http handler error: ${message}\n`);
|
|
111
|
+
if (!res.headersSent) {
|
|
112
|
+
send(res, 500, JSON.stringify({ error: 'internal_error' }));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
await new Promise((resolve) => {
|
|
117
|
+
httpServer.listen(port, host, () => {
|
|
118
|
+
process.stderr.write(`[dero-mcp-server] HTTP listening on ${host}:${port} (POST /mcp · GET /health)\n`);
|
|
119
|
+
process.stderr.write(`[dero-mcp-server] ${describeDaemonResolution(resolution)} · auth: ${authToken ? 'bearer required' : 'none (do not expose publicly)'}\n`);
|
|
120
|
+
resolve();
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
const shutdown = (signal) => {
|
|
124
|
+
process.stderr.write(`[dero-mcp-server] ${signal} received, shutting down\n`);
|
|
125
|
+
httpServer.close(() => process.exit(0));
|
|
126
|
+
// Hard exit after 5s if connections won't drain.
|
|
127
|
+
setTimeout(() => process.exit(1), 5000).unref();
|
|
128
|
+
};
|
|
129
|
+
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
130
|
+
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=http-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-server.js","sourceRoot":"","sources":["../src/http-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAA;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAE9E,MAAM,eAAe,GAAG,OAAO,CAAA;AAE/B,SAAS,OAAO;IACd,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,MAAM,EAAE,EAAE,CAAC,CAAA;IAC1E,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,WAAW,CAAA;IAC1D,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,IAAI,EAAE,IAAI,SAAS,CAAA;IACtE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;AACl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,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;QACvC,iDAAiD;QACjD,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,CAAA;IACjD,CAAC,CAAA;IACD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAA;IAChD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAA;AAChD,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
3
|
import { createDeroMcpServer } from './server.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return
|
|
4
|
+
import { startHttpServer } from './http-server.js';
|
|
5
|
+
import { resolveDaemonBase, describeDaemonResolution } from './daemon-base.js';
|
|
6
|
+
function isHttpMode() {
|
|
7
|
+
if (process.argv.includes('--http'))
|
|
8
|
+
return true;
|
|
9
|
+
const env = process.env.DERO_MCP_HTTP?.trim().toLowerCase();
|
|
10
|
+
return env === '1' || env === 'true' || env === 'yes';
|
|
11
11
|
}
|
|
12
|
-
async function
|
|
13
|
-
const
|
|
14
|
-
const server = createDeroMcpServer(base);
|
|
12
|
+
async function runStdio() {
|
|
13
|
+
const resolution = await resolveDaemonBase();
|
|
14
|
+
const server = createDeroMcpServer(resolution.base);
|
|
15
15
|
const transport = new StdioServerTransport();
|
|
16
|
-
process.stderr.write(`[dero-mcp-server]
|
|
16
|
+
process.stderr.write(`[dero-mcp-server] stdio · ${describeDaemonResolution(resolution)}\n`);
|
|
17
17
|
await server.connect(transport);
|
|
18
18
|
}
|
|
19
|
+
async function main() {
|
|
20
|
+
if (isHttpMode()) {
|
|
21
|
+
await startHttpServer();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
await runStdio();
|
|
25
|
+
}
|
|
19
26
|
main().catch((err) => {
|
|
20
27
|
process.stderr.write(`[dero-mcp-server] fatal: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
21
28
|
process.exit(1);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAE9E,SAAS,UAAU;IACjB,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAA;IAChD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IAC3D,OAAO,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,KAAK,CAAA;AACvD,CAAC;AAED,KAAK,UAAU,QAAQ;IACrB,MAAM,UAAU,GAAG,MAAM,iBAAiB,EAAE,CAAA;IAC5C,MAAM,MAAM,GAAG,mBAAmB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACnD,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAA;IAE5C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,wBAAwB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IAE3F,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AACjC,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,IAAI,UAAU,EAAE,EAAE,CAAC;QACjB,MAAM,eAAe,EAAE,CAAA;QACvB,OAAM;IACR,CAAC;IACD,MAAM,QAAQ,EAAE,CAAA;AAClB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACtG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decoder for DERO `deroproof…` / `dero…` / `deroi…` / `deto…` / `detoi…` bech32 strings.
|
|
3
|
+
*
|
|
4
|
+
* Implements the same wire format as `rpc/address.go` + `rpc/rpc.go` in DEROHE:
|
|
5
|
+
*
|
|
6
|
+
* bech32 → convertbits(5→8, no pad) → version byte (=1) → 33-byte compressed point
|
|
7
|
+
* → optional CBOR map of arguments (only present for HRPs `deroi`, `detoi`, `deroproof`).
|
|
8
|
+
*
|
|
9
|
+
* The CBOR map keys are `Name + DataType` ASCII strings (e.g. `"VU"` for
|
|
10
|
+
* `RPC_VALUE_TRANSFER` + `DataUint64`). Values are typed CBOR primitives.
|
|
11
|
+
*
|
|
12
|
+
* No new npm dependencies — bech32 + the minimum-needed CBOR subset are hand-rolled
|
|
13
|
+
* (~zero kB install delta for the MCP server, which is published for `npx` use).
|
|
14
|
+
*
|
|
15
|
+
* Verified against the publicly-cited 2022 inflation-claim proof string:
|
|
16
|
+
* embedded `uint64` = 18446743853709551435 = signed -2,200,000.00181 DERO.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Decode a bech32 string. Throws on invalid input.
|
|
20
|
+
* Returns `{ hrp, data }` where data is the 5-bit values WITHOUT the 6-byte checksum.
|
|
21
|
+
*/
|
|
22
|
+
export declare function bech32Decode(input: string): {
|
|
23
|
+
hrp: string;
|
|
24
|
+
data: number[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Repack a bit-stream from `fromBits` to `toBits`. Mirrors DEROHE's `convertbits`
|
|
28
|
+
* (in turn from BIP-0173 reference impl).
|
|
29
|
+
*/
|
|
30
|
+
export declare function convertBits(data: readonly number[], fromBits: number, toBits: number, pad: boolean): number[];
|
|
31
|
+
export declare function cborDecode(bytes: Uint8Array): unknown;
|
|
32
|
+
/** DERO argument data-type single-char suffix. */
|
|
33
|
+
export type DeroDataType = 'I' | 'U' | 'S' | 'H' | 'A' | 'F' | 'T';
|
|
34
|
+
export type ParsedArgument = {
|
|
35
|
+
name: string;
|
|
36
|
+
type: DeroDataType;
|
|
37
|
+
type_label: string;
|
|
38
|
+
/** Human-readable name when the convention is known. */
|
|
39
|
+
semantic_name?: string;
|
|
40
|
+
/** Decoded value (uint64/int64/hash → bigint or hex; address → bech32; string → string; bool → boolean). */
|
|
41
|
+
value: unknown;
|
|
42
|
+
};
|
|
43
|
+
export type DecodedAddress = {
|
|
44
|
+
hrp: 'dero' | 'deto' | 'deroi' | 'detoi' | 'deroproof';
|
|
45
|
+
mainnet: boolean;
|
|
46
|
+
/** True when HRP === 'deroproof' — payload key is a derived blinder point, NOT a wallet pubkey. */
|
|
47
|
+
is_proof: boolean;
|
|
48
|
+
/** Compressed-point bytes, lowercase hex. */
|
|
49
|
+
public_key_hex: string;
|
|
50
|
+
/** All decoded arguments (empty for plain `dero`/`deto`). */
|
|
51
|
+
arguments: ParsedArgument[];
|
|
52
|
+
/** Convenience: the RPC_VALUE_TRANSFER uint64 if present, else undefined. */
|
|
53
|
+
value_transfer_uint64?: bigint;
|
|
54
|
+
};
|
|
55
|
+
export type ValueInterpretation = {
|
|
56
|
+
uint64: string;
|
|
57
|
+
signed_int64: string;
|
|
58
|
+
/** True when interpreted as signed int64, the value is negative. */
|
|
59
|
+
is_negative_wraparound: boolean;
|
|
60
|
+
/** Atomic units (signed). 1 DERO = 100,000 atomic. */
|
|
61
|
+
signed_atoms: string;
|
|
62
|
+
/** DERO float (signed_atoms / 100_000) as a string with 5 fractional digits. */
|
|
63
|
+
dero: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Interpret a uint64 transfer value as both unsigned and signed-wraparound.
|
|
67
|
+
*
|
|
68
|
+
* DERO transfer amounts are stored as `uint64` atomic units (1 DERO = 100,000 atoms).
|
|
69
|
+
* A "negative" transfer is the wraparound of a huge unsigned value; this helper
|
|
70
|
+
* surfaces both views without taking a position on which is "correct" — that's
|
|
71
|
+
* what the cited rebuttal docs are for.
|
|
72
|
+
*/
|
|
73
|
+
export declare function interpretValueTransfer(value: bigint): ValueInterpretation;
|
|
74
|
+
/**
|
|
75
|
+
* Decode a full `deroproof…` / `dero…` / `deroi…` / `deto…` / `detoi…` bech32 string.
|
|
76
|
+
*
|
|
77
|
+
* Mirrors `rpc.NewAddress` from DEROHE: validates HRP, runs 5→8 bit repack,
|
|
78
|
+
* checks version byte, splits compressed point + (optional) CBOR arguments.
|
|
79
|
+
*/
|
|
80
|
+
export declare function decodeDeroBech32(input: string): DecodedAddress;
|
|
81
|
+
/** Encode HRP + 5-bit data array to a bech32 string. Inverse of `bech32Decode`. */
|
|
82
|
+
export declare function bech32Encode(hrp: string, data: readonly number[]): string;
|
|
83
|
+
/**
|
|
84
|
+
* Value type accepted by the CBOR encoder. Mirrors the subset of types that
|
|
85
|
+
* `parseArgumentEntry` can surface — sufficient for deroproof argument maps.
|
|
86
|
+
*/
|
|
87
|
+
export type CborValue = bigint | number | string | Uint8Array | boolean | null | CborValue[] | {
|
|
88
|
+
[key: string]: CborValue;
|
|
89
|
+
};
|
|
90
|
+
/** Deterministic-CBOR encode a value (RFC 8949 core deterministic). */
|
|
91
|
+
export declare function cborEncode(value: CborValue): Uint8Array;
|
|
92
|
+
/**
|
|
93
|
+
* Build a `deroproof…` / `deroi…` / `detoi…` bech32 string from a compressed
|
|
94
|
+
* public-key point (the embedded blinder, for proofs) and a typed argument map.
|
|
95
|
+
*
|
|
96
|
+
* Arguments are passed as a plain object whose keys are `Name + DataType`
|
|
97
|
+
* (e.g. `HH` for hash, `VU` for uint64 value transfer). Values are typed:
|
|
98
|
+
* - `U` / `I`: bigint
|
|
99
|
+
* - `H` / `A`: Uint8Array (32 bytes for hash, 33 for address)
|
|
100
|
+
* - `S`: string
|
|
101
|
+
*/
|
|
102
|
+
export declare function encodeDeroBech32(hrp: 'dero' | 'deto' | 'deroi' | 'detoi' | 'deroproof', pointBytes33: Uint8Array, args?: Record<string, CborValue>): string;
|
|
103
|
+
/**
|
|
104
|
+
* Build a deroproof string for a forged amount. Convenience wrapper around
|
|
105
|
+
* `encodeDeroBech32` that handles the canonical `{HH, VU}` arg shape.
|
|
106
|
+
*
|
|
107
|
+
* HH = 32 zero bytes (the docs forge code uses `crypto.Hash{}` here)
|
|
108
|
+
* VU = uint64 amount
|
|
109
|
+
*/
|
|
110
|
+
export declare function encodeForgeProofString(blinderCompressed33: Uint8Array, amountUint64: bigint, hrp?: 'deroproof'): string;
|
|
111
|
+
/** Citation: the 2022 inflation-claim payload proof. Used by self-tests. */
|
|
112
|
+
export declare const CITED_2022_PROOF_STRING = "deroproof1qyyj0cgu3htmkumr79sgca75vwsx8kx7zkrjg0nfez46w36qyx4kwq9zvfyyskpqvdpcfhkhk4m7y9d77ehyj7yhnnrv9z0tjr9m5fqe2yx9t27dwtdxy4j4r0llll7vcmaxwjcl8jzfq";
|
|
113
|
+
/**
|
|
114
|
+
* Decode the cited 2022 proof string, re-encode it with the **same decoded
|
|
115
|
+
* arguments** (the real H hash, not zeros), and confirm byte-equal output.
|
|
116
|
+
*
|
|
117
|
+
* If this fails, the encoder is not faithful to DERO's canonical CBOR + bech32
|
|
118
|
+
* wire format and forging anything else is unsafe to surface.
|
|
119
|
+
*
|
|
120
|
+
* (The forge path defaults H to 32 zero bytes — see `encodeForgeProofString`.
|
|
121
|
+
* That's correct for the docs-page demo but would not reproduce a real
|
|
122
|
+
* wallet-generated proof, which has a real shared-key hash in H.)
|
|
123
|
+
*/
|
|
124
|
+
export declare function verifyProofEncoderRoundtrip(): void;
|
|
125
|
+
//# sourceMappingURL=proof-decode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof-decode.d.ts","sourceRoot":"","sources":["../src/proof-decode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAiCH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAwB3E;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,OAAO,GACX,MAAM,EAAE,CAsBV;AAmHD,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAKrD;AAMD,kDAAkD;AAClD,MAAM,MAAM,YAAY,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAwBlE,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,YAAY,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,4GA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