bsv-bap 0.0.1

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 (62) hide show
  1. package/.babelrc +20 -0
  2. package/.eslintrc +46 -0
  3. package/LICENSE +25 -0
  4. package/README.md +819 -0
  5. package/babel.config.js +6 -0
  6. package/bun.lockb +0 -0
  7. package/coverage/clover.xml +6 -0
  8. package/coverage/coverage-final.json +1 -0
  9. package/coverage/lcov-report/base.css +224 -0
  10. package/coverage/lcov-report/block-navigation.js +87 -0
  11. package/coverage/lcov-report/favicon.png +0 -0
  12. package/coverage/lcov-report/index.html +101 -0
  13. package/coverage/lcov-report/prettify.css +1 -0
  14. package/coverage/lcov-report/prettify.js +2 -0
  15. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  16. package/coverage/lcov-report/sorter.js +196 -0
  17. package/coverage/lcov-report/src/constants.ts.html +113 -0
  18. package/coverage/lcov-report/src/id.ts.html +2207 -0
  19. package/coverage/lcov-report/src/index.html +156 -0
  20. package/coverage/lcov-report/src/index.ts.html +1877 -0
  21. package/coverage/lcov-report/src/utils.ts.html +404 -0
  22. package/coverage/lcov-report/tests/data/index.html +111 -0
  23. package/coverage/lcov-report/tests/data/keys.js.html +86 -0
  24. package/coverage/lcov.info +0 -0
  25. package/dist/jest.config.d.ts +8 -0
  26. package/dist/src/constants.d.ts +8 -0
  27. package/dist/src/id.d.ts +295 -0
  28. package/dist/src/index.d.ts +238 -0
  29. package/dist/src/interface.d.ts +23 -0
  30. package/dist/src/poa.d.ts +6 -0
  31. package/dist/src/utils.d.ts +54 -0
  32. package/dist/typescript-npm-package.cjs.d.ts +554 -0
  33. package/dist/typescript-npm-package.cjs.js +1320 -0
  34. package/dist/typescript-npm-package.cjs.js.map +1 -0
  35. package/dist/typescript-npm-package.esm.d.ts +554 -0
  36. package/dist/typescript-npm-package.esm.js +1312 -0
  37. package/dist/typescript-npm-package.esm.js.map +1 -0
  38. package/dist/typescript-npm-package.umd.d.ts +554 -0
  39. package/dist/typescript-npm-package.umd.js +110193 -0
  40. package/dist/typescript-npm-package.umd.js.map +1 -0
  41. package/jest.config.ts +196 -0
  42. package/jsdoc.json +16 -0
  43. package/package.json +80 -0
  44. package/rollup.config.js +64 -0
  45. package/setup-jest.js +1 -0
  46. package/src/README.md +80 -0
  47. package/src/attributes.json +119 -0
  48. package/src/constants.ts +11 -0
  49. package/src/id.ts +783 -0
  50. package/src/index.ts +631 -0
  51. package/src/interface.ts +26 -0
  52. package/src/poa.ts +9 -0
  53. package/src/utils.ts +111 -0
  54. package/tests/data/ids.json +30 -0
  55. package/tests/data/keys.js +2 -0
  56. package/tests/data/old-ids.json +25 -0
  57. package/tests/data/test-vectors.json +122 -0
  58. package/tests/id.test.js +286 -0
  59. package/tests/index.test.js +335 -0
  60. package/tests/regression.test.js +28 -0
  61. package/tests/utils.test.js +27 -0
  62. package/tsconfig.json +17 -0
