@gibme/crypto-browser 7.0.2
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/LICENSE +25 -0
- package/README.md +18 -0
- package/dist/Crypto.min.js +3 -0
- package/dist/Crypto.min.js.LICENSE.txt +15 -0
- package/dist/Crypto.min.js.map +1 -0
- package/dist/browser/src/index.d.ts +70 -0
- package/dist/browser/src/index.js +177 -0
- package/dist/browser/src/index.js.map +1 -0
- package/dist/browser/src/version.d.ts +1 -0
- package/dist/browser/src/version.js +6 -0
- package/dist/browser/src/version.js.map +1 -0
- package/dist/types/helpers.d.ts +43 -0
- package/dist/types/helpers.js +123 -0
- package/dist/types/helpers.js.map +1 -0
- package/dist/types/index.d.ts +806 -0
- package/dist/types/index.js +1518 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/types.d.ts +278 -0
- package/dist/types/types.js +59 -0
- package/dist/types/types.js.map +1 -0
- package/dist/types/uint64.d.ts +13 -0
- package/dist/types/uint64.js +70 -0
- package/dist/types/uint64.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,806 @@
|
|
|
1
|
+
import { crypto_borromean_signature_t, crypto_bulletproof_plus_t, crypto_bulletproof_t, crypto_clsag_signature_t, crypto_entropy_t, crypto_triptych_signature_t, key_pair_t, Language, ICryptoLibrary, LibraryType, ModuleSettings } from './types';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export * from './helpers';
|
|
4
|
+
/**
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class CryptoModule {
|
|
8
|
+
private static _external_library;
|
|
9
|
+
protected static runtime_configuration: ModuleSettings;
|
|
10
|
+
/**
|
|
11
|
+
* We cannot create a new instance using this method as we need to await the
|
|
12
|
+
* loading of an underlying module, hence, we need to await the static
|
|
13
|
+
* init() method on this class to receive an instance of the class
|
|
14
|
+
*
|
|
15
|
+
* @protected
|
|
16
|
+
*/
|
|
17
|
+
protected constructor();
|
|
18
|
+
/**
|
|
19
|
+
* Gets the external library calls that replace our cryptographic method calls
|
|
20
|
+
*/
|
|
21
|
+
static get external_library(): Partial<ICryptoLibrary>;
|
|
22
|
+
/**
|
|
23
|
+
* Sets external library calls that replace our cryptographic method calls
|
|
24
|
+
*
|
|
25
|
+
* @param config
|
|
26
|
+
*/
|
|
27
|
+
static set external_library(config: Partial<ICryptoLibrary>);
|
|
28
|
+
/**
|
|
29
|
+
* Returns the underlying cryptographic library name
|
|
30
|
+
*/
|
|
31
|
+
static get library_name(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the underlying cryptographic library type
|
|
34
|
+
*/
|
|
35
|
+
static get library_type(): LibraryType;
|
|
36
|
+
/**
|
|
37
|
+
* Returns if the underlying cryptographic library is of the
|
|
38
|
+
* Node.js C++ Addon type
|
|
39
|
+
*/
|
|
40
|
+
static get is_native(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Sets external library calls that replace our cryptographic method calls
|
|
43
|
+
*
|
|
44
|
+
* @param config
|
|
45
|
+
*/
|
|
46
|
+
set external_library(config: Partial<ICryptoLibrary>);
|
|
47
|
+
/**
|
|
48
|
+
* Gets the external library calls that replace our cryptographic method calls
|
|
49
|
+
*/
|
|
50
|
+
get external_library(): Partial<ICryptoLibrary>;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the underlying cryptographic library name
|
|
53
|
+
*/
|
|
54
|
+
get library_name(): string;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the underlying cryptographic library type
|
|
57
|
+
*/
|
|
58
|
+
get library_type(): LibraryType;
|
|
59
|
+
/**
|
|
60
|
+
* Returns if the underlying cryptographic library is of the
|
|
61
|
+
* Node.js C++ Addon type
|
|
62
|
+
*/
|
|
63
|
+
get is_native(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Encodes an address into Base58
|
|
66
|
+
*
|
|
67
|
+
* @param prefix
|
|
68
|
+
* @param public_spend
|
|
69
|
+
* @param public_view
|
|
70
|
+
*/
|
|
71
|
+
base58_address_encode(prefix: number, public_spend: string, public_view?: string): Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Encodes an address into CryptoNote Base58
|
|
74
|
+
*
|
|
75
|
+
* @param prefix
|
|
76
|
+
* @param public_spend
|
|
77
|
+
* @param public_view
|
|
78
|
+
*/
|
|
79
|
+
cn_base58_address_encode(prefix: number, public_spend: string, public_view?: string): Promise<string>;
|
|
80
|
+
/**
|
|
81
|
+
* Decodes an address from Base58
|
|
82
|
+
*
|
|
83
|
+
* @param base58
|
|
84
|
+
*/
|
|
85
|
+
base58_address_decode(base58: string): Promise<{
|
|
86
|
+
prefix: number;
|
|
87
|
+
public_spend: string;
|
|
88
|
+
public_view?: string;
|
|
89
|
+
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Decodes an address from CryptoNote Base58
|
|
92
|
+
*
|
|
93
|
+
* @param base58
|
|
94
|
+
*/
|
|
95
|
+
cn_base58_address_decode(base58: string): Promise<{
|
|
96
|
+
prefix: number;
|
|
97
|
+
public_spend: string;
|
|
98
|
+
public_view?: string;
|
|
99
|
+
}>;
|
|
100
|
+
/**
|
|
101
|
+
* Generates a random entropy value
|
|
102
|
+
*
|
|
103
|
+
* @param entropy
|
|
104
|
+
* @param bits
|
|
105
|
+
* @param encode_timestamp
|
|
106
|
+
*/
|
|
107
|
+
random_entropy(entropy?: string, bits?: 128 | 256, encode_timestamp?: boolean): Promise<crypto_entropy_t>;
|
|
108
|
+
/**
|
|
109
|
+
* Generates a random hash value
|
|
110
|
+
*/
|
|
111
|
+
random_hash(): Promise<string>;
|
|
112
|
+
/**
|
|
113
|
+
* Generates a list of random hashes
|
|
114
|
+
*
|
|
115
|
+
* @param count
|
|
116
|
+
*/
|
|
117
|
+
random_hashes(count?: number): Promise<string[]>;
|
|
118
|
+
/**
|
|
119
|
+
* Generates a random ED25519 scalar value
|
|
120
|
+
*/
|
|
121
|
+
random_scalar(): Promise<string>;
|
|
122
|
+
/**
|
|
123
|
+
* Generates a list of random ED25519 scalars
|
|
124
|
+
*
|
|
125
|
+
* @param count
|
|
126
|
+
*/
|
|
127
|
+
random_scalars(count?: number): Promise<string[]>;
|
|
128
|
+
/**
|
|
129
|
+
* Generates a random ED25519 point value
|
|
130
|
+
*/
|
|
131
|
+
random_point(): Promise<string>;
|
|
132
|
+
/**
|
|
133
|
+
* Generates a list of random ED25519 points
|
|
134
|
+
*
|
|
135
|
+
* @param count
|
|
136
|
+
*/
|
|
137
|
+
random_points(count?: number): Promise<string[]>;
|
|
138
|
+
/**
|
|
139
|
+
* Hashes the input data using sha256 and returns the resulting hash value
|
|
140
|
+
*
|
|
141
|
+
* @param input
|
|
142
|
+
*/
|
|
143
|
+
sha256(input: any): Promise<string>;
|
|
144
|
+
/**
|
|
145
|
+
* Hashes the input data using sha384 and returns the resulting hash value
|
|
146
|
+
*
|
|
147
|
+
* @param input
|
|
148
|
+
*/
|
|
149
|
+
sha384(input: any): Promise<string>;
|
|
150
|
+
/**
|
|
151
|
+
* Hashes the input data using sha512 and returns the resulting hash value
|
|
152
|
+
*
|
|
153
|
+
* @param input
|
|
154
|
+
*/
|
|
155
|
+
sha512(input: any): Promise<string>;
|
|
156
|
+
/**
|
|
157
|
+
* Hashes the input data using sha3 and returns the resulting hash value
|
|
158
|
+
*
|
|
159
|
+
* @param input
|
|
160
|
+
*/
|
|
161
|
+
sha3(input: any): Promise<string>;
|
|
162
|
+
/**
|
|
163
|
+
* Hashes the input data using a simple SHA3 KDF function and returns
|
|
164
|
+
* the resulting hash value
|
|
165
|
+
*
|
|
166
|
+
* @param input
|
|
167
|
+
* @param iterations
|
|
168
|
+
*/
|
|
169
|
+
sha3_slow(input: string, iterations?: number): Promise<string>;
|
|
170
|
+
/**
|
|
171
|
+
* Hashes the input data using Blake2b and returns the resulting
|
|
172
|
+
* hash value
|
|
173
|
+
*
|
|
174
|
+
* @param input
|
|
175
|
+
*/
|
|
176
|
+
blake2b(input: any): Promise<string>;
|
|
177
|
+
/**
|
|
178
|
+
* Hashes the input data using Argon2i and returns the resulting hash value
|
|
179
|
+
*
|
|
180
|
+
* @param input
|
|
181
|
+
* @param iterations
|
|
182
|
+
* @param memory
|
|
183
|
+
* @param threads
|
|
184
|
+
*/
|
|
185
|
+
argon2i(input: any, iterations?: number, memory?: number, threads?: number): Promise<string>;
|
|
186
|
+
/**
|
|
187
|
+
* Hashes the input data using Argon2d and returns the resulting hash value
|
|
188
|
+
*
|
|
189
|
+
* @param input
|
|
190
|
+
* @param iterations
|
|
191
|
+
* @param memory
|
|
192
|
+
* @param threads
|
|
193
|
+
*/
|
|
194
|
+
argon2d(input: any, iterations?: number, memory?: number, threads?: number): Promise<string>;
|
|
195
|
+
/**
|
|
196
|
+
* Hashes the input data using Argon2id and returns the resulting hash value
|
|
197
|
+
*
|
|
198
|
+
* @param input
|
|
199
|
+
* @param iterations
|
|
200
|
+
* @param memory
|
|
201
|
+
* @param threads
|
|
202
|
+
*/
|
|
203
|
+
argon2id(input: any, iterations?: number, memory?: number, threads?: number): Promise<string>;
|
|
204
|
+
/**
|
|
205
|
+
* Recovers entropy from a mnemonic phrase or a list of mnemonic phrase words
|
|
206
|
+
*
|
|
207
|
+
* @param mnenomic_phrase
|
|
208
|
+
* @param language
|
|
209
|
+
*/
|
|
210
|
+
entropy_recover(mnenomic_phrase: string | string[], language?: Language): Promise<crypto_entropy_t>;
|
|
211
|
+
/**
|
|
212
|
+
* Generates a key derivation
|
|
213
|
+
*
|
|
214
|
+
* Note: D = (a * B) mod l
|
|
215
|
+
*
|
|
216
|
+
* @param public_key
|
|
217
|
+
* @param secret_key
|
|
218
|
+
*/
|
|
219
|
+
generate_derivation(public_key: string, secret_key: string): Promise<string>;
|
|
220
|
+
/**
|
|
221
|
+
* Generates a key derivation scalar value
|
|
222
|
+
*
|
|
223
|
+
* Note: Ds = H(D || output_index) mod l
|
|
224
|
+
*
|
|
225
|
+
* @param derivation
|
|
226
|
+
* @param output_index
|
|
227
|
+
*/
|
|
228
|
+
generate_derivation_scalar(derivation: string, output_index?: number): Promise<string>;
|
|
229
|
+
/**
|
|
230
|
+
* Derives a public ephemeral from a derivation scalar and a public key
|
|
231
|
+
*
|
|
232
|
+
* Note: P = [(Ds * G) + B] mod l
|
|
233
|
+
*
|
|
234
|
+
* @param derivation_scalar
|
|
235
|
+
* @param public_key
|
|
236
|
+
*/
|
|
237
|
+
derive_public_key(derivation_scalar: string, public_key: string): Promise<string>;
|
|
238
|
+
/**
|
|
239
|
+
* Derives a secret ephemeral from a derivation scalar and a secret key
|
|
240
|
+
*
|
|
241
|
+
* Note: p = (Ds + b) mod l
|
|
242
|
+
*
|
|
243
|
+
* @param derivation_scalar
|
|
244
|
+
* @param secret_key
|
|
245
|
+
*/
|
|
246
|
+
derive_secret_key(derivation_scalar: string, secret_key: string): Promise<string>;
|
|
247
|
+
/**
|
|
248
|
+
* Generates a key image from the public and secret ephemeral
|
|
249
|
+
*
|
|
250
|
+
* @param public_ephemeral
|
|
251
|
+
* @param secret_ephemeral
|
|
252
|
+
*/
|
|
253
|
+
generate_key_image(public_ephemeral: string, secret_ephemeral: string): Promise<string>;
|
|
254
|
+
/**
|
|
255
|
+
* Generates a V2 key image from the secret ephemeral
|
|
256
|
+
*
|
|
257
|
+
* @param secret_ephemeral
|
|
258
|
+
*/
|
|
259
|
+
generate_key_image_v2(secret_ephemeral: string): Promise<string>;
|
|
260
|
+
/**
|
|
261
|
+
* Generates a secret & public key pair
|
|
262
|
+
*/
|
|
263
|
+
generate_keys(): Promise<key_pair_t>;
|
|
264
|
+
/**
|
|
265
|
+
* Generates a list pf secret & public keys
|
|
266
|
+
*
|
|
267
|
+
* @param count
|
|
268
|
+
*/
|
|
269
|
+
generate_keys_m(count?: number): Promise<{
|
|
270
|
+
public_keys: string[];
|
|
271
|
+
secret_keys: string[];
|
|
272
|
+
}>;
|
|
273
|
+
/**
|
|
274
|
+
* Much like derive_public_key() but calculates the public_key used from the public ephemeral
|
|
275
|
+
*
|
|
276
|
+
* Note: B = P - [H(D || output_index) mod l]
|
|
277
|
+
*
|
|
278
|
+
* @param derivation
|
|
279
|
+
* @param public_ephemeral
|
|
280
|
+
* @param output_index
|
|
281
|
+
*/
|
|
282
|
+
underive_public_key(derivation: string, public_ephemeral: string, output_index?: number): Promise<string>;
|
|
283
|
+
/**
|
|
284
|
+
* Calculates the public key of the given secret key
|
|
285
|
+
*
|
|
286
|
+
* @param secret_key
|
|
287
|
+
*/
|
|
288
|
+
secret_key_to_public_key(secret_key: string): Promise<string>;
|
|
289
|
+
/**
|
|
290
|
+
* Calculates the secret scalar and public key for the provided ED25519 private key (aka seed)
|
|
291
|
+
*
|
|
292
|
+
* @param private_key
|
|
293
|
+
*/
|
|
294
|
+
private_key_to_keys(private_key: string): Promise<key_pair_t>;
|
|
295
|
+
/**
|
|
296
|
+
* Generates an ED25519 point by hashing the provided data and turning
|
|
297
|
+
* it into a point on the ED25519 curve
|
|
298
|
+
*
|
|
299
|
+
* @param input
|
|
300
|
+
*/
|
|
301
|
+
hash_to_point(input: any): Promise<string>;
|
|
302
|
+
/**
|
|
303
|
+
* Generates an ED25519 scalar by hashing the provided data and
|
|
304
|
+
* reducing it to an ED25519 scalar value
|
|
305
|
+
*
|
|
306
|
+
* @param input
|
|
307
|
+
*/
|
|
308
|
+
hash_to_scalar(input: any): Promise<string>;
|
|
309
|
+
/**
|
|
310
|
+
* Reduces the input value to an ED25519 scalar value
|
|
311
|
+
*
|
|
312
|
+
* @param input
|
|
313
|
+
*/
|
|
314
|
+
scalar_reduce(input: string | Buffer): Promise<string>;
|
|
315
|
+
/**
|
|
316
|
+
* Calculates the depth of the Merkle tree based upon how many hashes
|
|
317
|
+
* the tree contains
|
|
318
|
+
*
|
|
319
|
+
* @param value
|
|
320
|
+
*/
|
|
321
|
+
tree_depth(value: number): Promise<number>;
|
|
322
|
+
/**
|
|
323
|
+
* Generates the root Merkle tree hash using the list of hashes
|
|
324
|
+
*
|
|
325
|
+
* @param hashes
|
|
326
|
+
*/
|
|
327
|
+
root_hash(hashes: string[]): Promise<string>;
|
|
328
|
+
/**
|
|
329
|
+
* Generates a Merkle tree root hash value from the supplied input values
|
|
330
|
+
*
|
|
331
|
+
* @param branches
|
|
332
|
+
* @param leaf
|
|
333
|
+
* @param depth
|
|
334
|
+
* @param path
|
|
335
|
+
*/
|
|
336
|
+
root_hash_from_branch(branches: string[], leaf: string, depth?: number, path?: 0 | 1): Promise<string>;
|
|
337
|
+
/**
|
|
338
|
+
* Generates Merkle tree branch from the list of hashes
|
|
339
|
+
*
|
|
340
|
+
* @param hashes
|
|
341
|
+
*/
|
|
342
|
+
tree_branch(hashes: string[]): Promise<string[]>;
|
|
343
|
+
/**
|
|
344
|
+
* Generates an ED25519 RFC8032 signature for the message using
|
|
345
|
+
* the secret key specified
|
|
346
|
+
* @param message
|
|
347
|
+
* @param secret_key
|
|
348
|
+
*/
|
|
349
|
+
generate_rfc8032_signature(message: string, secret_key: string): Promise<string>;
|
|
350
|
+
/**
|
|
351
|
+
* Checks an ED25519 RFC8032 signature to verify that it was created
|
|
352
|
+
* with the secret key of the public key specified
|
|
353
|
+
* @param message
|
|
354
|
+
* @param public_key
|
|
355
|
+
* @param signature
|
|
356
|
+
*/
|
|
357
|
+
check_rfc8032_signature(message: string, public_key: string, signature: string): Promise<boolean>;
|
|
358
|
+
/**
|
|
359
|
+
* Generates a simple ED25519 signature for the message digest using
|
|
360
|
+
* the secret key specified
|
|
361
|
+
*
|
|
362
|
+
* @param message_digest
|
|
363
|
+
* @param secret_key
|
|
364
|
+
*/
|
|
365
|
+
generate_signature(message_digest: string, secret_key: string): Promise<string>;
|
|
366
|
+
/**
|
|
367
|
+
* Prepares a signature for the message digest such that it
|
|
368
|
+
* can be completed in later stages of the signature construction
|
|
369
|
+
*
|
|
370
|
+
* @param message_digest
|
|
371
|
+
* @param public_key
|
|
372
|
+
*/
|
|
373
|
+
prepare_signature(message_digest: string, public_key: string): Promise<string>;
|
|
374
|
+
/**
|
|
375
|
+
* Completes a previously prepared signature
|
|
376
|
+
*
|
|
377
|
+
* @param secret_key
|
|
378
|
+
* @param signature
|
|
379
|
+
*/
|
|
380
|
+
complete_signature(secret_key: string, signature: string): Promise<string>;
|
|
381
|
+
/**
|
|
382
|
+
* Checks a simple ED25519 signature to verify that it was created
|
|
383
|
+
* with the secret key of the public key specified
|
|
384
|
+
*
|
|
385
|
+
* @param message_digest
|
|
386
|
+
* @param public_key
|
|
387
|
+
* @param signature
|
|
388
|
+
*/
|
|
389
|
+
check_signature(message_digest: string, public_key: string, signature: string): Promise<boolean>;
|
|
390
|
+
/**
|
|
391
|
+
* Generates a borromean ring signature for the message digest using
|
|
392
|
+
* the secret key specified and the list of all possible public key
|
|
393
|
+
* signing candidates
|
|
394
|
+
*
|
|
395
|
+
* @param message_digest
|
|
396
|
+
* @param secret_ephemeral
|
|
397
|
+
* @param public_keys
|
|
398
|
+
*/
|
|
399
|
+
generate_borromean_signature(message_digest: string, secret_ephemeral: string, public_keys: string[]): Promise<crypto_borromean_signature_t>;
|
|
400
|
+
/**
|
|
401
|
+
* Prepares a borromean ring signature for the message digest such
|
|
402
|
+
* that it can be completed in later stages of signature construction
|
|
403
|
+
*
|
|
404
|
+
* @param message_digest
|
|
405
|
+
* @param key_image
|
|
406
|
+
* @param public_keys
|
|
407
|
+
* @param real_output_index
|
|
408
|
+
*/
|
|
409
|
+
prepare_borromean_signature(message_digest: string, key_image: string, public_keys: string[], real_output_index: number): Promise<crypto_borromean_signature_t>;
|
|
410
|
+
/**
|
|
411
|
+
* Completes a previously prepared borromean ring signature
|
|
412
|
+
*
|
|
413
|
+
* @param secret_ephemeral
|
|
414
|
+
* @param real_output_index
|
|
415
|
+
* @param signature
|
|
416
|
+
*/
|
|
417
|
+
complete_borromean_signature(secret_ephemeral: string, real_output_index: number, signature: crypto_borromean_signature_t): Promise<crypto_borromean_signature_t>;
|
|
418
|
+
/**
|
|
419
|
+
* Checks a borromean ring signature to verify that it was created
|
|
420
|
+
* by one of the candidate public keys
|
|
421
|
+
*
|
|
422
|
+
* @param message_digest
|
|
423
|
+
* @param key_image
|
|
424
|
+
* @param public_keys
|
|
425
|
+
* @param signature
|
|
426
|
+
*/
|
|
427
|
+
check_borromean_signature(message_digest: string, key_image: string, public_keys: string[], signature: crypto_borromean_signature_t): Promise<boolean>;
|
|
428
|
+
/**
|
|
429
|
+
* Generates a CLSAG ring signature for the message digest using
|
|
430
|
+
* the secret key specified and the list of all possible public
|
|
431
|
+
* key signing candidates.
|
|
432
|
+
*
|
|
433
|
+
* Optionally, we also include proof that we have the real values
|
|
434
|
+
* of the values hidden within pedersen commitments
|
|
435
|
+
*
|
|
436
|
+
* @param message_digest
|
|
437
|
+
* @param secret_ephemeral
|
|
438
|
+
* @param public_keys
|
|
439
|
+
* @param input_blinding_factor
|
|
440
|
+
* @param public_commitments
|
|
441
|
+
* @param pseudo_blinding_factor
|
|
442
|
+
* @param pseudo_commitment
|
|
443
|
+
*/
|
|
444
|
+
generate_clsag_signature(message_digest: string, secret_ephemeral: string, public_keys: string[], input_blinding_factor?: string, public_commitments?: string[], pseudo_blinding_factor?: string, pseudo_commitment?: string): Promise<crypto_clsag_signature_t>;
|
|
445
|
+
/**
|
|
446
|
+
* Prepares a CLSAG ring signature for the message digest such
|
|
447
|
+
* that it can be completed in later stages of signature
|
|
448
|
+
* construction
|
|
449
|
+
*
|
|
450
|
+
* @param message_digest
|
|
451
|
+
* @param key_image
|
|
452
|
+
* @param public_keys
|
|
453
|
+
* @param real_output_index
|
|
454
|
+
* @param input_blinding_factor
|
|
455
|
+
* @param public_commitments
|
|
456
|
+
* @param pseudo_blinding_factor
|
|
457
|
+
* @param pseudo_commitment
|
|
458
|
+
*/
|
|
459
|
+
prepare_clsag_signature(message_digest: string, key_image: string, public_keys: string[], real_output_index: number, input_blinding_factor?: string, public_commitments?: string[], pseudo_blinding_factor?: string, pseudo_commitment?: string): Promise<{
|
|
460
|
+
signature: crypto_clsag_signature_t;
|
|
461
|
+
h: string[];
|
|
462
|
+
mu_P: string;
|
|
463
|
+
}>;
|
|
464
|
+
/**
|
|
465
|
+
* Completes a previously prepared CLSAG ring signature
|
|
466
|
+
*
|
|
467
|
+
* @param secret_ephemeral
|
|
468
|
+
* @param real_output_index
|
|
469
|
+
* @param signature
|
|
470
|
+
* @param h
|
|
471
|
+
* @param mu_P
|
|
472
|
+
*/
|
|
473
|
+
complete_clsag_signature(secret_ephemeral: string, real_output_index: number, signature: crypto_clsag_signature_t, h: string[], mu_P: string): Promise<crypto_clsag_signature_t>;
|
|
474
|
+
/**
|
|
475
|
+
* Checks a CLSAG ring signature to verify that it was created
|
|
476
|
+
* by one of the candidate public keys.
|
|
477
|
+
*
|
|
478
|
+
* @param message_digest
|
|
479
|
+
* @param key_image
|
|
480
|
+
* @param public_keys
|
|
481
|
+
* @param signature
|
|
482
|
+
* @param commitments
|
|
483
|
+
*/
|
|
484
|
+
check_clsag_signature(message_digest: string, key_image: string, public_keys: string[], signature: crypto_clsag_signature_t, commitments?: string[]): Promise<boolean>;
|
|
485
|
+
/**
|
|
486
|
+
* Generates a Triptych ring signature for the message digest using
|
|
487
|
+
* the secret key specified and the list of all possible public
|
|
488
|
+
* key signing candidates.
|
|
489
|
+
*
|
|
490
|
+
* Optionally, we also include proof that we have the real values
|
|
491
|
+
* of the values hidden within pedersen commitments
|
|
492
|
+
*
|
|
493
|
+
* @param message_digest
|
|
494
|
+
* @param secret_ephemeral
|
|
495
|
+
* @param public_keys
|
|
496
|
+
* @param input_blinding_factor
|
|
497
|
+
* @param public_commitments
|
|
498
|
+
* @param pseudo_blinding_factor
|
|
499
|
+
* @param pseudo_commitment
|
|
500
|
+
*/
|
|
501
|
+
generate_triptych_signature(message_digest: string, secret_ephemeral: string, public_keys: string[], input_blinding_factor: string, public_commitments: string[], pseudo_blinding_factor: string, pseudo_commitment: string): Promise<crypto_triptych_signature_t>;
|
|
502
|
+
/**
|
|
503
|
+
* Prepares a Triptych ring signature for the message digest such
|
|
504
|
+
* that it can be completed in later stages of signature
|
|
505
|
+
* construction
|
|
506
|
+
*
|
|
507
|
+
* @param message_digest
|
|
508
|
+
* @param key_image
|
|
509
|
+
* @param public_keys
|
|
510
|
+
* @param real_output_index
|
|
511
|
+
* @param input_blinding_factor
|
|
512
|
+
* @param public_commitments
|
|
513
|
+
* @param pseudo_blinding_factor
|
|
514
|
+
* @param pseudo_commitment
|
|
515
|
+
*/
|
|
516
|
+
prepare_triptych_signature(message_digest: string, key_image: string, public_keys: string[], real_output_index: number, input_blinding_factor: string, public_commitments: string[], pseudo_blinding_factor: string, pseudo_commitment: string): Promise<{
|
|
517
|
+
signature: crypto_triptych_signature_t;
|
|
518
|
+
xpow: string;
|
|
519
|
+
}>;
|
|
520
|
+
/**
|
|
521
|
+
* Completes a previously prepared Triptych ring signature
|
|
522
|
+
*
|
|
523
|
+
* @param secret_ephemeral
|
|
524
|
+
* @param signature
|
|
525
|
+
* @param xpow
|
|
526
|
+
*/
|
|
527
|
+
complete_triptych_signature(secret_ephemeral: string, signature: crypto_triptych_signature_t, xpow: string): Promise<crypto_triptych_signature_t>;
|
|
528
|
+
/**
|
|
529
|
+
* Checks a Triptych ring signature to verify that it was created
|
|
530
|
+
* by one of the candidate public keys.
|
|
531
|
+
*
|
|
532
|
+
* @param message_digest
|
|
533
|
+
* @param key_image
|
|
534
|
+
* @param public_keys
|
|
535
|
+
* @param signature
|
|
536
|
+
* @param commitments
|
|
537
|
+
*/
|
|
538
|
+
check_triptych_signature(message_digest: string, key_image: string, public_keys: string[], signature: crypto_triptych_signature_t, commitments: string[]): Promise<boolean>;
|
|
539
|
+
/**
|
|
540
|
+
* Generates a Bulletproof Zero-Knowledge proof of the amount(s) specified
|
|
541
|
+
*
|
|
542
|
+
* @param amounts
|
|
543
|
+
* @param blinding_factors
|
|
544
|
+
* @param N
|
|
545
|
+
*/
|
|
546
|
+
generate_bulletproof(amounts: number[], blinding_factors: string[], N?: number): Promise<{
|
|
547
|
+
proof: crypto_bulletproof_t;
|
|
548
|
+
commitments: string[];
|
|
549
|
+
}>;
|
|
550
|
+
/**
|
|
551
|
+
* Checks that a Bulletproof proof is valid
|
|
552
|
+
*
|
|
553
|
+
* @param proof
|
|
554
|
+
* @param commitments
|
|
555
|
+
* @param N
|
|
556
|
+
*/
|
|
557
|
+
check_bulletproof(proof: crypto_bulletproof_t | crypto_bulletproof_t[], commitments: string[] | string[][], N?: number): Promise<boolean>;
|
|
558
|
+
/**
|
|
559
|
+
* Generates a Bulletproof+ Zero-Knowledge proof of the amount(s) specified
|
|
560
|
+
*
|
|
561
|
+
* @param amounts
|
|
562
|
+
* @param blinding_factors
|
|
563
|
+
* @param N
|
|
564
|
+
*/
|
|
565
|
+
generate_bulletproof_plus(amounts: number[], blinding_factors: string[], N?: number): Promise<{
|
|
566
|
+
proof: crypto_bulletproof_plus_t;
|
|
567
|
+
commitments: string[];
|
|
568
|
+
}>;
|
|
569
|
+
/**
|
|
570
|
+
* Checks that a Bulletproof+ proof is valid
|
|
571
|
+
*
|
|
572
|
+
* @param proof
|
|
573
|
+
* @param commitments
|
|
574
|
+
* @param N
|
|
575
|
+
*/
|
|
576
|
+
check_bulletproof_plus(proof: crypto_bulletproof_plus_t | crypto_bulletproof_plus_t[], commitments: string[] | string[][], N?: number): Promise<boolean>;
|
|
577
|
+
/**
|
|
578
|
+
* Verifies that the sum of output pedersen commitments plus a pedersen
|
|
579
|
+
* commitment of the transaction fee are equal to the sum of pseudo
|
|
580
|
+
* pedersen commitments
|
|
581
|
+
*
|
|
582
|
+
* @param pseudo_commitments
|
|
583
|
+
* @param output_commitments
|
|
584
|
+
* @param transaction_fee
|
|
585
|
+
*/
|
|
586
|
+
check_commitments_parity(pseudo_commitments: string[], output_commitments: string[], transaction_fee: number): Promise<boolean>;
|
|
587
|
+
/**
|
|
588
|
+
* Generates the amount mask for the given deriviation scalar
|
|
589
|
+
*
|
|
590
|
+
* @param derivation_scalar
|
|
591
|
+
*/
|
|
592
|
+
generate_amount_mask(derivation_scalar: string): Promise<string>;
|
|
593
|
+
/**
|
|
594
|
+
* Generates the commitment blinding factor for the given derivation scalar
|
|
595
|
+
*
|
|
596
|
+
* @param derivation_scalar
|
|
597
|
+
*/
|
|
598
|
+
generate_commitment_blinding_factor(derivation_scalar: string): Promise<string>;
|
|
599
|
+
/**
|
|
600
|
+
* Generates a pedersen commitment for the supplied blinding factor and amount
|
|
601
|
+
*
|
|
602
|
+
* Note: C = (y * G) + (a * H) mod l
|
|
603
|
+
*
|
|
604
|
+
* @param blinding_factor
|
|
605
|
+
* @param amount
|
|
606
|
+
*/
|
|
607
|
+
generate_pedersen_commitment(blinding_factor: string, amount: number): Promise<string>;
|
|
608
|
+
/**
|
|
609
|
+
* Generates a list of random blinding factors and pseudo output commitments from
|
|
610
|
+
* the list of input amounts and the output commitments while proving them to a zero-sum
|
|
611
|
+
*
|
|
612
|
+
* @param amounts
|
|
613
|
+
* @param output_blinding_factors
|
|
614
|
+
*/
|
|
615
|
+
generate_pseudo_commitments(amounts: number[], output_blinding_factors: string[]): Promise<{
|
|
616
|
+
blinding_factors: string[];
|
|
617
|
+
commitments: string[];
|
|
618
|
+
}>;
|
|
619
|
+
/**
|
|
620
|
+
* Toggles an amount from unmasked/masked to the inverse state of masked/unmasked using the
|
|
621
|
+
* provided amount mask
|
|
622
|
+
*
|
|
623
|
+
* @param amount_mask
|
|
624
|
+
* @param amount
|
|
625
|
+
*/
|
|
626
|
+
toggle_masked_amount(amount_mask: string, amount: string | number | bigint): Promise<bigint>;
|
|
627
|
+
/**
|
|
628
|
+
* Generates proof of having the secret ephemerals specified by generating the
|
|
629
|
+
* relevant public keys, key_images, and signature for each and encoding the
|
|
630
|
+
* necessary information into a Base58 encoded string that can be provided
|
|
631
|
+
* to a verified that already has the public ephemerals
|
|
632
|
+
*
|
|
633
|
+
* @param secret_ephemerals
|
|
634
|
+
*/
|
|
635
|
+
generate_outputs_proof(secret_ephemerals: string[]): Promise<string>;
|
|
636
|
+
/**
|
|
637
|
+
* Verifies the proof provides using the public ephemerals by decoding the Base58 proof,
|
|
638
|
+
* extracting the key images, the signatures, and then verifying if those signatures
|
|
639
|
+
* are all valid, in which case, the key images are returned
|
|
640
|
+
*
|
|
641
|
+
* @param public_ephemerals
|
|
642
|
+
* @param proof
|
|
643
|
+
*/
|
|
644
|
+
check_outputs_proof(public_ephemerals: string[], proof: string): Promise<string[]>;
|
|
645
|
+
/**
|
|
646
|
+
* Encodes the value specified into Base58
|
|
647
|
+
*
|
|
648
|
+
* @param value
|
|
649
|
+
*/
|
|
650
|
+
base58_encode(value: string | Buffer): Promise<string>;
|
|
651
|
+
/**
|
|
652
|
+
* Encodes the value specified into Base58 and appends a checksum to the result
|
|
653
|
+
*
|
|
654
|
+
* @param value
|
|
655
|
+
*/
|
|
656
|
+
base58_encode_check(value: string | Buffer): Promise<string>;
|
|
657
|
+
/**
|
|
658
|
+
* Decodes a Base58 encoded string
|
|
659
|
+
*
|
|
660
|
+
* @param base58
|
|
661
|
+
*/
|
|
662
|
+
base58_decode(base58: string): Promise<Buffer>;
|
|
663
|
+
/**
|
|
664
|
+
* Decodes a Base58 encoded string after verifying the checksum value included
|
|
665
|
+
*
|
|
666
|
+
* @param base58
|
|
667
|
+
*/
|
|
668
|
+
base58_decode_check(base58: string): Promise<Buffer>;
|
|
669
|
+
/**
|
|
670
|
+
* Encodes the specified value into CryptoNote Base58
|
|
671
|
+
* @param value
|
|
672
|
+
*/
|
|
673
|
+
cn_base58_encode(value: string | Buffer): Promise<string>;
|
|
674
|
+
/**
|
|
675
|
+
* Encodes the value specified into CryptoNote Base58 and appends a checksum to the result
|
|
676
|
+
*
|
|
677
|
+
* @param value
|
|
678
|
+
*/
|
|
679
|
+
cn_base58_encode_check(value: string | Buffer): Promise<string>;
|
|
680
|
+
/**
|
|
681
|
+
* Decodes a CryptoNote Base58 string
|
|
682
|
+
*
|
|
683
|
+
* @param base58
|
|
684
|
+
*/
|
|
685
|
+
cn_base58_decode(base58: string): Promise<Buffer>;
|
|
686
|
+
/**
|
|
687
|
+
* Decodes a CryptoNote Base58 encoded string after verifying the checkvalue value included
|
|
688
|
+
*
|
|
689
|
+
* @param base58
|
|
690
|
+
*/
|
|
691
|
+
cn_base58_decode_check(base58: string): Promise<Buffer>;
|
|
692
|
+
/**
|
|
693
|
+
* Generates a pedersen commitment for a transaction fee
|
|
694
|
+
*
|
|
695
|
+
* @param amount
|
|
696
|
+
*/
|
|
697
|
+
generate_transaction_fee_commitment(amount: number): Promise<string>;
|
|
698
|
+
/**
|
|
699
|
+
* Checks if the value provided is a valid ED25519 scalar
|
|
700
|
+
*
|
|
701
|
+
* @param value
|
|
702
|
+
*/
|
|
703
|
+
check_scalar(value: string): Promise<boolean>;
|
|
704
|
+
/**
|
|
705
|
+
* Checks if the value provided is a valid ED25519 point
|
|
706
|
+
* @param value
|
|
707
|
+
*/
|
|
708
|
+
check_point(value: string): Promise<boolean>;
|
|
709
|
+
/**
|
|
710
|
+
* Encodes the supplied seed into a list of mnemonic words
|
|
711
|
+
*
|
|
712
|
+
* @param entropy
|
|
713
|
+
* @param language
|
|
714
|
+
*/
|
|
715
|
+
mnemonics_encode(entropy: string, language?: Language): Promise<string[]>;
|
|
716
|
+
/**
|
|
717
|
+
* Decodes a mnemonic phrase or list of mnenomic words into as seed value
|
|
718
|
+
*
|
|
719
|
+
* @param mnemonic
|
|
720
|
+
* @param language
|
|
721
|
+
*/
|
|
722
|
+
mnemonics_decode(mnemonic: string | string[], language?: Language): Promise<crypto_entropy_t>;
|
|
723
|
+
/**
|
|
724
|
+
* Returns the index number of the specified mnemonic word
|
|
725
|
+
*
|
|
726
|
+
* @param word
|
|
727
|
+
* @param language
|
|
728
|
+
*/
|
|
729
|
+
mnemonics_word_index(word: string, language?: Language): Promise<number>;
|
|
730
|
+
/**
|
|
731
|
+
* Returns the list of mnemonic words
|
|
732
|
+
*
|
|
733
|
+
* @param language
|
|
734
|
+
*/
|
|
735
|
+
word_list(language?: Language): Promise<string[]>;
|
|
736
|
+
/**
|
|
737
|
+
* Returns the list of mnemonic words that have been trimmed to
|
|
738
|
+
* the minimum number of characters per word
|
|
739
|
+
*
|
|
740
|
+
* @param language
|
|
741
|
+
*/
|
|
742
|
+
word_list_trimmed(language?: Language): Promise<string[]>;
|
|
743
|
+
/**
|
|
744
|
+
* Calculates the exponent of 2^e that matches the target value
|
|
745
|
+
*
|
|
746
|
+
* @param value
|
|
747
|
+
*/
|
|
748
|
+
calculate_base2_exponent(value: number): Promise<number>;
|
|
749
|
+
/**
|
|
750
|
+
* Encrypts the provides string using the supplied password into a hexadecimal encoded string
|
|
751
|
+
*
|
|
752
|
+
* @param input
|
|
753
|
+
* @param password
|
|
754
|
+
* @param iterations
|
|
755
|
+
*/
|
|
756
|
+
aes_encrypt<InputType = string>(input: InputType, password: string, iterations?: number): Promise<string>;
|
|
757
|
+
/**
|
|
758
|
+
* Decrypts the data from the provided hexidecimal encoded encrypted string using the supplied password
|
|
759
|
+
*
|
|
760
|
+
* @param input
|
|
761
|
+
* @param password
|
|
762
|
+
* @param iterations
|
|
763
|
+
*/
|
|
764
|
+
aes_decrypt<OutputType = string>(input: string, password: string, iterations?: number): Promise<OutputType>;
|
|
765
|
+
/**
|
|
766
|
+
* Returns a list of the supported languages
|
|
767
|
+
*/
|
|
768
|
+
languages(): Promise<Language[]>;
|
|
769
|
+
/**
|
|
770
|
+
* Generates a BIP-39 seed from the provided entropy
|
|
771
|
+
*
|
|
772
|
+
* @param entropy
|
|
773
|
+
* @param passphrase
|
|
774
|
+
*/
|
|
775
|
+
generate_seed(entropy: string, passphrase?: string): Promise<string>;
|
|
776
|
+
/**
|
|
777
|
+
* Generates a Hierarchical Deterministic Key Pair using the provided path
|
|
778
|
+
*
|
|
779
|
+
* @param seed
|
|
780
|
+
* @param purpose
|
|
781
|
+
* @param coin_type
|
|
782
|
+
* @param account
|
|
783
|
+
* @param change
|
|
784
|
+
* @param address_index
|
|
785
|
+
* @param hmac_key
|
|
786
|
+
*/
|
|
787
|
+
generate_child_key(seed: string, purpose?: number, coin_type?: number, account?: number, change?: number, address_index?: number, hmac_key?: string): Promise<key_pair_t>;
|
|
788
|
+
/**
|
|
789
|
+
* Generates a hardened Hierarchical Deterministic Key path
|
|
790
|
+
*
|
|
791
|
+
* @param purpose
|
|
792
|
+
* @param coin_type
|
|
793
|
+
* @param account
|
|
794
|
+
* @param change
|
|
795
|
+
* @param address_index
|
|
796
|
+
*/
|
|
797
|
+
make_path(purpose?: number, coin_type?: number, account?: number, change?: number, address_index?: number): string;
|
|
798
|
+
/**
|
|
799
|
+
* Executes the method call using the underlying library
|
|
800
|
+
*
|
|
801
|
+
* @param method
|
|
802
|
+
* @param argument
|
|
803
|
+
* @private
|
|
804
|
+
*/
|
|
805
|
+
private execute;
|
|
806
|
+
}
|