viz-js-lib 0.11.0 → 0.12.4
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/.qoder/docs/spec/viz-dns-nameserver-spec.md +982 -0
- package/.qoder/docs/viz-cpp-node-docs/data-types.md +322 -0
- package/.qoder/docs/viz-cpp-node-docs/index.md +160 -0
- package/.qoder/docs/viz-cpp-node-docs/op-account-market.md +236 -0
- package/.qoder/docs/viz-cpp-node-docs/op-account.md +199 -0
- package/.qoder/docs/viz-cpp-node-docs/op-award.md +162 -0
- package/.qoder/docs/viz-cpp-node-docs/op-committee.md +193 -0
- package/.qoder/docs/viz-cpp-node-docs/op-content.md +157 -0
- package/.qoder/docs/viz-cpp-node-docs/op-escrow.md +224 -0
- package/.qoder/docs/viz-cpp-node-docs/op-invite.md +219 -0
- package/.qoder/docs/viz-cpp-node-docs/op-proposal.md +229 -0
- package/.qoder/docs/viz-cpp-node-docs/op-recovery.md +188 -0
- package/.qoder/docs/viz-cpp-node-docs/op-subscription.md +146 -0
- package/.qoder/docs/viz-cpp-node-docs/op-transfer-vesting.md +224 -0
- package/.qoder/docs/viz-cpp-node-docs/op-witness.md +252 -0
- package/.qoder/docs/viz-cpp-node-docs/plugins.md +887 -0
- package/.qoder/docs/viz-cpp-node-docs/virtual-operations.md +513 -0
- package/.qoder/repowiki/en/content/API Reference/API Reference.md +724 -0
- package/.qoder/repowiki/en/content/API Reference/Configuration Options.md +410 -0
- package/.qoder/repowiki/en/content/API Reference/Core API Methods.md +547 -0
- package/.qoder/repowiki/en/content/API Reference/Streaming APIs.md +380 -0
- package/.qoder/repowiki/en/content/API Reference/Transport Layer.md +341 -0
- package/.qoder/repowiki/en/content/API Reference/VIZ Blockchain Operations Coverage Status.md +427 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Authentication & Cryptography.md +430 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Digital Signatures.md +462 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Key Management.md +456 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Memo Encryption.md +331 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Security Practices.md +488 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Broadcast Transactions.md +432 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Network Broadcasting.md +418 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Operation Construction.md +352 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Transaction Preparation.md +353 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Transaction Signing.md +404 -0
- package/.qoder/repowiki/en/content/Data Serialization/Data Serialization.md +540 -0
- package/.qoder/repowiki/en/content/Data Serialization/Encoding & Decoding.md +463 -0
- package/.qoder/repowiki/en/content/Data Serialization/Object Templates.md +413 -0
- package/.qoder/repowiki/en/content/Data Serialization/Type System.md +514 -0
- package/.qoder/repowiki/en/content/Data Serialization/Validation Rules.md +439 -0
- package/.qoder/repowiki/en/content/Examples & Tutorials.md +485 -0
- package/.qoder/repowiki/en/content/Getting Started.md +345 -0
- package/.qoder/repowiki/en/content/Testing & Development.md +637 -0
- package/.qoder/repowiki/en/content/Utilities & Helpers.md +557 -0
- package/.qoder/repowiki/en/meta/repowiki-metadata.json +1 -0
- package/VIZ-JS-LIB-COVERAGE-STATUS.md +356 -0
- package/config.json +3 -1
- package/dist/statistics.html +1 -1
- package/dist/viz-tests.min.js +32 -42
- package/dist/viz-tests.min.js.gz +0 -0
- package/dist/viz.min.js +8 -18
- package/dist/viz.min.js.gz +0 -0
- package/lib/api/methods.js +24 -0
- package/lib/auth/serializer/src/ChainTypes.js +2 -1
- package/lib/auth/serializer/src/operations.js +35 -2
- package/lib/broadcast/index.js +29 -15
- package/lib/broadcast/operations.js +4 -0
- package/lib/dns.js +658 -0
- package/lib/index.js +3 -1
- package/package.json +3 -2
- package/test/dns.test.js +395 -0
- package/webpack/makeConfig.js +3 -0
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
# Transaction Signing
|
|
2
|
+
|
|
3
|
+
<cite>
|
|
4
|
+
**Referenced Files in This Document**
|
|
5
|
+
- [broadcast/index.js](file://src/broadcast/index.js)
|
|
6
|
+
- [broadcast/operations.js](file://src/broadcast/operations.js)
|
|
7
|
+
- [broadcast/helpers.js](file://src/broadcast/helpers.js)
|
|
8
|
+
- [auth/index.js](file://src/auth/index.js)
|
|
9
|
+
- [auth/ecc/index.js](file://src/auth/ecc/index.js)
|
|
10
|
+
- [auth/ecc/src/signature.js](file://src/auth/ecc/src/signature.js)
|
|
11
|
+
- [auth/ecc/src/key_private.js](file://src/auth/ecc/src/key_private.js)
|
|
12
|
+
- [auth/ecc/src/key_public.js](file://src/auth/ecc/src/key_public.js)
|
|
13
|
+
- [auth/ecc/src/ecdsa.js](file://src/auth/ecc/src/ecdsa.js)
|
|
14
|
+
- [auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js)
|
|
15
|
+
- [config.js](file://src/config.js)
|
|
16
|
+
- [test/broadcast.test.js](file://test/broadcast.test.js)
|
|
17
|
+
- [examples/broadcast.html](file://examples/broadcast.html)
|
|
18
|
+
- [README.md](file://README.md)
|
|
19
|
+
</cite>
|
|
20
|
+
|
|
21
|
+
## Table of Contents
|
|
22
|
+
1. [Introduction](#introduction)
|
|
23
|
+
2. [Project Structure](#project-structure)
|
|
24
|
+
3. [Core Components](#core-components)
|
|
25
|
+
4. [Architecture Overview](#architecture-overview)
|
|
26
|
+
5. [Detailed Component Analysis](#detailed-component-analysis)
|
|
27
|
+
6. [Dependency Analysis](#dependency-analysis)
|
|
28
|
+
7. [Performance Considerations](#performance-considerations)
|
|
29
|
+
8. [Troubleshooting Guide](#troubleshooting-guide)
|
|
30
|
+
9. [Conclusion](#conclusion)
|
|
31
|
+
10. [Appendices](#appendices)
|
|
32
|
+
|
|
33
|
+
## Introduction
|
|
34
|
+
This document explains the transaction signing processes in the VIZ broadcast system. It covers how the broadcaster integrates with the authentication module, how private keys are handled, and how cryptographic signing is performed. It documents the signTransaction workflow, key role assignment, and multi-signature support. It also includes error handling for invalid keys and signature validation, along with security considerations. Practical examples demonstrate signing with different key types, batch signing operations, and debugging signature-related issues.
|
|
35
|
+
|
|
36
|
+
## Project Structure
|
|
37
|
+
The transaction signing pipeline spans three primary areas:
|
|
38
|
+
- Broadcasting: constructs transactions, injects chain metadata, and signs/broadcasts them.
|
|
39
|
+
- Authentication: generates keys, validates WIF, and performs cryptographic signing.
|
|
40
|
+
- Serialization: defines transaction and signed transaction structures for encoding and hashing.
|
|
41
|
+
|
|
42
|
+
```mermaid
|
|
43
|
+
graph TB
|
|
44
|
+
subgraph "Broadcast Layer"
|
|
45
|
+
BR["src/broadcast/index.js"]
|
|
46
|
+
BO["src/broadcast/operations.js"]
|
|
47
|
+
BH["src/broadcast/helpers.js"]
|
|
48
|
+
end
|
|
49
|
+
subgraph "Auth Layer"
|
|
50
|
+
AI["src/auth/index.js"]
|
|
51
|
+
AEI["src/auth/ecc/index.js"]
|
|
52
|
+
SIG["src/auth/ecc/src/signature.js"]
|
|
53
|
+
PRI["src/auth/ecc/src/key_private.js"]
|
|
54
|
+
PUB["src/auth/ecc/src/key_public.js"]
|
|
55
|
+
ECS["src/auth/ecc/src/ecdsa.js"]
|
|
56
|
+
end
|
|
57
|
+
subgraph "Serialization"
|
|
58
|
+
OPS["src/auth/serializer/src/operations.js"]
|
|
59
|
+
end
|
|
60
|
+
subgraph "Config"
|
|
61
|
+
CFG["src/config.js"]
|
|
62
|
+
end
|
|
63
|
+
BR --> AI
|
|
64
|
+
BR --> OPS
|
|
65
|
+
BR --> CFG
|
|
66
|
+
AI --> SIG
|
|
67
|
+
AI --> PRI
|
|
68
|
+
AI --> PUB
|
|
69
|
+
SIG --> ECS
|
|
70
|
+
BH --> BR
|
|
71
|
+
BO --> BR
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Diagram sources**
|
|
75
|
+
- [broadcast/index.js](file://src/broadcast/index.js#L1-L137)
|
|
76
|
+
- [broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
77
|
+
- [broadcast/helpers.js](file://src/broadcast/helpers.js#L1-L82)
|
|
78
|
+
- [auth/index.js](file://src/auth/index.js#L1-L133)
|
|
79
|
+
- [auth/ecc/index.js](file://src/auth/ecc/index.js#L1-L13)
|
|
80
|
+
- [auth/ecc/src/signature.js](file://src/auth/ecc/src/signature.js#L1-L163)
|
|
81
|
+
- [auth/ecc/src/key_private.js](file://src/auth/ecc/src/key_private.js#L1-L172)
|
|
82
|
+
- [auth/ecc/src/key_public.js](file://src/auth/ecc/src/key_public.js#L1-L170)
|
|
83
|
+
- [auth/ecc/src/ecdsa.js](file://src/auth/ecc/src/ecdsa.js#L1-L219)
|
|
84
|
+
- [auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L73-L125)
|
|
85
|
+
- [config.js](file://src/config.js#L1-L10)
|
|
86
|
+
|
|
87
|
+
**Section sources**
|
|
88
|
+
- [broadcast/index.js](file://src/broadcast/index.js#L1-L137)
|
|
89
|
+
- [auth/index.js](file://src/auth/index.js#L1-L133)
|
|
90
|
+
- [auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L73-L125)
|
|
91
|
+
|
|
92
|
+
## Core Components
|
|
93
|
+
- Broadcaster.send: orchestrates transaction preparation, signing via the authentication module, and broadcasting to the node.
|
|
94
|
+
- Auth.signTransaction: computes signatures over the serialized transaction using the configured chain ID and provided private keys.
|
|
95
|
+
- Serializer transaction/singed_transaction: defines the wire format for transactions and signed transactions, ensuring deterministic hashing.
|
|
96
|
+
- Key management: WIF generation, validation, and conversion between WIF and public keys.
|
|
97
|
+
|
|
98
|
+
Key responsibilities:
|
|
99
|
+
- Transaction preparation: fetches dynamic global properties, sets reference block and expiration.
|
|
100
|
+
- Signing: iterates over provided keys, signs the typed transaction buffer with the chain ID prefix.
|
|
101
|
+
- Broadcasting: sends the signed transaction to the node via configured transport.
|
|
102
|
+
|
|
103
|
+
**Section sources**
|
|
104
|
+
- [broadcast/index.js](file://src/broadcast/index.js#L24-L84)
|
|
105
|
+
- [auth/index.js](file://src/auth/index.js#L107-L130)
|
|
106
|
+
- [auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L73-L125)
|
|
107
|
+
|
|
108
|
+
## Architecture Overview
|
|
109
|
+
The signing workflow integrates the broadcast layer with the authentication and serialization layers.
|
|
110
|
+
|
|
111
|
+
```mermaid
|
|
112
|
+
sequenceDiagram
|
|
113
|
+
participant Client as "Client Code"
|
|
114
|
+
participant BR as "Broadcaster.send"
|
|
115
|
+
participant API as "Node API"
|
|
116
|
+
participant AUTH as "Auth.signTransaction"
|
|
117
|
+
participant SIG as "Signature.signBuffer"
|
|
118
|
+
participant NODE as "Blockchain Node"
|
|
119
|
+
Client->>BR : "send(tx, keys, callback)"
|
|
120
|
+
BR->>API : "getDynamicGlobalPropertiesAsync()"
|
|
121
|
+
API-->>BR : "dynamic properties"
|
|
122
|
+
BR->>BR : "_prepareTransaction(tx)"
|
|
123
|
+
BR->>AUTH : "signTransaction(transaction, keys)"
|
|
124
|
+
AUTH->>SIG : "signBuffer(chainID + txBuffer, privateKey)"
|
|
125
|
+
SIG-->>AUTH : "signature buffer"
|
|
126
|
+
AUTH-->>BR : "signed_transaction"
|
|
127
|
+
BR->>NODE : "broadcastTransaction*Async(signedTransaction)"
|
|
128
|
+
NODE-->>BR : "result"
|
|
129
|
+
BR-->>Client : "signed transaction"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Diagram sources**
|
|
133
|
+
- [broadcast/index.js](file://src/broadcast/index.js#L24-L47)
|
|
134
|
+
- [auth/index.js](file://src/auth/index.js#L107-L130)
|
|
135
|
+
- [auth/ecc/src/signature.js](file://src/auth/ecc/src/signature.js#L62-L98)
|
|
136
|
+
- [auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L73-L125)
|
|
137
|
+
|
|
138
|
+
## Detailed Component Analysis
|
|
139
|
+
|
|
140
|
+
### Broadcaster.send and Transaction Preparation
|
|
141
|
+
- Prepares transaction by fetching dynamic global properties and setting reference block and expiration.
|
|
142
|
+
- Signs the prepared transaction using the authentication module’s signTransaction.
|
|
143
|
+
- Broadcasts the signed transaction via configured transport.
|
|
144
|
+
|
|
145
|
+
```mermaid
|
|
146
|
+
flowchart TD
|
|
147
|
+
Start(["Entry: send(tx, keys, callback)"]) --> Prepare["_prepareTransaction(tx)"]
|
|
148
|
+
Prepare --> FetchProps["getDynamicGlobalPropertiesAsync()"]
|
|
149
|
+
FetchProps --> SetRef["Set ref_block_num/prefix<br/>and expiration"]
|
|
150
|
+
SetRef --> Sign["nodeAuth.signTransaction(transaction, keys)"]
|
|
151
|
+
Sign --> Broadcast["broadcastTransaction*Async(signedTransaction)"]
|
|
152
|
+
Broadcast --> Done(["Return signed transaction"])
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Diagram sources**
|
|
156
|
+
- [broadcast/index.js](file://src/broadcast/index.js#L24-L84)
|
|
157
|
+
|
|
158
|
+
**Section sources**
|
|
159
|
+
- [broadcast/index.js](file://src/broadcast/index.js#L24-L84)
|
|
160
|
+
|
|
161
|
+
### Auth.signTransaction Workflow
|
|
162
|
+
- Reads the chain ID from configuration and serializes the transaction to a buffer.
|
|
163
|
+
- Iterates over provided keys, signs the concatenated chain ID + transaction buffer, and accumulates signatures.
|
|
164
|
+
- Returns a signed transaction object with the collected signatures.
|
|
165
|
+
|
|
166
|
+
```mermaid
|
|
167
|
+
flowchart TD
|
|
168
|
+
AStart(["Entry: signTransaction(trx, keys)"]) --> CID["Load chain_id from config"]
|
|
169
|
+
CID --> Serialize["Serialize transaction to buffer"]
|
|
170
|
+
Serialize --> Loop{"For each key in keys"}
|
|
171
|
+
Loop --> |Sign| SignStep["Signature.signBuffer(concat(chainID, txBuffer), key)"]
|
|
172
|
+
SignStep --> Acc["Append signature to list"]
|
|
173
|
+
Acc --> Loop
|
|
174
|
+
Loop --> |Done| Wrap["signed_transaction.toObject({trx, signatures})"]
|
|
175
|
+
Wrap --> AEnd(["Return signed transaction"])
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Diagram sources**
|
|
179
|
+
- [auth/index.js](file://src/auth/index.js#L107-L130)
|
|
180
|
+
- [auth/ecc/src/signature.js](file://src/auth/ecc/src/signature.js#L62-L98)
|
|
181
|
+
- [auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L73-L125)
|
|
182
|
+
|
|
183
|
+
**Section sources**
|
|
184
|
+
- [auth/index.js](file://src/auth/index.js#L107-L130)
|
|
185
|
+
- [auth/ecc/src/signature.js](file://src/auth/ecc/src/signature.js#L62-L98)
|
|
186
|
+
|
|
187
|
+
### Multi-Signature Support and Key Role Assignment
|
|
188
|
+
- The broadcast layer supports multiple keys passed to signTransaction.
|
|
189
|
+
- Operations metadata includes roles (e.g., active, master, regular) that guide which key to supply for signing.
|
|
190
|
+
- The helpers module demonstrates adding/removing account authorities for delegated signing scenarios.
|
|
191
|
+
|
|
192
|
+
```mermaid
|
|
193
|
+
classDiagram
|
|
194
|
+
class Broadcaster {
|
|
195
|
+
+send(tx, keys, callback)
|
|
196
|
+
+_prepareTransaction(tx)
|
|
197
|
+
}
|
|
198
|
+
class OperationsMeta {
|
|
199
|
+
+roles
|
|
200
|
+
+operation
|
|
201
|
+
+params
|
|
202
|
+
}
|
|
203
|
+
class Helpers {
|
|
204
|
+
+addAccountAuth(activeWif, username, authorizedUsername, role)
|
|
205
|
+
+removeAccountAuth(activeWif, username, authorizedUsername, role)
|
|
206
|
+
}
|
|
207
|
+
class Auth {
|
|
208
|
+
+signTransaction(trx, keys)
|
|
209
|
+
}
|
|
210
|
+
Broadcaster --> Auth : "uses"
|
|
211
|
+
Broadcaster --> OperationsMeta : "reads roles"
|
|
212
|
+
Helpers --> Broadcaster : "complements"
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Diagram sources**
|
|
216
|
+
- [broadcast/index.js](file://src/broadcast/index.js#L89-L129)
|
|
217
|
+
- [broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
218
|
+
- [broadcast/helpers.js](file://src/broadcast/helpers.js#L6-L80)
|
|
219
|
+
- [auth/index.js](file://src/auth/index.js#L107-L130)
|
|
220
|
+
|
|
221
|
+
**Section sources**
|
|
222
|
+
- [broadcast/index.js](file://src/broadcast/index.js#L89-L129)
|
|
223
|
+
- [broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
224
|
+
- [broadcast/helpers.js](file://src/broadcast/helpers.js#L6-L80)
|
|
225
|
+
|
|
226
|
+
### Cryptographic Signing Internals
|
|
227
|
+
- Signature.signBufferSha256 enforces a 32-byte hash input and uses deterministic nonce generation.
|
|
228
|
+
- The signing process ensures canonical signature format and derives recovery parameter for public key recovery.
|
|
229
|
+
- Verification uses ECDSA with proper range checks and curve validation.
|
|
230
|
+
|
|
231
|
+
```mermaid
|
|
232
|
+
classDiagram
|
|
233
|
+
class Signature {
|
|
234
|
+
+fromBuffer(buf)
|
|
235
|
+
+toBuffer()
|
|
236
|
+
+recoverPublicKey(sha256)
|
|
237
|
+
+signBuffer(buf, privateKey)
|
|
238
|
+
+signBufferSha256(buf32, privateKey)
|
|
239
|
+
+verifyBuffer(buf, publicKey)
|
|
240
|
+
+verifyHash(hash, publicKey)
|
|
241
|
+
}
|
|
242
|
+
class PrivateKey {
|
|
243
|
+
+fromWif(wif)
|
|
244
|
+
+toWif()
|
|
245
|
+
+toPublicKey()
|
|
246
|
+
}
|
|
247
|
+
class PublicKey {
|
|
248
|
+
+fromString(str, prefix)
|
|
249
|
+
+toPublicKeyString(prefix)
|
|
250
|
+
}
|
|
251
|
+
class ECSignature {
|
|
252
|
+
+toDER()
|
|
253
|
+
}
|
|
254
|
+
Signature --> PrivateKey : "uses"
|
|
255
|
+
Signature --> PublicKey : "verifies against"
|
|
256
|
+
Signature --> ECSignature : "produces"
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Diagram sources**
|
|
260
|
+
- [auth/ecc/src/signature.js](file://src/auth/ecc/src/signature.js#L9-L163)
|
|
261
|
+
- [auth/ecc/src/key_private.js](file://src/auth/ecc/src/key_private.js#L13-L172)
|
|
262
|
+
- [auth/ecc/src/key_public.js](file://src/auth/ecc/src/key_public.js#L13-L170)
|
|
263
|
+
- [auth/ecc/src/ecdsa.js](file://src/auth/ecc/src/ecdsa.js#L65-L137)
|
|
264
|
+
|
|
265
|
+
**Section sources**
|
|
266
|
+
- [auth/ecc/src/signature.js](file://src/auth/ecc/src/signature.js#L62-L121)
|
|
267
|
+
- [auth/ecc/src/key_private.js](file://src/auth/ecc/src/key_private.js#L55-L81)
|
|
268
|
+
- [auth/ecc/src/key_public.js](file://src/auth/ecc/src/key_public.js#L86-L100)
|
|
269
|
+
- [auth/ecc/src/ecdsa.js](file://src/auth/ecc/src/ecdsa.js#L65-L137)
|
|
270
|
+
|
|
271
|
+
### Transaction and Signed Transaction Structures
|
|
272
|
+
- transaction: defines ref_block_num, ref_block_prefix, expiration, operations, and extensions.
|
|
273
|
+
- signed_transaction: extends transaction with a signatures array of 65-byte signature buffers.
|
|
274
|
+
|
|
275
|
+
```mermaid
|
|
276
|
+
erDiagram
|
|
277
|
+
TRANSACTION {
|
|
278
|
+
uint16 ref_block_num
|
|
279
|
+
uint32 ref_block_prefix
|
|
280
|
+
time_point_sec expiration
|
|
281
|
+
array~operation~ operations
|
|
282
|
+
set future_extensions extensions
|
|
283
|
+
}
|
|
284
|
+
SIGNED_TRANSACTION {
|
|
285
|
+
uint16 ref_block_num
|
|
286
|
+
uint32 ref_block_prefix
|
|
287
|
+
time_point_sec expiration
|
|
288
|
+
array~operation~ operations
|
|
289
|
+
set future_extensions extensions
|
|
290
|
+
array~bytes65~ signatures
|
|
291
|
+
}
|
|
292
|
+
SIGNED_TRANSACTION }o--|| TRANSACTION : "includes"
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Diagram sources**
|
|
296
|
+
- [auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L73-L125)
|
|
297
|
+
|
|
298
|
+
**Section sources**
|
|
299
|
+
- [auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L73-L125)
|
|
300
|
+
|
|
301
|
+
## Dependency Analysis
|
|
302
|
+
- Broadcaster depends on:
|
|
303
|
+
- Node API for dynamic properties and broadcasting.
|
|
304
|
+
- Auth.signTransaction for cryptographic signing.
|
|
305
|
+
- Serializer transaction/singed_transaction for deterministic hashing.
|
|
306
|
+
- Config for chain ID and broadcast behavior.
|
|
307
|
+
- Auth depends on:
|
|
308
|
+
- ECC primitives (Signature, PrivateKey, PublicKey).
|
|
309
|
+
- Serializer transaction for buffer serialization.
|
|
310
|
+
- Config for address prefix and chain ID.
|
|
311
|
+
|
|
312
|
+
```mermaid
|
|
313
|
+
graph LR
|
|
314
|
+
BR["broadcast/index.js"] --> API["node API"]
|
|
315
|
+
BR --> AUTH["auth/index.js"]
|
|
316
|
+
BR --> CFG["config.js"]
|
|
317
|
+
AUTH --> SIGMOD["auth/ecc/src/signature.js"]
|
|
318
|
+
AUTH --> PRIKEY["auth/ecc/src/key_private.js"]
|
|
319
|
+
AUTH --> PUBKEY["auth/ecc/src/key_public.js"]
|
|
320
|
+
AUTH --> OPSER["auth/serializer/src/operations.js"]
|
|
321
|
+
SIGMOD --> ECS["auth/ecc/src/ecdsa.js"]
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Diagram sources**
|
|
325
|
+
- [broadcast/index.js](file://src/broadcast/index.js#L1-L15)
|
|
326
|
+
- [auth/index.js](file://src/auth/index.js#L1-L16)
|
|
327
|
+
- [auth/ecc/src/signature.js](file://src/auth/ecc/src/signature.js#L1-L8)
|
|
328
|
+
- [auth/ecc/src/key_private.js](file://src/auth/ecc/src/key_private.js#L1-L8)
|
|
329
|
+
- [auth/ecc/src/key_public.js](file://src/auth/ecc/src/key_public.js#L1-L8)
|
|
330
|
+
- [auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L73-L81)
|
|
331
|
+
- [config.js](file://src/config.js#L1-L10)
|
|
332
|
+
|
|
333
|
+
**Section sources**
|
|
334
|
+
- [broadcast/index.js](file://src/broadcast/index.js#L1-L15)
|
|
335
|
+
- [auth/index.js](file://src/auth/index.js#L1-L16)
|
|
336
|
+
|
|
337
|
+
## Performance Considerations
|
|
338
|
+
- Deterministic nonce generation avoids retries in most cases; however, the signing loop includes a retry mechanism to produce canonical signatures. This can increase latency under rare conditions.
|
|
339
|
+
- Batch signing: pass multiple keys to signTransaction to accumulate multiple signatures efficiently in a single pass.
|
|
340
|
+
- Avoid unnecessary re-serialization: reuse the prepared transaction object to prevent redundant serialization costs.
|
|
341
|
+
|
|
342
|
+
[No sources needed since this section provides general guidance]
|
|
343
|
+
|
|
344
|
+
## Troubleshooting Guide
|
|
345
|
+
Common issues and resolutions:
|
|
346
|
+
- Invalid WIF or mismatched public key:
|
|
347
|
+
- Validate WIF using Auth.isWif and Auth.wifIsValid.
|
|
348
|
+
- Ensure the private key corresponds to the intended public key.
|
|
349
|
+
- Signature verification failures:
|
|
350
|
+
- Confirm the chain ID matches the network configuration.
|
|
351
|
+
- Verify the transaction buffer serialization aligns with the node’s expectations.
|
|
352
|
+
- Missing or incorrect roles:
|
|
353
|
+
- Ensure the operation’s roles match the supplied keys.
|
|
354
|
+
- Use helpers to manage account authorities when delegating signing permissions.
|
|
355
|
+
- Debugging signature-related issues:
|
|
356
|
+
- Enable debug logging around signing and broadcasting.
|
|
357
|
+
- Inspect the raw transaction buffer and signatures to confirm correctness.
|
|
358
|
+
|
|
359
|
+
Practical references:
|
|
360
|
+
- Transaction preparation and signing lifecycle: [broadcast/index.js](file://src/broadcast/index.js#L24-L84)
|
|
361
|
+
- Signing implementation and signature format: [auth/index.js](file://src/auth/index.js#L107-L130), [auth/ecc/src/signature.js](file://src/auth/ecc/src/signature.js#L62-L98)
|
|
362
|
+
- Key validation utilities: [auth/index.js](file://src/auth/index.js#L65-L101)
|
|
363
|
+
- Authority management helpers: [broadcast/helpers.js](file://src/broadcast/helpers.js#L6-L80)
|
|
364
|
+
- Example usage patterns: [examples/broadcast.html](file://examples/broadcast.html#L15-L103), [README.md](file://README.md#L55-L64)
|
|
365
|
+
|
|
366
|
+
**Section sources**
|
|
367
|
+
- [broadcast/index.js](file://src/broadcast/index.js#L24-L84)
|
|
368
|
+
- [auth/index.js](file://src/auth/index.js#L65-L101)
|
|
369
|
+
- [auth/ecc/src/signature.js](file://src/auth/ecc/src/signature.js#L62-L98)
|
|
370
|
+
- [broadcast/helpers.js](file://src/broadcast/helpers.js#L6-L80)
|
|
371
|
+
- [examples/broadcast.html](file://examples/broadcast.html#L15-L103)
|
|
372
|
+
- [README.md](file://README.md#L55-L64)
|
|
373
|
+
|
|
374
|
+
## Conclusion
|
|
375
|
+
The VIZ broadcast system integrates tightly with the authentication and serialization layers to securely sign and broadcast transactions. By leveraging deterministic signing, role-aware key assignment, and multi-signature support, applications can reliably transact on the VIZ blockchain. Proper configuration of chain ID, careful key handling, and robust error checking are essential for secure and reliable operation.
|
|
376
|
+
|
|
377
|
+
[No sources needed since this section summarizes without analyzing specific files]
|
|
378
|
+
|
|
379
|
+
## Appendices
|
|
380
|
+
|
|
381
|
+
### Practical Examples
|
|
382
|
+
|
|
383
|
+
- Signing with a single key (regular):
|
|
384
|
+
- Use the generated WIF for the desired role and call the appropriate broadcast method.
|
|
385
|
+
- Reference: [examples/broadcast.html](file://examples/broadcast.html#L15-L25), [README.md](file://README.md#L55-L64)
|
|
386
|
+
|
|
387
|
+
- Batch signing with multiple keys:
|
|
388
|
+
- Supply multiple keys to signTransaction to collect multiple signatures in one pass.
|
|
389
|
+
- Reference: [auth/index.js](file://src/auth/index.js#L107-L130)
|
|
390
|
+
|
|
391
|
+
- Delegated signing with account authorities:
|
|
392
|
+
- Add or remove authorized accounts for a given role using helpers.
|
|
393
|
+
- Reference: [broadcast/helpers.js](file://src/broadcast/helpers.js#L6-L80)
|
|
394
|
+
|
|
395
|
+
- Verifying signatures:
|
|
396
|
+
- Use Signature.verifyHash or Signature.verifyBuffer to validate signatures against public keys.
|
|
397
|
+
- Reference: [auth/ecc/src/signature.js](file://src/auth/ecc/src/signature.js#L115-L121)
|
|
398
|
+
|
|
399
|
+
**Section sources**
|
|
400
|
+
- [examples/broadcast.html](file://examples/broadcast.html#L15-L103)
|
|
401
|
+
- [README.md](file://README.md#L55-L64)
|
|
402
|
+
- [auth/index.js](file://src/auth/index.js#L107-L130)
|
|
403
|
+
- [broadcast/helpers.js](file://src/broadcast/helpers.js#L6-L80)
|
|
404
|
+
- [auth/ecc/src/signature.js](file://src/auth/ecc/src/signature.js#L115-L121)
|