@@ -0,0 +1,295 @@
1
+ /// <reference types="node" />
2
+ import { type HD } from "@bsv/sdk";
3
+ import type { Identity } from "./interface";
4
+ /**
5
+ * BAP_ID class
6
+ *
7
+ * This class should be used in conjunction with the BAP class
8
+ *
9
+ * @type {BAP_ID}
10
+ */
11
+ declare class BAP_ID {
12
+ #private;
13
+ idName: string;
14
+ description: string;
15
+ rootAddress: string;
16
+ identityKey: string;
17
+ identityAttributes: {
18
+ [key: string]: any;
19
+ };
20
+ constructor(HDPrivateKey: HD, identityAttributes?: {
21
+ [key: string]: any;
22
+ }, idSeed?: string);
23
+ set BAP_SERVER(bapServer: string);
24
+ get BAP_SERVER(): string;
25
+ set BAP_TOKEN(token: string);
26
+ get BAP_TOKEN(): string;
27
+ deriveIdentityKey(address: string): string;
28
+ /**
29
+ * Helper function to parse identity attributes
30
+ *
31
+ * @param identityAttributes
32
+ * @returns {{}}
33
+ */
34
+ parseAttributes(identityAttributes: {
35
+ [key: string]: any;
36
+ } | string): {
37
+ [key: string]: any;
38
+ };
39
+ /**
40
+ * Parse a text of urn string into identity attributes
41
+ *
42
+ * urn:bap:id:name:John Doe:e2c6fb4063cc04af58935737eaffc938011dff546d47b7fbb18ed346f8c4d4fa
43
+ * urn:bap:id:birthday:1990-05-22:e61f23cbbb2284842d77965e2b0e32f0ca890b1894ca4ce652831347ee3596d9
44
+ * urn:bap:id:over18:1:480ca17ccaacd671b28dc811332525f2f2cd594d8e8e7825de515ce5d52d30e8
45
+ *
46
+ * @param urnIdentityAttributes
47
+ */
48
+ parseStringUrns(urnIdentityAttributes: string): {
49
+ [key: string]: any;
50
+ };
51
+ /**
52
+ * Returns the identity key
53
+ *
54
+ * @returns {*|string}
55
+ */
56
+ getIdentityKey(): string;
57
+ /**
58
+ * Returns all the attributes in the identity
59
+ *
60
+ * @returns {*}
61
+ */
62
+ getAttributes(): {
63
+ [key: string]: any;
64
+ };
65
+ /**
66
+ * Get the value of the given attribute
67
+ *
68
+ * @param attributeName
69
+ * @returns {{}|null}
70
+ */
71
+ getAttribute(attributeName: string): any;
72
+ /**
73
+ * Set the value of the given attribute
74
+ *
75
+ * If an empty value ('' || null || false) is given, the attribute is removed from the ID
76
+ *
77
+ * @param attributeName string
78
+ * @param attributeValue any
79
+ * @returns {{}|null}
80
+ */
81
+ setAttribute(attributeName: string, attributeValue: any): void;
82
+ /**
83
+ * Unset the given attribute from the ID
84
+ *
85
+ * @param attributeName
86
+ * @returns {{}|null}
87
+ */
88
+ unsetAttribute(attributeName: string): void;
89
+ /**
90
+ * Get all attribute urn's for this id
91
+ *
92
+ * @returns {string}
93
+ */
94
+ getAttributeUrns(): string;
95
+ /**
96
+ * Create an return the attribute urn for the given attribute
97
+ *
98
+ * @param attributeName
99
+ * @returns {string|null}
100
+ */
101
+ getAttributeUrn(attributeName: string): string | null;
102
+ /**
103
+ * Add an attribute to this identity
104
+ *
105
+ * @param attributeName
106
+ * @param value
107
+ * @param nonce
108
+ */
109
+ addAttribute(attributeName: string, value: any, nonce?: string): void;
110
+ /**
111
+ * This should be called with the last part of the signing path (/.../.../...)
112
+ * This library assumes the first part is m/424150'/0'/0' as defined at the top of this file
113
+ *
114
+ * @param path The second path of the signing path in the format [0-9]{0,9}/[0-9]{0,9}/[0-9]{0,9}
115
+ */
116
+ set rootPath(path: string);
117
+ get rootPath(): string;
118
+ getRootPath(): string;
119
+ /**
120
+ * This should be called with the last part of the signing path (/.../.../...)
121
+ * This library assumes the first part is m/424150'/0'/0' as defined at the top of this file
122
+ *
123
+ * @param path The second path of the signing path in the format [0-9]{0,9}/[0-9]{0,9}/[0-9]{0,9}
124
+ */
125
+ set currentPath(path: string);
126
+ get currentPath(): string;
127
+ get previousPath(): string;
128
+ /**
129
+ * This can be used to break the deterministic way child keys are created to make it harder for
130
+ * an attacker to steal the identites when the root key is compromised. This does however require
131
+ * the seeds to be stored at all times. If the seed is lost, the identity will not be recoverable.
132
+ */
133
+ get idSeed(): string;
134
+ /**
135
+ * Increment current path to a new path
136
+ *
137
+ * @returns {*}
138
+ */
139
+ incrementPath(): void;
140
+ /**
141
+ * Check whether the given path is a valid path for use with this class
142
+ * The signing paths used here always have a length of 3
143
+ *
144
+ * @param path The last part of the signing path (example "/0/0/1")
145
+ * @returns {boolean}
146
+ */
147
+ validatePath(path: string): boolean;
148
+ /**
149
+ * Get the OP_RETURN for the initial ID transaction (signed with root address)
150
+ *
151
+ * @returns {[]}
152
+ */
153
+ getInitialIdTransaction(): string[];
154
+ /**
155
+ * Get the OP_RETURN for the ID transaction of the current address / path
156
+ *
157
+ * @returns {[]}
158
+ */
159
+ getIdTransaction(previousPath?: string): string[];
160
+ /**
161
+ * Get address for given path
162
+ *
163
+ * @param path
164
+ * @returns {*}
165
+ */
166
+ getAddress(path: string): string;
167
+ /**
168
+ * Get current signing address
169
+ *
170
+ * @returns {*}
171
+ */
172
+ getCurrentAddress(): string;
173
+ /**
174
+ * Get the public key for encrypting data for this identity
175
+ */
176
+ getEncryptionPublicKey(): string;
177
+ /**
178
+ * Get the public key for encrypting data for this identity, using a seed for the encryption
179
+ */
180
+ getEncryptionPublicKeyWithSeed(seed: string): string;
181
+ /**
182
+ * Encrypt the given string data with the identity encryption key
183
+ * @param stringData
184
+ * @param counterPartyPublicKey Optional public key of the counterparty
185
+ * @return string Base64
186
+ */
187
+ encrypt(stringData: string, counterPartyPublicKey?: string): string;
188
+ /**
189
+ * Decrypt the given ciphertext with the identity encryption key
190
+ * @param ciphertext
191
+ * @param counterPartyPublicKey Optional public key of the counterparty
192
+ */
193
+ decrypt(ciphertext: string, counterPartyPublicKey?: string): string;
194
+ /**
195
+ * Encrypt the given string data with the identity encryption key
196
+ * @param stringData
197
+ * @param seed String seed
198
+ * @param counterPartyPublicKey Optional public key of the counterparty
199
+ * @return string Base64
200
+ */
201
+ encryptWithSeed(stringData: string, seed: string, counterPartyPublicKey?: string): string;
202
+ /**
203
+ * Decrypt the given ciphertext with the identity encryption key
204
+ * @param ciphertext
205
+ * @param seed String seed
206
+ * @param counterPartyPublicKey Public key of the counterparty
207
+ */
208
+ decryptWithSeed(ciphertext: string, seed: string, counterPartyPublicKey?: string): string;
209
+ private getEncryptionPrivateKeyWithSeed;
210
+ /**
211
+ * Get an attestation string for the given urn for this identity
212
+ *
213
+ * @param urn
214
+ * @returns {string}
215
+ */
216
+ getAttestation(urn: string): string;
217
+ /**
218
+ * Generate and return the attestation hash for the given attribute of this identity
219
+ *
220
+ * @param attribute Attribute name (name, email etc.)
221
+ * @returns {string}
222
+ */
223
+ getAttestationHash(attribute: string): string | null;
224
+ /**
225
+ * Sign a message with the current signing address of this identity
226
+ *
227
+ * @param message
228
+ * @param signingPath
229
+ * @returns {{address, signature}}
230
+ */
231
+ signMessage(message: string | Buffer, signingPath?: string): {
232
+ address: string;
233
+ signature: string;
234
+ };
235
+ /**
236
+ * Sign a message using a key based on the given string seed
237
+ *
238
+ * This works by creating a private key from the root key of this identity. It will always
239
+ * work with the rootPath / rootKey, to be deterministic. It will not change even if the keys
240
+ * are rotated for this ID.
241
+ *
242
+ * This is used in for instance deterministic login systems, that do not support BAP.
243
+ *
244
+ * @param message
245
+ * @param seed {string} String seed that will be used to generate a path
246
+ */
247
+ signMessageWithSeed(message: string, seed: string): {
248
+ address: string;
249
+ signature: string;
250
+ };
251
+ /**
252
+ * Sign an op_return hex array with AIP
253
+ * @param opReturn {array}
254
+ * @param signingPath {string}
255
+ * @param outputType {string}
256
+ * @return {[]}
257
+ */
258
+ signOpReturnWithAIP(opReturn: string[], signingPath?: string, outputType?: BufferEncoding): string[];
259
+ /**
260
+ * Construct an AIP buffer from the op return data
261
+ * @param opReturn
262
+ * @returns {Buffer}
263
+ */
264
+ getAIPMessageBuffer(opReturn: string[]): Buffer;
265
+ /**
266
+ * Get all signing keys for this identity
267
+ */
268
+ getIdSigningKeys(): Promise<any>;
269
+ /**
270
+ * Get all attestations for the given attribute
271
+ *
272
+ * @param attribute
273
+ */
274
+ getAttributeAttestations(attribute: string): Promise<any>;
275
+ /**
276
+ * Helper function to get attestation from a BAP API server
277
+ *
278
+ * @param apiUrl
279
+ * @param apiData
280
+ * @returns {Promise<any>}
281
+ */
282
+ getApiData(apiUrl: string, apiData: any): Promise<any>;
283
+ /**
284
+ * Import an identity from a JSON object
285
+ *
286
+ * @param identity{{}}
287
+ */
288
+ import(identity: Identity): void;
289
+ /**
290
+ * Export this identity to a JSON object
291
+ * @returns {{}}
292
+ */
293
+ export(): Identity;
294
+ }
295
+ export { BAP_ID };
@@ -0,0 +1,238 @@
1
+ /// <reference types="node" />
2
+ import { HD } from "@bsv/sdk";
3
+ import "node-fetch";
4
+ import { BAP_ID } from "./id";
5
+ import type { Attestation, PathPrefix } from "./interface";
6
+ /**
7
+ * BAP class
8
+ *
9
+ * Creates an instance of the BAP class and uses the given HDPrivateKey for all BAP operations.
10
+ *
11
+ * @param HDPrivateKey
12
+ */
13
+ export declare const BAP: {
14
+ new (HDPrivateKey: string, token?: string): {
15
+ "__#1030@#HDPrivateKey": HD;
16
+ "__#1030@#ids": {
17
+ [key: string]: BAP_ID;
18
+ };
19
+ "__#1030@#BAP_SERVER": string;
20
+ "__#1030@#BAP_TOKEN": string;
21
+ "__#1030@#lastIdPath": string;
22
+ readonly lastIdPath: string;
23
+ /**
24
+ * Get the public key of the given childPath, or of the current HDPrivateKey of childPath is empty
25
+ *
26
+ * @param childPath Full derivation path for this child
27
+ * @returns {*}
28
+ */
29
+ getPublicKey(childPath?: string): string;
30
+ /**
31
+ * Get the public key of the given childPath, or of the current HDPrivateKey of childPath is empty
32
+ *
33
+ * @param childPath Full derivation path for this child
34
+ * @returns {*}
35
+ */
36
+ getHdPublicKey(childPath?: string): string;
37
+ BAP_SERVER: string;
38
+ BAP_TOKEN: string;
39
+ /**
40
+ * This function verifies that the given bapId matches the given root address
41
+ * This is used as a data integrity check
42
+ *
43
+ * @param bapId BAP_ID instance
44
+ */
45
+ checkIdBelongs(bapId: BAP_ID): boolean;
46
+ /**
47
+ * Returns a list of all the identity keys that are stored in this instance
48
+ *
49
+ * @returns {string[]}
50
+ */
51
+ listIds(): string[];
52
+ /**
53
+ * Create a new Id and link it to this BAP instance
54
+ *
55
+ * This function uses the length of the #ids of this class to determine the next valid path.
56
+ * If not all ids related to this HDPrivateKey have been loaded, determine the path externally
57
+ * and pass it to newId when creating a new ID.
58
+ *
59
+ * @param path
60
+ * @param identityAttributes
61
+ * @param idSeed
62
+ * @returns {*}
63
+ */
64
+ newId(path?: string, identityAttributes?: any, idSeed?: string): BAP_ID;
65
+ /**
66
+ * Remove identity
67
+ *
68
+ * @param idKey
69
+ * @returns {*}
70
+ */
71
+ removeId(idKey: string): void;
72
+ /**
73
+ * Get the next valid path for the used HDPrivateKey and loaded #ids
74
+ *
75
+ * @returns {string}
76
+ */
77
+ getNextValidPath(): PathPrefix;
78
+ /**
79
+ * Get a certain Id
80
+ *
81
+ * @param identityKey
82
+ * @returns {null}
83
+ */
84
+ getId(identityKey: string): BAP_ID | null;
85
+ /**
86
+ * This function is used when manipulating ID's, adding or removing attributes etc
87
+ * First create an id through this class and then use getId to get it. Then you can add/edit or
88
+ * increment the signing path and then re-set it with this function.
89
+ *
90
+ * Note: when you getId() from this class, you will be working on the same object as this class
91
+ * has and any changes made will be propagated to the id in this class. When you call exportIds
92
+ * your new changes will also be included, without having to setId().
93
+ *
94
+ * @param bapId
95
+ */
96
+ setId(bapId: BAP_ID): void;
97
+ /**
98
+ * This function is used to import IDs and attributes from some external storage
99
+ *
100
+ * The ID information should NOT be stored together with the HD private key !
101
+ *
102
+ * @param idData Array of ids that have been exported
103
+ * @param encrypted Whether the data should be treated as being encrypted (default true)
104
+ */
105
+ importIds(idData: any, encrypted?: boolean): void;
106
+ /**
107
+ * Export all the IDs of this instance for external storage
108
+ *
109
+ * By default this function will encrypt the data, using a derivative child of the main HD key
110
+ *
111
+ * @param encrypted Whether the data should be encrypted (default true)
112
+ * @returns {[]|*}
113
+ */
114
+ exportIds(encrypted?: boolean): any;
115
+ /**
116
+ * Encrypt a string of data
117
+ *
118
+ * @param string
119
+ * @returns {string}
120
+ */
121
+ encrypt(string: string): string;
122
+ /**
123
+ * Decrypt a string of data
124
+ *
125
+ * @param string
126
+ * @returns {string}
127
+ */
128
+ decrypt(string: string): string;
129
+ /**
130
+ * Sign an attestation for a user
131
+ *
132
+ * @param attestationHash The computed attestation hash for the user - this should be calculated with the BAP_ID class for an identity for the user
133
+ * @param identityKey The identity key we are using for the signing
134
+ * @param counter
135
+ * @param dataString Optional data string that will be appended to the BAP attestation
136
+ * @returns {string[]}
137
+ */
138
+ signAttestationWithAIP(attestationHash: string, identityKey: string, counter?: number, dataString?: string): string[];
139
+ /**
140
+ * Verify an AIP signed attestation for a user
141
+ *
142
+ * [
143
+ * '0x6a',
144
+ * '0x31424150537561506e66476e53424d33474c56397968785564596534764762644d54',
145
+ * '0x415454455354',
146
+ * '0x33656166366361396334313936356538353831366439336439643034333136393032376633396661623034386333633031333663343364663635376462383761',
147
+ * '0x30',
148
+ * '0x7c',
149
+ * '0x313550636948473232534e4c514a584d6f5355615756693757537163376843667661',
150
+ * '0x424954434f494e5f4543445341',
151
+ * '0x31477531796d52567a595557634638776f6f506a7a4a4c764d383550795a64655876',
152
+ * '0x20ef60c5555001ddb1039bb0f215e46571fcb39ee46f48b089d1c08b0304dbcb3366d8fdf8bafd82be24b5ac42dcd6a5e96c90705dd42e3ad918b1b47ac3ce6ac2'
153
+ * ]
154
+ *
155
+ * @param tx Array of hex values for the OP_RETURN values
156
+ * @returns {{}}
157
+ */
158
+ verifyAttestationWithAIP(tx: string[]): Attestation;
159
+ /**
160
+ * For BAP attestations we use all fields for the attestation
161
+ *
162
+ * @param attestationHash
163
+ * @param counter
164
+ * @param address
165
+ * @param signature
166
+ * @param dataString Optional data string that will be appended to the BAP attestation
167
+ * @returns {[string]}
168
+ */
169
+ createAttestationTransaction(attestationHash: string, counter: number, address: string, signature: string, dataString?: string): string[];
170
+ /**
171
+ * This is a re-creation of how the bitcoinfiles-sdk creates a hash to sign for AIP
172
+ *
173
+ * @param attestationHash
174
+ * @param counter
175
+ * @param dataString Optional data string
176
+ * @returns {Buffer}
177
+ */
178
+ getAttestationBuffer(attestationHash: string, counter?: number, dataString?: string): Buffer;
179
+ /**
180
+ * Verify that the identity challenge is signed by the address
181
+ *
182
+ * @param message Buffer or utf-8 string
183
+ * @param address Bitcoin address of signee
184
+ * @param signature Signature base64 string
185
+ *
186
+ * @return boolean
187
+ */
188
+ verifySignature(message: string | Buffer, address: string, signature: string): boolean;
189
+ /**
190
+ * Check whether the given transaction (BAP OP_RETURN) is valid, is signed and that the
191
+ * identity signing is also valid at the time of signing
192
+ *
193
+ * @param idKey
194
+ * @param address
195
+ * @param challenge
196
+ * @param signature
197
+ *
198
+ * @returns {Promise<boolean|*>}
199
+ */
200
+ verifyChallengeSignature(idKey: string, address: string, challenge: string, signature: string): Promise<boolean>;
201
+ /**
202
+ * Check whether the given transaction (BAP OP_RETURN) is valid, is signed and that the
203
+ * identity signing is also valid at the time of signing
204
+ *
205
+ * @param tx
206
+ * @returns {Promise<boolean|*>}
207
+ */
208
+ isValidAttestationTransaction(tx: string[]): Promise<any>;
209
+ /**
210
+ * Get all signing keys for the given idKey
211
+ *
212
+ * @param address
213
+ * @returns {Promise<*>}
214
+ */
215
+ getIdentityFromAddress(address: string): Promise<any>;
216
+ /**
217
+ * Get all signing keys for the given idKey
218
+ *
219
+ * @param idKey
220
+ * @returns {Promise<*>}
221
+ */
222
+ getIdentity(idKey: string): Promise<any>;
223
+ /**
224
+ * Get all attestations for the given attestation hash
225
+ *
226
+ * @param attestationHash
227
+ */
228
+ getAttestationsForHash(attestationHash: string): Promise<any>;
229
+ /**
230
+ * Helper function to get attestation from a BAP API server
231
+ *
232
+ * @param apiUrl
233
+ * @param apiData
234
+ * @returns {Promise<any>}
235
+ */
236
+ getApiData(apiUrl: string, apiData: any): Promise<any>;
237
+ };
238
+ };
@@ -0,0 +1,23 @@
1
+ export interface Identity {
2
+ name: string;
3
+ description: string;
4
+ identityKey: string;
5
+ rootPath: string;
6
+ rootAddress: string;
7
+ previousPath: string;
8
+ currentPath: string;
9
+ lastIdPath: string;
10
+ idSeed: string;
11
+ identityAttributes: any;
12
+ }
13
+ export type PathPrefix = `/${number}/${number}/${number}` | `/${number}'/${number}'/${number}'`;
14
+ export interface Attestation {
15
+ type: string;
16
+ hash: string;
17
+ sequence: string;
18
+ signingProtocol: string;
19
+ signingAddress: string;
20
+ signature: string;
21
+ data?: string;
22
+ verified?: boolean;
23
+ }
@@ -0,0 +1,6 @@
1
+ import type { HD } from '@bsv/sdk';
2
+ export declare const BAP_POA: {
3
+ new (HDPrivateKey: HD): {
4
+ "__#1031@#HDPrivateKey": HD;
5
+ };
6
+ };
@@ -0,0 +1,54 @@
1
+ /// <reference types="node" />
2
+ import type { PathPrefix } from "./interface";
3
+ export declare const Utils: {
4
+ /**
5
+ * Helper function for encoding strings to hex
6
+ *
7
+ * @param string
8
+ * @returns {string}
9
+ */
10
+ hexEncode(string: string): string;
11
+ /**
12
+ * Helper function for encoding strings to hex
13
+ *
14
+ * @param hexString string
15
+ * @param encoding BufferEncoding
16
+ * @returns {string}
17
+ */
18
+ hexDecode(hexString: string, encoding?: BufferEncoding): string;
19
+ /**
20
+ * Helper function to generate a random nonce
21
+ *
22
+ * @returns {string}
23
+ */
24
+ getRandomString(length?: number): string;
25
+ /**
26
+ * Test whether the given string is hex
27
+ *
28
+ * @param value any
29
+ * @returns {boolean}
30
+ */
31
+ isHex(value: string): boolean;
32
+ /**
33
+ * Get a signing path from a hex number
34
+ *
35
+ * @param hexString {string}
36
+ * @param hardened {boolean} Whether to return a hardened path
37
+ * @returns {string}
38
+ */
39
+ getSigningPathFromHex(hexString: string, hardened?: boolean): string;
40
+ /**
41
+ * Increment that second to last part from the given part, set the last part to 0
42
+ *
43
+ * @param path string
44
+ * @returns {*}
45
+ */
46
+ getNextIdentityPath(path: string): PathPrefix;
47
+ /**
48
+ * Increment that last part of the given path
49
+ *
50
+ * @param path string
51
+ * @returns {*}
52
+ */
53
+ getNextPath(path: string): string;
54
+ };