@bsv/sdk 1.9.3 → 1.9.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.
Files changed (60) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/docs/fast-docs.png +0 -0
  3. package/docs/index.md +49 -44
  4. package/docs/swagger.png +0 -0
  5. package/package.json +1 -1
  6. package/docs/MARKDOWN_VALIDATION_GUIDE.md +0 -175
  7. package/docs/concepts/beef.md +0 -92
  8. package/docs/concepts/chain-tracking.md +0 -134
  9. package/docs/concepts/decentralized-identity.md +0 -221
  10. package/docs/concepts/fees.md +0 -249
  11. package/docs/concepts/identity-certificates.md +0 -307
  12. package/docs/concepts/index.md +0 -77
  13. package/docs/concepts/key-management.md +0 -185
  14. package/docs/concepts/script-templates.md +0 -176
  15. package/docs/concepts/sdk-philosophy.md +0 -80
  16. package/docs/concepts/signatures.md +0 -194
  17. package/docs/concepts/spv-verification.md +0 -118
  18. package/docs/concepts/transaction-encoding.md +0 -167
  19. package/docs/concepts/transaction-structure.md +0 -67
  20. package/docs/concepts/trust-model.md +0 -139
  21. package/docs/concepts/verification.md +0 -250
  22. package/docs/concepts/wallet-integration.md +0 -101
  23. package/docs/guides/development-wallet-setup.md +0 -374
  24. package/docs/guides/direct-transaction-creation.md +0 -147
  25. package/docs/guides/http-client-configuration.md +0 -488
  26. package/docs/guides/index.md +0 -138
  27. package/docs/guides/large-transactions.md +0 -448
  28. package/docs/guides/multisig-transactions.md +0 -792
  29. package/docs/guides/security-best-practices.md +0 -494
  30. package/docs/guides/transaction-batching.md +0 -132
  31. package/docs/guides/transaction-signing-methods.md +0 -419
  32. package/docs/reference/arc-config.md +0 -698
  33. package/docs/reference/brc-100.md +0 -33
  34. package/docs/reference/configuration.md +0 -835
  35. package/docs/reference/debugging.md +0 -705
  36. package/docs/reference/errors.md +0 -597
  37. package/docs/reference/index.md +0 -111
  38. package/docs/reference/network-config.md +0 -914
  39. package/docs/reference/op-codes.md +0 -325
  40. package/docs/reference/transaction-signatures.md +0 -95
  41. package/docs/tutorials/advanced-transaction.md +0 -572
  42. package/docs/tutorials/aes-encryption.md +0 -949
  43. package/docs/tutorials/authfetch-tutorial.md +0 -986
  44. package/docs/tutorials/ecdh-key-exchange.md +0 -549
  45. package/docs/tutorials/elliptic-curve-fundamentals.md +0 -606
  46. package/docs/tutorials/error-handling.md +0 -1216
  47. package/docs/tutorials/first-transaction-low-level.md +0 -205
  48. package/docs/tutorials/first-transaction.md +0 -275
  49. package/docs/tutorials/hashes-and-hmacs.md +0 -788
  50. package/docs/tutorials/identity-management.md +0 -729
  51. package/docs/tutorials/index.md +0 -219
  52. package/docs/tutorials/key-management.md +0 -538
  53. package/docs/tutorials/protowallet-development.md +0 -743
  54. package/docs/tutorials/script-construction.md +0 -690
  55. package/docs/tutorials/spv-merkle-proofs.md +0 -685
  56. package/docs/tutorials/testnet-transactions-low-level.md +0 -359
  57. package/docs/tutorials/transaction-broadcasting.md +0 -538
  58. package/docs/tutorials/transaction-types.md +0 -420
  59. package/docs/tutorials/type-42.md +0 -568
  60. package/docs/tutorials/uhrp-storage.md +0 -599
