@wowok/agent-mcp 2.2.13 → 2.2.15
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/README.md +19 -11
- package/dist/index.js +44 -100
- package/dist/schema/query/index.js +1 -1
- package/dist/schema-query/index.d.ts +29 -0
- package/dist/schema-query/index.js +149 -0
- package/dist/schemas/account_operation.schema.json +255 -0
- package/dist/schemas/guard2file.schema.json +71 -0
- package/dist/schemas/index.json +139 -0
- package/dist/schemas/local_info_operation.schema.json +142 -0
- package/dist/schemas/local_mark_operation.schema.json +119 -0
- package/dist/schemas/machineNode2file.schema.json +71 -0
- package/dist/schemas/messenger_operation.schema.json +1393 -0
- package/dist/schemas/onchain_events.schema.json +113 -0
- package/dist/schemas/onchain_operations.schema.json +376 -0
- package/dist/schemas/onchain_operations_allocation.schema.json +914 -0
- package/dist/schemas/onchain_operations_arbitration.schema.json +1166 -0
- package/dist/schemas/onchain_operations_contact.schema.json +853 -0
- package/dist/schemas/onchain_operations_demand.schema.json +984 -0
- package/dist/schemas/onchain_operations_gen_passport.schema.json +1141 -0
- package/dist/schemas/onchain_operations_guard.schema.json +713 -0
- package/dist/schemas/onchain_operations_machine.schema.json +1347 -0
- package/dist/schemas/onchain_operations_order.schema.json +830 -0
- package/dist/schemas/onchain_operations_payment.schema.json +717 -0
- package/dist/schemas/onchain_operations_permission.schema.json +1088 -0
- package/dist/schemas/onchain_operations_personal.schema.json +1282 -0
- package/dist/schemas/onchain_operations_progress.schema.json +751 -0
- package/dist/schemas/onchain_operations_repository.schema.json +1572 -0
- package/dist/schemas/onchain_operations_reward.schema.json +955 -0
- package/dist/schemas/onchain_operations_service.schema.json +1411 -0
- package/dist/schemas/onchain_operations_treasury.schema.json +1155 -0
- package/dist/schemas/onchain_table_data.schema.json +35 -0
- package/dist/schemas/query_toolkit.schema.json +32 -0
- package/dist/schemas/schema_query.schema.json +33 -0
- package/dist/schemas/wip_file.schema.json +27 -0
- package/dist/schemas/wowok_buildin_info.schema.json +487 -0
- package/package.json +7 -5
- package/dist/docs/index.d.ts +0 -3
- package/dist/docs/index.js +0 -2
- package/dist/docs/loader.d.ts +0 -12
- package/dist/docs/loader.js +0 -177
- package/dist/docs/search.d.ts +0 -17
- package/dist/docs/search.js +0 -325
- package/dist/docs/types.d.ts +0 -55
- package/dist/docs/types.js +0 -1
- package/docs/README.md +0 -249
- package/docs/WIP.md +0 -388
- package/docs/WTS.md +0 -536
- package/docs/docs/account.md +0 -914
- package/docs/docs/allocation.md +0 -635
- package/docs/docs/arbitration.md +0 -1804
- package/docs/docs/arbitration_state_machine.md +0 -270
- package/docs/docs/contact.md +0 -709
- package/docs/docs/demand.md +0 -948
- package/docs/docs/guard.md +0 -1465
- package/docs/docs/localinfo.md +0 -432
- package/docs/docs/localmark.md +0 -583
- package/docs/docs/machine.md +0 -2490
- package/docs/docs/messenger.md +0 -2098
- package/docs/docs/onchain_events.md +0 -267
- package/docs/docs/order.md +0 -1001
- package/docs/docs/payment.md +0 -512
- package/docs/docs/permission.md +0 -1438
- package/docs/docs/personal.md +0 -742
- package/docs/docs/progress.md +0 -1748
- package/docs/docs/query.md +0 -467
- package/docs/docs/repository.md +0 -1043
- package/docs/docs/reward.md +0 -833
- package/docs/docs/service.md +0 -2130
- package/docs/docs/stage-01-introduction.md +0 -243
- package/docs/docs/stage-02-trust.md +0 -302
- package/docs/docs/stage-03-collaboration.md +0 -337
- package/docs/docs/stage-04-transaction.md +0 -277
- package/docs/docs/stage-05-business.md +0 -151
- package/docs/docs/stage-06-personal.md +0 -203
- package/docs/docs/stage-07-query.md +0 -572
- package/docs/docs/stage-08-examples.md +0 -184
- package/docs/docs/treasury.md +0 -1149
- package/docs/docs/wowok_buildin_info.md +0 -740
- package/docs/examples/Insurance/Insurance.md +0 -594
- package/docs/examples/Insurance/Insurance_TestResults.md +0 -481
- package/docs/examples/Insurance/insurance_complete_guard_v1.json +0 -50
- package/docs/examples/MyShop/MyShop.md +0 -1353
- package/docs/examples/MyShop/MyShop_TestResults.md +0 -1003
- package/docs/examples/MyShop_Advanced/MyShop_Advanced.md +0 -1898
- package/docs/examples/MyShop_Advanced/MyShop_Advanced_MerchantSystem_TestResults.md +0 -1297
- package/docs/examples/MyShop_Advanced/MyShop_Advanced_OrderFlow_TestResults.md +0 -743
- package/docs/examples/MyShop_Advanced/machine_nodes.json +0 -222
- package/docs/examples/ThreeBody_Signature/ThreeBody_Signature.md +0 -776
- package/docs/examples/ThreeBody_Signature/ThreeBody_Signature_TestResults.md +0 -599
- package/docs/examples/Travel/Travel.md +0 -1157
- package/docs/examples/Travel/Travel_TestResults.md +0 -743
- package/docs/examples/Travel/calc-weather-timestamps.js +0 -8
- package/docs/examples/Travel/travel_machine_v2_export.json +0 -104
- package/docs/examples/Travel/weather_check_guard_v1.json +0 -51
- package/docs/skills/WOWOK.md +0 -650
- package/docs/skills/onchain_operations/_common.md +0 -406
- package/docs/skills/onchain_operations/_index.md +0 -196
- package/docs/skills/onchain_operations/allocation.md +0 -28
- package/docs/skills/onchain_operations/arbitration.md +0 -106
- package/docs/skills/onchain_operations/contact.md +0 -40
- package/docs/skills/onchain_operations/demand.md +0 -53
- package/docs/skills/onchain_operations/gen_passport.md +0 -23
- package/docs/skills/onchain_operations/guard.md +0 -56
- package/docs/skills/onchain_operations/machine.md +0 -89
- package/docs/skills/onchain_operations/order.md +0 -56
- package/docs/skills/onchain_operations/payment.md +0 -24
- package/docs/skills/onchain_operations/permission.md +0 -68
- package/docs/skills/onchain_operations/personal.md +0 -58
- package/docs/skills/onchain_operations/progress.md +0 -38
- package/docs/skills/onchain_operations/repository.md +0 -70
- package/docs/skills/onchain_operations/reward.md +0 -38
- package/docs/skills/onchain_operations/service.md +0 -78
- package/docs/skills/onchain_operations/treasury.md +0 -68
- package/docs/skills/schema-account_operation.md +0 -402
- package/docs/skills/schema-guard2file.md +0 -153
- package/docs/skills/schema-local_info_operation.md +0 -160
- package/docs/skills/schema-local_mark_operation.md +0 -148
- package/docs/skills/schema-machineNode2file.md +0 -155
- package/docs/skills/schema-messenger_operation.md +0 -547
- package/docs/skills/schema-onchain_events.md +0 -201
- package/docs/skills/schema-onchain_table_data.md +0 -334
- package/docs/skills/schema-query_toolkit.md +0 -395
- package/docs/skills/schema-wip_file.md +0 -240
- package/docs/skills/schema-wowok_buildin_info.md +0 -296
- package/docs/wip-examples/three_body.html +0 -57
- package/docs/wip-examples/three_body.wip +0 -30
package/docs/WTS.md
DELETED
|
@@ -1,536 +0,0 @@
|
|
|
1
|
-
# WTS — Witness Timestamped Sequence
|
|
2
|
-
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
**WTS** (Witness Timestamped Sequence) is a JSON-based file format for creating **self-proving, tamper-proof records of encrypted conversations** from the WoWok Messenger. It captures the complete message history between two parties, including server-attested Merkle proofs, timestamps, and optional digital signatures.
|
|
8
|
-
|
|
9
|
-
A WTS file serves as a **standalone evidence package** — anyone can independently verify the authenticity, integrity, and chronology of every message without access to the original server or encryption keys.
|
|
10
|
-
|
|
11
|
-
### Key Properties
|
|
12
|
-
|
|
13
|
-
| Property | Mechanism |
|
|
14
|
-
|----------|-----------|
|
|
15
|
-
| **Server Attestation** | Each message includes a server signature over its Merkle tree position |
|
|
16
|
-
| **Merkle Chain Integrity** | Consecutive messages are linked via `prevRoot` → `merkleRoot` chains |
|
|
17
|
-
| **Tamper Detection** | SHA-256 hash covers the schema identifier and entire payload |
|
|
18
|
-
| **Non-Repudiation** | Optional Falcon-512 digital signature over the entire metadata block |
|
|
19
|
-
| **Self-Verifiable** | All verification data is embedded; no server access required |
|
|
20
|
-
| **Cross-Validation** | Metadata fields (`messageCount`, `merkleRoot`) are cross-checked against actual payload content |
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Schema
|
|
25
|
-
|
|
26
|
-
### JSON Structure
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
{
|
|
30
|
-
"wts": " "https://github.com/wowok-ai/docs/blob/main/WTS.md",
|
|
31
|
-
"payload": {
|
|
32
|
-
"session": { ... },
|
|
33
|
-
"messages": [ ... ]
|
|
34
|
-
},
|
|
35
|
-
"meta": { ... }
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## Field Reference
|
|
42
|
-
|
|
43
|
-
### Root Level
|
|
44
|
-
|
|
45
|
-
| Field | Type | Required | Description |
|
|
46
|
-
|-------|------|----------|-------------|
|
|
47
|
-
| `wts` | `string` | **Yes** | Schema identifier URL. Fixed value: `"https://github.com/wowok-ai/docs/blob/main/WTS.md"` |
|
|
48
|
-
| `payload` | `object` | **Yes** | The conversation data (session info + messages) |
|
|
49
|
-
| `meta` | `object` | **Yes** | Metadata including integrity hash, summary stats, and optional signatures |
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
### `payload` — Conversation Payload
|
|
54
|
-
|
|
55
|
-
| Field | Type | Required | Description |
|
|
56
|
-
|-------|------|----------|-------------|
|
|
57
|
-
| `payload.session` | `object` | **Yes** | Session identifier and participant information |
|
|
58
|
-
| `payload.messages` | `array` | **Yes** | Ordered array of WTS messages |
|
|
59
|
-
|
|
60
|
-
#### `payload.session` — Session Info
|
|
61
|
-
|
|
62
|
-
| Field | Type | Required | Description |
|
|
63
|
-
|-------|------|----------|-------------|
|
|
64
|
-
| `id` | `string` | **Yes** | Unique session identifier |
|
|
65
|
-
| `participants` | `string[]` | **Yes** | Array of participant addresses (hex-encoded, `0x` prefix) |
|
|
66
|
-
|
|
67
|
-
#### `payload.messages[]` — WTS Message
|
|
68
|
-
|
|
69
|
-
| Field | Type | Required | Description |
|
|
70
|
-
|-------|------|----------|-------------|
|
|
71
|
-
| `id` | `string` | **Yes** | Unique message identifier (format: `{fromShort}_{toShort}_{leafIndex}_{random}`) |
|
|
72
|
-
| `from` | `string` | **Yes** | Sender address (hex-encoded, `0x` prefix) |
|
|
73
|
-
| `to` | `string` | **Yes** | Recipient address (hex-encoded, `0x` prefix) |
|
|
74
|
-
| `plaintext` | `string` | No | Decrypted message content. Omitted when `excludePlaintext` is `true` |
|
|
75
|
-
| `plaintextHash` | `string` | **Yes** | SHA-256 hash of the plaintext (hex-encoded, `0x` prefix) |
|
|
76
|
-
| `clientTimestamp` | `number` | **Yes** | Client-side timestamp in milliseconds (Unix epoch) |
|
|
77
|
-
| `timestamp` | `number` | **Yes** | Server-attested timestamp in milliseconds (Unix epoch) |
|
|
78
|
-
| `leafIndex` | `number` | **Yes** | Position in the server's Merkle tree for this conversation |
|
|
79
|
-
| `prevRoot` | `string` | **Yes** | Merkle tree root **before** this message was inserted (hex-encoded, `0x` prefix) |
|
|
80
|
-
| `merkleRoot` | `string` | **Yes** | Merkle tree root **after** this message was inserted (hex-encoded, `0x` prefix) |
|
|
81
|
-
| `serverSignature` | `string` | **Yes** | Server's Falcon-512 signature over the Merkle tree update (hex-encoded, `0x` prefix) |
|
|
82
|
-
| `serverPublicKeyIndex` | `number` | **Yes** | Index into `meta.serverPublicKeys[]` identifying which server key signed this message |
|
|
83
|
-
| `guardAddress` | `string` | No | Guard object address if message was verified by a Guard |
|
|
84
|
-
| `passportAddress` | `string` | No | Passport address if sender used verified credentials |
|
|
85
|
-
| `lastReceivedLeafIndex` | `number` | No | Last message leaf index the sender had received (for sync confirmation) |
|
|
86
|
-
| `arkConfirmed` | `object` | No | ARK (Asynchronous Ratchet Key) confirmation data |
|
|
87
|
-
| `msgType` | `number` | No | Message type: `1` = text message, `3` = file message |
|
|
88
|
-
| `zipMetadata` | `object` | No | ZIP file metadata for file messages |
|
|
89
|
-
|
|
90
|
-
##### `arkConfirmed` — ARK Confirmation
|
|
91
|
-
|
|
92
|
-
| Field | Type | Required | Description |
|
|
93
|
-
|-------|------|----------|-------------|
|
|
94
|
-
| `recipient` | `string` | **Yes** | Recipient address |
|
|
95
|
-
| `recipientPublicKey` | `string` | **Yes** | Recipient's public key |
|
|
96
|
-
| `signature` | `string` | **Yes** | Signature confirming key receipt |
|
|
97
|
-
| `timestamp` | `number` | **Yes** | Confirmation timestamp in milliseconds |
|
|
98
|
-
|
|
99
|
-
##### `zipMetadata` — File Message Metadata
|
|
100
|
-
|
|
101
|
-
| Field | Type | Required | Description |
|
|
102
|
-
|-------|------|----------|-------------|
|
|
103
|
-
| `fileName` | `string` | No | Original filename |
|
|
104
|
-
| `fileSize` | `number` | No | File size in bytes |
|
|
105
|
-
| `contentType` | `string` | No | Content type (`"wts"`, `"wip"`, `"zip"`) |
|
|
106
|
-
| `zipHash` | `string` | No | Hash of the ZIP content |
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
### `meta` — Metadata
|
|
111
|
-
|
|
112
|
-
| Field | Type | Required | Description |
|
|
113
|
-
|-------|------|----------|-------------|
|
|
114
|
-
| `meta.type` | `string` | **Yes** | File type identifier. Fixed value: `"wts"` |
|
|
115
|
-
| `meta.version` | `string` | **Yes** | Format version. Current: `"1.0"` |
|
|
116
|
-
| `meta.created` | `string` | **Yes** | Creation timestamp in ISO 8601 format |
|
|
117
|
-
| `meta.hash` | `string` | **Yes** | SHA-256 hash of `{ wts, session, messages }` as a lowercase hex string (no prefix) |
|
|
118
|
-
| `meta.algorithm` | `string` | **Yes** | Hash algorithm identifier. Fixed value: `"sha256"` |
|
|
119
|
-
| `meta.startTime` | `number` | **Yes** | Timestamp of the earliest message in the sequence (ms, Unix epoch) |
|
|
120
|
-
| `meta.endTime` | `number` | **Yes** | Timestamp of the latest message in the sequence (ms, Unix epoch) |
|
|
121
|
-
| `meta.messageCount` | `number` | **Yes** | Total number of messages in the sequence |
|
|
122
|
-
| `meta.merkleRoot` | `string` | **Yes** | Merkle root of the **last** message in the sequence (hex-encoded, `0x` prefix) |
|
|
123
|
-
| `meta.creator` | `string` | **Yes** | Address of the WTS generator (hex-encoded, `0x` prefix) |
|
|
124
|
-
| `meta.participant` | `string` | **Yes** | Address of the conversation peer (hex-encoded, `0x` prefix) |
|
|
125
|
-
| `meta.serverPublicKeys` | `array` | No | Array of server public keys referenced by messages via `serverPublicKeyIndex` |
|
|
126
|
-
| `meta.signature` | `object` or `array` | No | Digital signature(s). Single object or array for multi-signature support |
|
|
127
|
-
|
|
128
|
-
#### `meta.serverPublicKeys[]` — Server Public Key Entry
|
|
129
|
-
|
|
130
|
-
| Field | Type | Required | Description |
|
|
131
|
-
|-------|------|----------|-------------|
|
|
132
|
-
| `publicKey` | `string` | **Yes** | Server's Falcon-512 public key (hex-encoded, `0x` prefix) |
|
|
133
|
-
| `keyId` | `string` | No | Optional key identifier |
|
|
134
|
-
| `validFrom` | `number` | **Yes** | Timestamp from which this key is valid (ms, Unix epoch) |
|
|
135
|
-
| `validUntil` | `number` | No | Timestamp until which this key is valid (ms, Unix epoch) |
|
|
136
|
-
| `algorithm` | `string` | No | Key algorithm identifier |
|
|
137
|
-
|
|
138
|
-
> **Design Note:** Server public keys are stored in a deduplicated array in `meta` rather than inline in each message. Messages reference keys by index (`serverPublicKeyIndex`), significantly reducing file size since server keys rarely change during a conversation.
|
|
139
|
-
|
|
140
|
-
#### `meta.signature` — Signature Object
|
|
141
|
-
|
|
142
|
-
| Field | Type | Required | Description |
|
|
143
|
-
|-------|------|----------|-------------|
|
|
144
|
-
| `value` | `string` | **Yes** | Base64-encoded signature bytes |
|
|
145
|
-
| `publicKey` | `string` | **Yes** | Public key for verification (Base64-encoded, 897 bytes for Falcon-512) |
|
|
146
|
-
| `algorithm` | `string` | **Yes** | Signature algorithm. Fixed value: `"Falcon512"` |
|
|
147
|
-
| `address` | `string` | No | Signer's blockchain address (hex-encoded, `0x` prefix) |
|
|
148
|
-
|
|
149
|
-
---
|
|
150
|
-
|
|
151
|
-
## Integrity Model
|
|
152
|
-
|
|
153
|
-
### Hash Computation
|
|
154
|
-
|
|
155
|
-
The `meta.hash` is computed as:
|
|
156
|
-
|
|
157
|
-
```
|
|
158
|
-
hash = SHA-256( canonicalizeJson({ wts: schemaUrl, session: session, messages: messages }) )
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
This covers the schema identifier, session info, and all messages, preventing tampering with any of these components.
|
|
162
|
-
|
|
163
|
-
### Signature Computation
|
|
164
|
-
|
|
165
|
-
When present, `meta.signature` is a Falcon-512 signature over:
|
|
166
|
-
|
|
167
|
-
```
|
|
168
|
-
metaHash = SHA-256( canonicalizeJson(meta_without_signature) )
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
Where `meta_without_signature` is the `meta` object with the `signature` field excluded. This covers all metadata fields including `serverPublicKeys`.
|
|
172
|
-
|
|
173
|
-
### Verification Chain
|
|
174
|
-
|
|
175
|
-
```
|
|
176
|
-
{ wts, session, messages } ──SHA-256──► meta.hash ──(part of)──► meta
|
|
177
|
-
│
|
|
178
|
-
meta (excluding signature) ──SHA-256──► metaHash ──Falcon-512──► meta.signature
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Cross-Validation
|
|
182
|
-
|
|
183
|
-
During verification, the following cross-checks are performed:
|
|
184
|
-
|
|
185
|
-
| Check | Description |
|
|
186
|
-
|-------|-------------|
|
|
187
|
-
| `meta.messageCount` vs `payload.messages.length` | Ensures the declared count matches actual messages |
|
|
188
|
-
| `meta.merkleRoot` vs last message's `merkleRoot` | Ensures the summary root matches the final message |
|
|
189
|
-
|
|
190
|
-
### Merkle Chain Validation
|
|
191
|
-
|
|
192
|
-
Each message's integrity is verified through the Merkle chain:
|
|
193
|
-
|
|
194
|
-
1. For message at index `i` (where `i > 0`):
|
|
195
|
-
- `messages[i].prevRoot` must equal `messages[i-1].merkleRoot`
|
|
196
|
-
2. The server signature on each message attests to the `(prevRoot, merkleRoot)` transition
|
|
197
|
-
3. This creates an unbroken chain of cryptographic proofs from the first to the last message
|
|
198
|
-
|
|
199
|
-
### Tamper Detection Matrix
|
|
200
|
-
|
|
201
|
-
| Tampered Field | Detected By |
|
|
202
|
-
|----------------|-------------|
|
|
203
|
-
| `wts` (schema URL) | Hash mismatch |
|
|
204
|
-
| `payload.session` | Hash mismatch |
|
|
205
|
-
| Any message field | Hash mismatch |
|
|
206
|
-
| Message insertion/deletion | Hash mismatch **+** `messageCount` cross-validation |
|
|
207
|
-
| Message reordering | Merkle chain break (`prevRoot` mismatch) |
|
|
208
|
-
| `meta.type` | Signature mismatch |
|
|
209
|
-
| `meta.version` | Signature mismatch |
|
|
210
|
-
| `meta.created` | Signature mismatch |
|
|
211
|
-
| `meta.hash` | Hash mismatch **+** Signature mismatch |
|
|
212
|
-
| `meta.startTime` / `meta.endTime` | Signature mismatch |
|
|
213
|
-
| `meta.messageCount` | Signature mismatch **+** Cross-validation |
|
|
214
|
-
| `meta.merkleRoot` | Signature mismatch **+** Cross-validation |
|
|
215
|
-
| `meta.serverPublicKeys[]` | Signature mismatch |
|
|
216
|
-
| `meta.signature` | Signature mismatch |
|
|
217
|
-
|
|
218
|
-
---
|
|
219
|
-
|
|
220
|
-
## Canonical JSON Serialization
|
|
221
|
-
|
|
222
|
-
To ensure deterministic hash computation, all JSON objects are serialized using **canonical JSON** before hashing:
|
|
223
|
-
|
|
224
|
-
1. Object keys are sorted alphabetically
|
|
225
|
-
2. No whitespace between tokens
|
|
226
|
-
3. Strings use standard JSON escaping
|
|
227
|
-
4. `undefined` values are excluded from serialization
|
|
228
|
-
5. Numbers are serialized without unnecessary precision
|
|
229
|
-
|
|
230
|
-
---
|
|
231
|
-
|
|
232
|
-
## Examples
|
|
233
|
-
|
|
234
|
-
### Minimal WTS (Two Messages, No Plaintext, No Signature)
|
|
235
|
-
|
|
236
|
-
```json
|
|
237
|
-
{
|
|
238
|
-
"wts": "https://github.com/wowok-ai/docs/blob/main/WTS.md",
|
|
239
|
-
"payload": {
|
|
240
|
-
"session": {
|
|
241
|
-
"id": "alice_bob_session_001",
|
|
242
|
-
"participants": [
|
|
243
|
-
"0x3a15ed459db7b7bcd9e1c7cd49c8a58aed5e1fd169cc2a99ead2201fa3ee54a4",
|
|
244
|
-
"0x478a79a2e12d2c17886da98352c6d3fe4283eff63e465393bc4b71ed7a0afcbf"
|
|
245
|
-
]
|
|
246
|
-
},
|
|
247
|
-
"messages": [
|
|
248
|
-
{
|
|
249
|
-
"id": "3a15ed45_478a79a2_0_0744",
|
|
250
|
-
"from": "0x3a15ed459db7b7bcd9e1c7cd49c8a58aed5e1fd169cc2a99ead2201fa3ee54a4",
|
|
251
|
-
"to": "0x478a79a2e12d2c17886da98352c6d3fe4283eff63e465393bc4b71ed7a0afcbf",
|
|
252
|
-
"plaintextHash": "0xabc123...",
|
|
253
|
-
"clientTimestamp": 1776863000000,
|
|
254
|
-
"timestamp": 1776863002578,
|
|
255
|
-
"leafIndex": 0,
|
|
256
|
-
"prevRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
257
|
-
"merkleRoot": "0xbf23abc123def45678901234567890abcdef1234567890abcdef12345678906e5b",
|
|
258
|
-
"serverSignature": "0x248a...",
|
|
259
|
-
"serverPublicKeyIndex": 0
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
"id": "478a79a2_3a15ed45_1_a025",
|
|
263
|
-
"from": "0x478a79a2e12d2c17886da98352c6d3fe4283eff63e465393bc4b71ed7a0afcbf",
|
|
264
|
-
"to": "0x3a15ed459db7b7bcd9e1c7cd49c8a58aed5e1fd169cc2a99ead2201fa3ee54a4",
|
|
265
|
-
"plaintextHash": "0xdef456...",
|
|
266
|
-
"clientTimestamp": 1776863010000,
|
|
267
|
-
"timestamp": 1776863011234,
|
|
268
|
-
"leafIndex": 1,
|
|
269
|
-
"prevRoot": "0xbf23abc123def45678901234567890abcdef1234567890abcdef12345678906e5b",
|
|
270
|
-
"merkleRoot": "0x2cdf789abcdef01234567890abcdef1234567890abcdef1234567890abc13f4",
|
|
271
|
-
"serverSignature": "0xce31...",
|
|
272
|
-
"serverPublicKeyIndex": 0
|
|
273
|
-
}
|
|
274
|
-
]
|
|
275
|
-
},
|
|
276
|
-
"meta": {
|
|
277
|
-
"type": "wts",
|
|
278
|
-
"version": "1.0",
|
|
279
|
-
"created": "2026-05-06T03:20:00Z",
|
|
280
|
-
"hash": "e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5",
|
|
281
|
-
"algorithm": "sha256",
|
|
282
|
-
"startTime": 1776863000000,
|
|
283
|
-
"endTime": 1776863010000,
|
|
284
|
-
"messageCount": 2,
|
|
285
|
-
"merkleRoot": "0x2cdf789abcdef01234567890abcdef1234567890abcdef1234567890abc13f4",
|
|
286
|
-
"creator": "0x3a15ed459db7b7bcd9e1c7cd49c8a58aed5e1fd169cc2a99ead2201fa3ee54a4",
|
|
287
|
-
"participant": "0x478a79a2e12d2c17886da98352c6d3fe4283eff63e465393bc4b71ed7a0afcbf",
|
|
288
|
-
"serverPublicKeys": [
|
|
289
|
-
{
|
|
290
|
-
"publicKey": "0xa723abc123def45678901234567890abcdef1234567890abcdef123456783790",
|
|
291
|
-
"validFrom": 0
|
|
292
|
-
}
|
|
293
|
-
]
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
### Signed WTS (With Plaintext + Signature)
|
|
299
|
-
|
|
300
|
-
```json
|
|
301
|
-
{
|
|
302
|
-
"wts": "https://github.com/wowok-ai/docs/blob/main/WTS.md",
|
|
303
|
-
"payload": {
|
|
304
|
-
"session": {
|
|
305
|
-
"id": "alice_bob_session_001",
|
|
306
|
-
"participants": [
|
|
307
|
-
"0x3a15ed45...",
|
|
308
|
-
"0x478a79a2..."
|
|
309
|
-
]
|
|
310
|
-
},
|
|
311
|
-
"messages": [
|
|
312
|
-
{
|
|
313
|
-
"id": "3a15ed45_478a79a2_0_0744",
|
|
314
|
-
"from": "0x3a15ed45...",
|
|
315
|
-
"to": "0x478a79a2...",
|
|
316
|
-
"plaintext": "Hello Bob! Let's discuss the contract.",
|
|
317
|
-
"plaintextHash": "0xabc123...",
|
|
318
|
-
"clientTimestamp": 1776863000000,
|
|
319
|
-
"timestamp": 1776863002578,
|
|
320
|
-
"leafIndex": 0,
|
|
321
|
-
"prevRoot": "0x0000...",
|
|
322
|
-
"merkleRoot": "0xbf23...",
|
|
323
|
-
"serverSignature": "0x248a...",
|
|
324
|
-
"serverPublicKeyIndex": 0
|
|
325
|
-
}
|
|
326
|
-
]
|
|
327
|
-
},
|
|
328
|
-
"meta": {
|
|
329
|
-
"type": "wts",
|
|
330
|
-
"version": "1.0",
|
|
331
|
-
"created": "2026-05-06T03:20:00Z",
|
|
332
|
-
"hash": "f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6",
|
|
333
|
-
"algorithm": "sha256",
|
|
334
|
-
"startTime": 1776863000000,
|
|
335
|
-
"endTime": 1776863000000,
|
|
336
|
-
"messageCount": 1,
|
|
337
|
-
"merkleRoot": "0xbf23...",
|
|
338
|
-
"creator": "0x3a15ed45...",
|
|
339
|
-
"participant": "0x478a79a2...",
|
|
340
|
-
"serverPublicKeys": [
|
|
341
|
-
{
|
|
342
|
-
"publicKey": "0xa723...",
|
|
343
|
-
"validFrom": 0
|
|
344
|
-
}
|
|
345
|
-
],
|
|
346
|
-
"signature": {
|
|
347
|
-
"value": "base64EncodedSignatureValueHere...",
|
|
348
|
-
"publicKey": "Bwl0UgpjuBhHXtrC09LAW30exFURxRBB...",
|
|
349
|
-
"algorithm": "Falcon512",
|
|
350
|
-
"address": "0x3a15ed459db7b7bcd9e1c7cd49c8a58aed5e1fd169cc2a99ead2201fa3ee54a4"
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
---
|
|
357
|
-
|
|
358
|
-
## API Reference
|
|
359
|
-
|
|
360
|
-
### `generate_wts(params)`
|
|
361
|
-
|
|
362
|
-
Generates a WTS file from the conversation history between two accounts.
|
|
363
|
-
|
|
364
|
-
**Parameters:** `WtsGenerationParams`
|
|
365
|
-
|
|
366
|
-
| Field | Type | Required | Description |
|
|
367
|
-
|-------|------|----------|-------------|
|
|
368
|
-
| `myAccount` | `string` | **Yes** | Account name or address of the requesting party |
|
|
369
|
-
| `peerAccount` | `string` \| `object` | **Yes** | Account name/address of the conversation peer |
|
|
370
|
-
| `range` | `object` | No | Message range filter. If omitted, all messages are included |
|
|
371
|
-
| `excludePlaintext` | `boolean` | No | If `true`, plaintext is excluded from messages (default: `false`) |
|
|
372
|
-
| `outputDir` | `string` | **Yes** | Directory path for the generated WTS file(s) |
|
|
373
|
-
|
|
374
|
-
#### `range` — Range Filter
|
|
375
|
-
|
|
376
|
-
Three range types are supported:
|
|
377
|
-
|
|
378
|
-
**Time Range** (by client timestamp):
|
|
379
|
-
|
|
380
|
-
| Field | Type | Description |
|
|
381
|
-
|-------|------|-------------|
|
|
382
|
-
| `type` | `"time"` | Range type |
|
|
383
|
-
| `start` | `number` | Start timestamp (ms, Unix epoch) |
|
|
384
|
-
| `end` | `number` | End timestamp (ms, Unix epoch) |
|
|
385
|
-
|
|
386
|
-
**Message ID Range:**
|
|
387
|
-
|
|
388
|
-
| Field | Type | Description |
|
|
389
|
-
|-------|------|-------------|
|
|
390
|
-
| `type` | `"messageId"` | Range type |
|
|
391
|
-
| `start` | `string` | Starting message ID |
|
|
392
|
-
| `end` | `string` | Ending message ID |
|
|
393
|
-
|
|
394
|
-
**Sequence Index Range** (by `leafIndex`):
|
|
395
|
-
|
|
396
|
-
| Field | Type | Description |
|
|
397
|
-
|-------|------|-------------|
|
|
398
|
-
| `type` | `"seqIndex"` | Range type |
|
|
399
|
-
| `start` | `number` | Starting leaf index |
|
|
400
|
-
| `end` | `number` | Ending leaf index |
|
|
401
|
-
|
|
402
|
-
**Returns:** `Promise<WtsFileResult>`
|
|
403
|
-
|
|
404
|
-
| Field | Type | Description |
|
|
405
|
-
|-------|------|-------------|
|
|
406
|
-
| `files` | `string[]` | Paths to generated WTS files |
|
|
407
|
-
| `totalMessageCount` | `number` | Total messages across all generated files |
|
|
408
|
-
| `timeRange` | `object` | `{ start: number, end: number }` — Time span of captured messages |
|
|
409
|
-
|
|
410
|
-
---
|
|
411
|
-
|
|
412
|
-
### `verify_wts(wtsFilePath)`
|
|
413
|
-
|
|
414
|
-
Verifies a WTS file's integrity, Merkle chain, cross-validation fields, and signatures.
|
|
415
|
-
|
|
416
|
-
**Parameters:**
|
|
417
|
-
|
|
418
|
-
| Parameter | Type | Required | Description |
|
|
419
|
-
|-----------|------|----------|-------------|
|
|
420
|
-
| `wtsFilePath` | `string` | **Yes** | Path to the WTS file |
|
|
421
|
-
|
|
422
|
-
**Returns:** `Promise<WtsVerificationResult>`
|
|
423
|
-
|
|
424
|
-
| Field | Type | Description |
|
|
425
|
-
|-------|------|-------------|
|
|
426
|
-
| `valid` | `boolean` | Overall verification result |
|
|
427
|
-
| `error` | `string` | Error message if verification failed |
|
|
428
|
-
| `hashValid` | `boolean` | Whether the content hash matches |
|
|
429
|
-
| `hasSignature` | `boolean` | Whether the file contains any signature |
|
|
430
|
-
| `signatureValid` | `boolean` | Whether all signatures are valid (undefined if no signature) |
|
|
431
|
-
| `signatures` | `WtsSignatureVerification[]` | Per-signature verification details |
|
|
432
|
-
|
|
433
|
-
**Verification Steps:**
|
|
434
|
-
|
|
435
|
-
1. **Structure validation** — Checks that `wts`, `payload`, and `meta` exist
|
|
436
|
-
2. **Type validation** — Ensures `meta.type === "wts"`
|
|
437
|
-
3. **Merkle chain validation** — Verifies `prevRoot` continuity across all messages
|
|
438
|
-
4. **Hash verification** — Recomputes `SHA-256({ wts, session, messages })` and compares with `meta.hash`
|
|
439
|
-
5. **Cross-validation** — Checks `meta.messageCount` vs actual message count, and `meta.merkleRoot` vs last message's `merkleRoot`
|
|
440
|
-
6. **Signature verification** — If `meta.signature` exists, verifies Falcon-512 signature over `SHA-256(meta_without_signature)`
|
|
441
|
-
|
|
442
|
-
---
|
|
443
|
-
|
|
444
|
-
### `sign_wts(wtsFilePath, account, outputPath?)`
|
|
445
|
-
|
|
446
|
-
Adds a digital signature to an existing WTS file. Supports multi-signature — if the file already has signatures, the new one is appended (or replaces an existing signature from the same public key).
|
|
447
|
-
|
|
448
|
-
**Parameters:**
|
|
449
|
-
|
|
450
|
-
| Parameter | Type | Required | Description |
|
|
451
|
-
|-----------|------|----------|-------------|
|
|
452
|
-
| `wtsFilePath` | `string` | **Yes** | Path to the WTS file |
|
|
453
|
-
| `account` | `string` | **Yes** | Account name or address for signing |
|
|
454
|
-
| `outputPath` | `string` | No | Output path (defaults to overwriting the input file) |
|
|
455
|
-
|
|
456
|
-
**Returns:** `Promise<string>` — Path to the signed WTS file.
|
|
457
|
-
|
|
458
|
-
---
|
|
459
|
-
|
|
460
|
-
### `wts2html(wtsPath, options?)`
|
|
461
|
-
|
|
462
|
-
Converts a WTS file to a human-readable HTML page with styled message bubbles, timestamps, and verification status.
|
|
463
|
-
|
|
464
|
-
**Parameters:**
|
|
465
|
-
|
|
466
|
-
| Parameter | Type | Required | Description |
|
|
467
|
-
|-----------|------|----------|-------------|
|
|
468
|
-
| `wtsPath` | `string` | **Yes** | Path to the `.wts` file |
|
|
469
|
-
| `options.title` | `string` | No | Custom HTML page title |
|
|
470
|
-
| `options.theme` | `enum` | No | `"light"` or `"dark"` |
|
|
471
|
-
| `options.outputPath` | `string` | No | Output file path |
|
|
472
|
-
|
|
473
|
-
**Returns:** `Promise<string>` — Path to the generated HTML file.
|
|
474
|
-
|
|
475
|
-
---
|
|
476
|
-
|
|
477
|
-
## Use Cases
|
|
478
|
-
|
|
479
|
-
| Scenario | How WTS Is Used |
|
|
480
|
-
|----------|-----------------|
|
|
481
|
-
| **Legal Evidence** | Generate a WTS of a conversation and sign it. The file is a self-contained evidence package with server-attested timestamps and Merkle proofs. |
|
|
482
|
-
| **Dispute Resolution** | In arbitration, both parties can present WTS files of the same conversation. The Merkle chain and server signatures prove message authenticity and order. |
|
|
483
|
-
| **Compliance Auditing** | Organizations generate periodic WTS sequences of business communications for compliance records. |
|
|
484
|
-
| **Contract Negotiation** | During Messenger-based negotiations, a signed WTS captures the full exchange as an immutable record. |
|
|
485
|
-
| **On-Chain Proof** | Individual messages from a WTS can be submitted on-chain via `proof_message` for blockchain-level timestamp verification. |
|
|
486
|
-
|
|
487
|
-
---
|
|
488
|
-
|
|
489
|
-
## Relationship with Other Components
|
|
490
|
-
|
|
491
|
-
| Component | Relationship |
|
|
492
|
-
|-----------|-------------|
|
|
493
|
-
| **Messenger** | WTS files are generated from Messenger conversation history. They can also be sent as file attachments. |
|
|
494
|
-
| **Account** | Signatures are created using local Account keys (Falcon-512 keypairs). |
|
|
495
|
-
| **Guard** | Messages may reference `guardAddress` if verified by a Guard during sending. |
|
|
496
|
-
| **Passport** | Messages may reference `passportAddress` if the sender used verified credentials. |
|
|
497
|
-
| **Proof** | Individual WTS messages can be submitted on-chain via `proof_message` for permanent timestamping. |
|
|
498
|
-
| **Arbitration** | WTS files serve as primary evidence in dispute resolution workflows. |
|
|
499
|
-
|
|
500
|
-
---
|
|
501
|
-
|
|
502
|
-
## File Extension & MIME Type
|
|
503
|
-
|
|
504
|
-
| Property | Value |
|
|
505
|
-
|----------|-------|
|
|
506
|
-
| File extension | `.wts` |
|
|
507
|
-
| MIME type | `application/json` |
|
|
508
|
-
| Encoding | UTF-8 |
|
|
509
|
-
|
|
510
|
-
---
|
|
511
|
-
|
|
512
|
-
## Server Public Key Optimization
|
|
513
|
-
|
|
514
|
-
To minimize file size, server public keys are stored in a deduplicated array (`meta.serverPublicKeys[]`) rather than inline in each message. Messages reference keys by array index via `serverPublicKeyIndex`.
|
|
515
|
-
|
|
516
|
-
**Example:**
|
|
517
|
-
|
|
518
|
-
```json
|
|
519
|
-
{
|
|
520
|
-
"meta": {
|
|
521
|
-
"serverPublicKeys": [
|
|
522
|
-
{ "publicKey": "0xaaaa...", "validFrom": 0 },
|
|
523
|
-
{ "publicKey": "0xbbbb...", "validFrom": 1 }
|
|
524
|
-
]
|
|
525
|
-
},
|
|
526
|
-
"payload": {
|
|
527
|
-
"messages": [
|
|
528
|
-
{ "serverPublicKeyIndex": 0, ... },
|
|
529
|
-
{ "serverPublicKeyIndex": 0, ... },
|
|
530
|
-
{ "serverPublicKeyIndex": 1, ... }
|
|
531
|
-
]
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
```
|
|
535
|
-
|
|
536
|
-
This is particularly effective for long conversations where the server key rarely changes — a 900-byte public key is stored once instead of being repeated in every message.
|