@@ -1,307 +0,0 @@
1
- # Identity Certificates
2
-
3
- Understanding how cryptographic certificates work to establish trust and verify identity claims in decentralized systems.
4
-
5
- ## What are Identity Certificates?
6
-
7
- Think of identity certificates as digital testimonials that can't be forged. Just like a diploma proves you graduated from a university, or a driver's license proves you're authorized to drive, identity certificates prove specific claims about who you are or what you're authorized to do.
8
-
9
- The key difference is that these digital certificates use cryptographic signatures instead of physical security features, making them verifiable by anyone with the right tools, anywhere in the world.
10
-
11
- ## How Certificates Create Trust
12
-
13
- ### The Trust Problem
14
-
15
- In the digital world, it's easy to claim anything about yourself. Anyone can create a website saying they're a doctor, lawyer, or certified professional. How do you know who to trust?
16
-
17
- ### The Certificate Solution
18
-
19
- Certificates solve this by having trusted third parties vouch for specific claims. When a university issues you a digital diploma certificate, they're cryptographically signing a statement that says "We verify that this person graduated from our program."
20
-
21
- Anyone can then verify:
22
-
23
- 1. **The certificate is authentic** (cryptographic signature is valid)
24
- 2. **It hasn't been tampered with** (any changes would break the signature)
25
- 3. **It's still valid** (hasn't expired or been revoked)
26
- 4. **The issuer is trustworthy** (you trust the university)
27
-
28
- ## Types of Certificates
29
-
30
- ### Self-Signed Certificates
31
-
32
- These are claims you make about yourself, like "My name is John Doe" or "My email is <john@example.com>." While anyone can create these, they serve as a starting point for building your digital identity.
33
-
34
- **When they're useful:**
35
-
36
- - Basic profile information
37
- - Contact preferences
38
- - Personal statements
39
- - Starting point for identity building
40
-
41
- **Limitations:**
42
-
43
- - Low trust value (anyone can claim anything)
44
- - Not suitable for high-stakes verification
45
- - Mainly useful for discovery and basic interaction
46
-
47
- ### Peer-Verified Certificates
48
-
49
- These are endorsements from other users who can vouch for specific claims about you. Like professional references or character witnesses, they carry more weight when they come from trusted sources.
50
-
51
- **Examples:**
52
-
53
- - Colleague endorsing your professional skills
54
- - Friend confirming your identity
55
- - Community member vouching for your reputation
56
- - Business partner confirming successful transactions
57
-
58
- ### Institutional Certificates
59
-
60
- These come from recognized organizations with established authority and verification processes. They carry the most weight because the issuers have reputations to protect and rigorous verification procedures.
61
-
62
- **Examples:**
63
-
64
- - University degree certificates
65
- - Professional licensing board certifications
66
- - Government-issued identity documents
67
- - Industry association memberships
68
- - Employer verification of work history
69
-
70
- ## Certificate Lifecycle
71
-
72
- ### Creation and Issuance
73
-
74
- When someone wants to issue you a certificate, they typically:
75
-
76
- 1. **Verify your claim** through their established process
77
- 2. **Create a digital certificate** containing the verified information
78
- 3. **Sign it cryptographically** using their private key
79
- 4. **Deliver it to you** for use in proving the claim
80
-
81
- ### Validation and Trust
82
-
83
- When someone wants to verify your certificate, they:
84
-
85
- 1. **Check the cryptographic signature** to ensure authenticity
86
- 2. **Verify it hasn't expired** or been revoked
87
- 3. **Assess the issuer's credibility** and authority
88
- 4. **Determine if it meets their requirements** for the specific use case
89
-
90
- ### Renewal and Maintenance
91
-
92
- Certificates have limited lifespans for security reasons:
93
-
94
- - **Expiration dates** ensure information stays current
95
- - **Renewal processes** allow for re-verification
96
- - **Revocation mechanisms** handle compromised or invalid certificates
97
- - **Update procedures** accommodate changing information
98
-
99
- ## Trust Scoring and Reputation
100
-
101
- ### Building Credibility
102
-
103
- Your overall trustworthiness comes from the combination of all your certificates:
104
-
105
- - **Quantity**: More verifications generally increase trust
106
- - **Quality**: Certificates from respected issuers carry more weight
107
- - **Diversity**: Different types of verification provide broader confidence
108
- - **Recency**: Fresh certificates are more valuable than old ones
109
-
110
- ### Confidence Levels
111
-
112
- Different certificates provide different levels of assurance:
113
-
114
- - **Self-asserted claims** provide basic information but low confidence
115
- - **Peer verifications** offer moderate confidence from social proof
116
- - **Service verifications** provide higher confidence from specialized validators
117
- - **Institutional certificates** offer the highest confidence from established authorities
118
-
119
- ### Context Matters
120
-
121
- The same certificate might be highly valuable in one context but irrelevant in another:
122
-
123
- - A medical license is crucial for healthcare but irrelevant for software development
124
- - A GitHub contribution history matters for programming jobs but not for teaching
125
- - Age verification is essential for restricted services but unnecessary for professional networking
126
-
127
- ## Privacy and Selective Disclosure
128
-
129
- ### Controlling Information Flow
130
-
131
- One of the key advantages of certificate-based identity is granular control over what you reveal:
132
-
133
- - **Public certificates** are discoverable by anyone
134
- - **Private certificates** are shared only with specific parties
135
- - **Selective revelation** lets you prove specific claims without revealing everything
136
- - **Progressive disclosure** allows trust to build gradually
137
-
138
- ### Zero-Knowledge Proofs
139
-
140
- Advanced techniques allow you to prove things without revealing the underlying data:
141
-
142
- - Prove you're over 21 without revealing your exact age
143
- - Prove you have a degree without revealing which university
144
- - Prove you're a resident without revealing your exact address
145
- - Prove you're qualified without revealing all your credentials
146
-
147
- ### Consent and Control
148
-
149
- You maintain control over your certificates:
150
-
151
- - **Choose what to make public** vs. keep private
152
- - **Decide who can access** specific information
153
- - **Revoke access** when relationships change
154
- - **Update preferences** as your needs evolve
155
-
156
- ## Real-World Applications
157
-
158
- ### Professional Verification
159
-
160
- Instead of relying on self-reported resumes, employers can verify:
161
-
162
- - Educational credentials directly from institutions
163
- - Work history from previous employers
164
- - Professional certifications from licensing bodies
165
- - Skills endorsements from colleagues and clients
166
-
167
- ### Age and Identity Verification
168
-
169
- Services requiring age or identity verification can:
170
-
171
- - Verify age without collecting birthdates
172
- - Confirm identity without storing personal documents
173
- - Meet regulatory requirements while preserving privacy
174
- - Reduce fraud through cryptographic verification
175
-
176
- ### Reputation Systems
177
-
178
- Platforms can build more reliable reputation systems:
179
-
180
- - Portable reputation that follows users between platforms
181
- - Verifiable transaction history and feedback
182
- - Reduced fake accounts and manipulation
183
- - Incentives for honest behavior
184
-
185
- ### Access Control
186
-
187
- Organizations can manage access more securely:
188
-
189
- - Verify membership or employment status
190
- - Confirm professional qualifications
191
- - Validate security clearances
192
- - Authenticate without passwords
193
-
194
- ## Benefits Over Traditional Systems
195
-
196
- ### Security
197
-
198
- - **Cryptographic verification** is more secure than physical documents
199
- - **Tamper evidence** makes forgery virtually impossible
200
- - **Distributed validation** eliminates single points of failure
201
- - **Revocation mechanisms** handle compromised credentials quickly
202
-
203
- ### Privacy
204
-
205
- - **Minimal disclosure** reveals only necessary information
206
- - **User control** over what information is shared
207
- - **No central databases** to be breached or misused
208
- - **Consent-based sharing** puts users in control
209
-
210
- ### Interoperability
211
-
212
- - **Standard formats** work across different systems
213
- - **Portable credentials** move between applications
214
- - **Universal verification** works anywhere in the world
215
- - **Cross-platform compatibility** reduces vendor lock-in
216
-
217
- ### Efficiency
218
-
219
- - **Automated verification** reduces manual processes
220
- - **Real-time validation** provides instant results
221
- - **Reduced paperwork** streamlines credential management
222
- - **Lower costs** compared to traditional verification methods
223
-
224
- ## Challenges and Considerations
225
-
226
- ### User Experience
227
-
228
- Making certificate systems user-friendly requires:
229
-
230
- - **Intuitive interfaces** that hide complexity
231
- - **Clear explanations** of what certificates mean
232
- - **Simple management tools** for organizing credentials
233
- - **Seamless integration** with existing workflows
234
-
235
- ### Recovery and Backup
236
-
237
- Unlike traditional documents, losing access to digital certificates can be permanent:
238
-
239
- - **Backup strategies** are essential for important credentials
240
- - **Recovery mechanisms** must balance security with usability
241
- - **Key management** becomes critical for certificate access
242
- - **Succession planning** for organizational certificates
243
-
244
- ### Adoption and Network Effects
245
-
246
- Certificate systems become more valuable as adoption grows:
247
-
248
- - **Issuer participation** is needed for valuable certificates
249
- - **Verifier acceptance** determines practical utility
250
- - **User adoption** creates network effects
251
- - **Standardization** enables interoperability
252
-
253
- ### Legal and Regulatory
254
-
255
- Integrating with existing legal frameworks requires:
256
-
257
- - **Regulatory compliance** with identity verification laws
258
- - **Legal recognition** of digital certificates
259
- - **Audit trails** for compliance reporting
260
- - **Dispute resolution** mechanisms for conflicts
261
-
262
- ## The Future of Digital Credentials
263
-
264
- As certificate-based identity systems mature, we can expect:
265
-
266
- ### Widespread Adoption
267
-
268
- - **Government integration** with official identity documents
269
- - **Educational institutions** issuing digital diplomas
270
- - **Professional organizations** moving to digital certifications
271
- - **Employers** accepting and requiring digital credentials
272
-
273
- ### Enhanced Privacy
274
-
275
- - **Zero-knowledge proofs** becoming standard
276
- - **Selective disclosure** built into all systems
277
- - **Privacy-preserving verification** as the default
278
- - **User control** over all personal data
279
-
280
- ### Improved User Experience
281
-
282
- - **Seamless integration** with daily digital activities
283
- - **Automated verification** reducing friction
284
- - **Intelligent recommendations** for credential building
285
- - **Universal acceptance** across platforms and services
286
-
287
- ### New Possibilities
288
-
289
- - **Micro-credentials** for specific skills and achievements
290
- - **Dynamic certificates** that update automatically
291
- - **Composite credentials** combining multiple sources
292
- - **AI-assisted verification** for complex claims
293
-
294
- Understanding these concepts helps developers and users participate in building a more trustworthy, privacy-preserving digital world where identity verification is both secure and user-controlled.
295
-
296
- ## Related Concepts
297
-
298
- - [Decentralized Identity](./decentralized-identity.md) - Overall identity system architecture
299
- - [Digital Signatures](./signatures.md) - Cryptographic foundations of certificates
300
- - [Trust Model](./trust-model.md) - Security assumptions and trust relationships
301
- - [Key Management](./key-management.md) - Managing cryptographic keys for certificates
302
-
303
- ## Further Reading
304
-
305
- - [Identity Management Tutorial](../tutorials/identity-management.md) - Practical certificate implementation
306
- - [Security Best Practices](../guides/security-best-practices.md) - Secure certificate handling
307
- - [AuthFetch Tutorial](../tutorials/authfetch-tutorial.md) - Using certificates for authentication
@@ -1,77 +0,0 @@
1
- # Concepts
2
-
3
- Essential concepts for understanding and using the BSV TypeScript SDK effectively.
4
-
5
- ## Core Bitcoin Concepts
6
-
7
- ### [Transaction Structure](./transaction-structure.md)
8
-
9
- Understanding Bitcoin transactions, inputs, outputs, and how they work in the SDK.
10
-
11
- ### [Script Templates](./script-templates.md)
12
-
13
- Standard and custom Bitcoin script patterns available in the SDK.
14
-
15
- ### [Digital Signatures](./signatures.md)
16
-
17
- How digital signatures work in Bitcoin and their implementation in the SDK.
18
-
19
- ### [Transaction Verification](./verification.md)
20
-
21
- Understanding how to verify Bitcoin transactions using the SDK.
22
-
23
- ### [SPV Verification](./spv-verification.md)
24
-
25
- Simplified Payment Verification and merkle proof concepts for lightweight clients.
26
-
27
- ### [Transaction Fees](./fees.md)
28
-
29
- How Bitcoin transaction fees work and fee optimization strategies.
30
-
31
- ## SDK Architecture
32
-
33
- ### [SDK Design Philosophy](./sdk-philosophy.md)
34
-
35
- Core principles: zero dependencies, SPV-first approach, and vendor neutrality.
36
-
37
- ### [Wallet Integration](./wallet-integration.md)
38
-
39
- How the SDK connects with Bitcoin wallets and manages authentication.
40
-
41
- ### [Chain Tracking](./chain-tracking.md)
42
-
43
- Understanding how the SDK interacts with the Bitcoin network for transaction data.
44
-
45
- ## Data Formats
46
-
47
- ### [BEEF Format](./beef.md)
48
-
49
- Bitcoin Extras Extension Format for efficient transaction data exchange.
50
-
51
- ### [Transaction Encoding](./transaction-encoding.md)
52
-
53
- How transactions are serialized and deserialized in the SDK.
54
-
55
- ## Identity and Certificates
56
-
57
- ### [Decentralized Identity](./decentralized-identity.md)
58
-
59
- Understanding BSV's decentralized identity system and certificate-based verification.
60
-
61
- ### [Identity Certificates](./identity-certificates.md)
62
-
63
- How cryptographic certificates work for identity claims and verification.
64
-
65
- ## Security Model
66
-
67
- ### [Key Management](./key-management.md)
68
-
69
- How private keys, public keys, and cryptographic operations work in the SDK.
70
-
71
- ### [Trust Model](./trust-model.md)
72
-
73
- Understanding the security assumptions and trust relationships in SDK applications.
74
-
75
- ---
76
-
77
- These concepts provide the foundational knowledge needed to build Bitcoin applications with the BSV TypeScript SDK. For deeper protocol details, refer to the [BSV Skills Center](https://docs.bsvblockchain.org/).
@@ -1,185 +0,0 @@
1
- # Key Management
2
-
3
- Understanding how private keys, public keys, and cryptographic operations work in the BSV TypeScript SDK.
4
-
5
- ## Cryptographic Keys
6
-
7
- Bitcoin uses elliptic curve cryptography (secp256k1) for key management:
8
-
9
- ```typescript
10
- import { PrivateKey, PublicKey } from '@bsv/sdk'
11
-
12
- // Generate a new private key
13
- const privateKey = PrivateKey.fromRandom()
14
-
15
- // Derive the corresponding public key
16
- const publicKey = privateKey.toPublicKey()
17
- ```
18
-
19
- ## Private Keys
20
-
21
- Private keys are 256-bit numbers that control Bitcoin funds:
22
-
23
- ### Generation
24
-
25
- ```typescript
26
- // Secure random generation
27
- const privKey = PrivateKey.fromRandom()
28
-
29
- // From existing data (use carefully)
30
- const privKey2 = PrivateKey.fromString('hex_string')
31
- ```
32
-
33
- ### Formats
34
-
35
- ```typescript
36
- // WIF (Wallet Import Format)
37
- const wif = privateKey.toWif()
38
-
39
- // Hex string
40
- const hex = privateKey.toString()
41
-
42
- // DER encoding
43
- const der = privateKey.toDER()
44
- ```
45
-
46
- ## Public Keys
47
-
48
- Public keys are derived from private keys and can be shared safely:
49
-
50
- ### Derivation
51
-
52
- ```typescript
53
- // Always derive from private key
54
- const publicKey = privateKey.toPublicKey()
55
-
56
- // Cannot go backwards (public -> private)
57
- ```
58
-
59
- ### Formats
60
-
61
- ```typescript
62
- // Compressed (33 bytes) - preferred
63
- const compressed = publicKey.toString()
64
-
65
- // Uncompressed (65 bytes) - legacy
66
- const uncompressed = publicKey.toString(false)
67
-
68
- // DER encoding
69
- const der = publicKey.toDER()
70
- ```
71
-
72
- ## Digital Signatures
73
-
74
- Private keys create signatures that prove ownership:
75
-
76
- ```typescript
77
- // Sign a message
78
- const message = 'Hello Bitcoin'
79
- const signature = privateKey.sign(message)
80
-
81
- // Verify with public key
82
- const isValid = publicKey.verify(message, signature)
83
- ```
84
-
85
- ## Key Derivation
86
-
87
- The SDK supports hierarchical key derivation:
88
-
89
- ```typescript
90
- // Derive child keys (simplified example)
91
- const childKey = privateKey.deriveChild(0)
92
- const childPubKey = childKey.toPublicKey()
93
- ```
94
-
95
- ## Security Considerations
96
-
97
- ### Private Key Security
98
-
99
- - **Never expose**: Private keys should never be logged or transmitted
100
- - **Secure storage**: Use encrypted storage for private keys
101
- - **Random generation**: Always use cryptographically secure randomness
102
- - **Access control**: Limit who can access private key operations
103
-
104
- ### Best Practices
105
-
106
- ```typescript
107
- // Good: Generate securely
108
- const key = PrivateKey.fromRandom()
109
-
110
- // Bad: Predictable generation
111
- const badKey = PrivateKey.fromString('1234567890abcdef...')
112
-
113
- // Good: Derive public key when needed
114
- const pubKey = key.toPublicKey()
115
-
116
- // Bad: Store private key unnecessarily
117
- localStorage.setItem('privateKey', key.toString())
118
- ```
119
-
120
- ## Wallet Integration
121
-
122
- In most applications, wallets handle key management:
123
-
124
- The `WalletClient` provides high-level key management through wallet integration:
125
-
126
- ```typescript
127
- // Wallet manages keys securely
128
- const wallet = new WalletClient()
129
-
130
- // Application doesn't see private keys
131
- const action = await wallet.createAction({
132
- outputs: [/* transaction outputs */]
133
- })
134
- ```
135
-
136
- When using the `WalletClient`, keys are managed by the connected wallet service:
137
-
138
- The `WalletClient` approach is recommended for production applications as it provides:
139
-
140
- ## Key Recovery
141
-
142
- Keys can be recovered from various formats:
143
-
144
- ```typescript
145
- // From WIF format
146
- const key1 = PrivateKey.fromWif(wifString)
147
-
148
- // From hex string
149
- const key2 = PrivateKey.fromString(hexString)
150
-
151
- // From DER encoding
152
- const key3 = PrivateKey.fromDER(derBytes)
153
- ```
154
-
155
- ## Cryptographic Operations
156
-
157
- The SDK provides secure implementations of:
158
-
159
- - **ECDSA**: Digital signature algorithm
160
- - **ECDH**: Key exchange protocol
161
- - **Hash Functions**: SHA-256, RIPEMD-160
162
- - **AES**: Symmetric encryption
163
-
164
- ## Memory Management
165
-
166
- Sensitive key data should be cleared when no longer needed:
167
-
168
- - Use secure memory practices
169
- - Clear variables containing key data
170
- - Avoid keeping keys in memory longer than necessary
171
-
172
- ## Testing and Development
173
-
174
- For development and testing:
175
-
176
- - Use testnet for experiments
177
- - Generate new keys for each test
178
- - Never use mainnet keys in test code
179
- - Implement proper key rotation
180
-
181
- ## Next Steps
182
-
183
- - Understand [Digital Signatures](./signatures.md) in detail
184
- - Learn about [Trust Model](./trust-model.md) considerations
185
- - Explore [Wallet Integration](./wallet-integration.md) patterns