@gibme/crypto-browser 7.0.4 → 20.0.0
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/dist/Crypto.min.js +1 -1
- package/dist/Crypto.min.js.LICENSE.txt +0 -7
- package/dist/Crypto.min.js.map +1 -1
- package/dist/browser/src/index.d.ts +3 -3
- package/dist/browser/src/index.js +5 -5
- package/dist/browser/src/index.js.map +1 -1
- package/dist/browser/src/version.d.ts +1 -1
- package/dist/browser/src/version.js +1 -1
- package/dist/browser/src/version.js.map +1 -1
- package/dist/types/index.d.ts +246 -22
- package/dist/types/index.js +151 -29
- package/dist/types/index.js.map +1 -1
- package/dist/types/lite.d.ts +23 -0
- package/dist/types/lite.js +73 -0
- package/dist/types/lite.js.map +1 -0
- package/dist/types/types.d.ts +14 -198
- package/dist/types/types.js +1 -32
- package/dist/types/types.js.map +1 -1
- package/dist/types/uint64.d.ts +13 -12
- package/dist/types/uint64.js +22 -30
- package/dist/types/uint64.js.map +1 -1
- package/package.json +16 -5
- package/dist/types/helpers.d.ts +0 -43
- package/dist/types/helpers.js +0 -123
- package/dist/types/helpers.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CryptoModule
|
|
1
|
+
import { CryptoModule } from '../../types';
|
|
2
2
|
export * from '../../types';
|
|
3
3
|
declare global {
|
|
4
4
|
interface Window {
|
|
5
|
-
CryptoModule?:
|
|
5
|
+
CryptoModule?: CryptoModule.Interface;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
export default class Crypto extends CryptoModule {
|
|
@@ -19,7 +19,7 @@ export default class Crypto extends CryptoModule {
|
|
|
19
19
|
* the underlying cryptographic library in the order the fastest
|
|
20
20
|
* running library to the slowest
|
|
21
21
|
*/
|
|
22
|
-
static init(externalLibrary?: Partial<
|
|
22
|
+
static init(externalLibrary?: Partial<CryptoModule.Interface>): Promise<Crypto>;
|
|
23
23
|
/**
|
|
24
24
|
* Forces the library to use the Javascript ASM.js underlying
|
|
25
25
|
* cryptographic library if it can
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright (c) 2020, Brandon Lehmann
|
|
2
|
+
// Copyright (c) 2020-2025, Brandon Lehmann
|
|
3
3
|
//
|
|
4
4
|
// Redistribution and use in source and binary forms, with or without modification, are
|
|
5
5
|
// permitted provided that the following conditions are met:
|
|
@@ -142,11 +142,11 @@ class Crypto extends types_1.CryptoModule {
|
|
|
142
142
|
* @private
|
|
143
143
|
*/
|
|
144
144
|
static async load_js_library() {
|
|
145
|
-
if (await this.load_library(`https://cdn.jsdelivr.net/npm/@gibme/crypto@${version_1.version}/dist/crypto-module.js`, types_1.
|
|
145
|
+
if (await this.load_library(`https://cdn.jsdelivr.net/npm/@gibme/crypto@${version_1.version}/dist/src/loaders/crypto-module.js`, types_1.CryptoModule.Type.JS)) {
|
|
146
146
|
return true;
|
|
147
147
|
}
|
|
148
148
|
// this is a fallback
|
|
149
|
-
return this.load_library('https://testmodule.pages.dev/crypto-module.js', types_1.
|
|
149
|
+
return this.load_library('https://testmodule.pages.dev/crypto-module.js', types_1.CryptoModule.Type.JS);
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* Attempts to load the WASM module as the underlying cryptographic
|
|
@@ -155,11 +155,11 @@ class Crypto extends types_1.CryptoModule {
|
|
|
155
155
|
* @private
|
|
156
156
|
*/
|
|
157
157
|
static async load_wasm_library() {
|
|
158
|
-
if (await this.load_library(`https://cdn.jsdelivr.net/npm/@gibme/crypto@${version_1.version}/dist/crypto-module-wasm.js`, types_1.
|
|
158
|
+
if (await this.load_library(`https://cdn.jsdelivr.net/npm/@gibme/crypto@${version_1.version}/dist/src/loaders/crypto-module-wasm.js`, types_1.CryptoModule.Type.WASM)) {
|
|
159
159
|
return true;
|
|
160
160
|
}
|
|
161
161
|
// this is a fallback
|
|
162
|
-
return this.load_library('https://testmodule.pages.dev/crypto-module-wasm.js', types_1.
|
|
162
|
+
return this.load_library('https://testmodule.pages.dev/crypto-module-wasm.js', types_1.CryptoModule.Type.WASM);
|
|
163
163
|
}
|
|
164
164
|
/**
|
|
165
165
|
* Checks if the URL exists
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";AAAA,2CAA2C;AAC3C,EAAE;AACF,uFAAuF;AACvF,4DAA4D;AAC5D,EAAE;AACF,yFAAyF;AACzF,8CAA8C;AAC9C,EAAE;AACF,yFAAyF;AACzF,kFAAkF;AAClF,+CAA+C;AAC/C,EAAE;AACF,uFAAuF;AACvF,qFAAqF;AACrF,+BAA+B;AAC/B,EAAE;AACF,sFAAsF;AACtF,0FAA0F;AAC1F,yFAAyF;AACzF,uFAAuF;AACvF,+EAA+E;AAC/E,0FAA0F;AAC1F,oFAAoF;AACpF,0FAA0F;AAC1F,+EAA+E;;;;;;;;;;;;;;;;;AAE/E,uCAA2C;AAC3C,uCAAoC;AAEpC,8CAA4B;AAQ5B,MAAqB,MAAO,SAAQ,oBAAY;IAC5C;;;;;;OAMG;IACH,kDAAkD;IAClD;QACI,KAAK,EAAE,CAAC;IACZ,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAE,kBAAmD,EAAE;QAC3E,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QAExC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;YACtC,IAAI,MAAM,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC;gBACjC,OAAO,IAAI,MAAM,EAAE,CAAC;YACxB,CAAC;YAED,IAAI,MAAM,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;gBAC/B,OAAO,IAAI,MAAM,EAAE,CAAC;YACxB,CAAC;YAED,MAAM,IAAI,KAA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,CAAC;IAC3G,CAAC;IAED;;;;;OAKG;IACK,MAAM,CAAC,KAAK,CAAC,UAAU,CAAE,GAAW;QACxC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAEtD,OAAO,QAAQ,CAAC,EAAE,CAAC;IACvB,CAAC;CACJ;AA3JD,yBA2JC;AAEQ,wBAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "
|
|
1
|
+
export declare const version = "20.0.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACzC,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACzC,QAAA,OAAO,GAAG,QAAQ,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
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
|
|
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 } from './types';
|
|
2
2
|
import { Buffer } from 'buffer';
|
|
3
3
|
export * from './types';
|
|
4
|
-
export * from './helpers';
|
|
5
4
|
/**
|
|
6
5
|
* @ignore
|
|
7
6
|
*/
|
|
8
7
|
export declare abstract class CryptoModule {
|
|
9
|
-
|
|
10
|
-
protected static runtime_configuration: ModuleSettings;
|
|
8
|
+
protected static runtime_configuration: CryptoModule.Settings;
|
|
11
9
|
/**
|
|
12
10
|
* We cannot create a new instance using this method as we need to await the
|
|
13
11
|
* loading of an underlying module, hence, we need to await the static
|
|
@@ -16,16 +14,23 @@ export declare abstract class CryptoModule {
|
|
|
16
14
|
* @protected
|
|
17
15
|
*/
|
|
18
16
|
protected constructor();
|
|
17
|
+
private static _external_library;
|
|
19
18
|
/**
|
|
20
19
|
* Gets the external library calls that replace our cryptographic method calls
|
|
21
20
|
*/
|
|
22
|
-
static get external_library(): Partial<
|
|
21
|
+
static get external_library(): Partial<CryptoModule.Interface>;
|
|
22
|
+
/**
|
|
23
|
+
* Sets external library calls that replace our cryptographic method calls
|
|
24
|
+
*
|
|
25
|
+
* @param config
|
|
26
|
+
*/
|
|
27
|
+
static set external_library(config: Partial<CryptoModule.Interface>);
|
|
23
28
|
/**
|
|
24
29
|
* Sets external library calls that replace our cryptographic method calls
|
|
25
30
|
*
|
|
26
31
|
* @param config
|
|
27
32
|
*/
|
|
28
|
-
|
|
33
|
+
set external_library(config: Partial<CryptoModule.Interface>);
|
|
29
34
|
/**
|
|
30
35
|
* Returns the underlying cryptographic library name
|
|
31
36
|
*/
|
|
@@ -33,22 +38,16 @@ export declare abstract class CryptoModule {
|
|
|
33
38
|
/**
|
|
34
39
|
* Returns the underlying cryptographic library type
|
|
35
40
|
*/
|
|
36
|
-
static get library_type():
|
|
41
|
+
static get library_type(): CryptoModule.Type;
|
|
37
42
|
/**
|
|
38
43
|
* Returns if the underlying cryptographic library is of the
|
|
39
44
|
* Node.js C++ Addon type
|
|
40
45
|
*/
|
|
41
46
|
static get is_native(): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Sets external library calls that replace our cryptographic method calls
|
|
44
|
-
*
|
|
45
|
-
* @param config
|
|
46
|
-
*/
|
|
47
|
-
set external_library(config: Partial<ICryptoLibrary>);
|
|
48
47
|
/**
|
|
49
48
|
* Gets the external library calls that replace our cryptographic method calls
|
|
50
49
|
*/
|
|
51
|
-
get external_library(): Partial<
|
|
50
|
+
get external_library(): Partial<CryptoModule.Interface>;
|
|
52
51
|
/**
|
|
53
52
|
* Returns the underlying cryptographic library name
|
|
54
53
|
*/
|
|
@@ -56,12 +55,53 @@ export declare abstract class CryptoModule {
|
|
|
56
55
|
/**
|
|
57
56
|
* Returns the underlying cryptographic library type
|
|
58
57
|
*/
|
|
59
|
-
get library_type():
|
|
58
|
+
get library_type(): CryptoModule.Type;
|
|
60
59
|
/**
|
|
61
60
|
* Returns if the underlying cryptographic library is of the
|
|
62
61
|
* Node.js C++ Addon type
|
|
63
62
|
*/
|
|
64
63
|
get is_native(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Tests if the supplied string is of hexadecimal form
|
|
66
|
+
*
|
|
67
|
+
* @param value
|
|
68
|
+
* @ignore
|
|
69
|
+
*/
|
|
70
|
+
static is_hex(value: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Constructs a Module Result
|
|
73
|
+
*
|
|
74
|
+
* Note: This is typically only used by external cryptographic library calls
|
|
75
|
+
* so that it mimics our underlying library call results
|
|
76
|
+
*
|
|
77
|
+
* The string returned should always be a raw type, whether it be
|
|
78
|
+
* a string, a number, or an object as expected by the module.
|
|
79
|
+
*
|
|
80
|
+
* If you are using external libraries for the underlying cryptographic library,
|
|
81
|
+
* it is highly recommended that you read the source code of this module
|
|
82
|
+
* to make sure that you are returning a result of the proper structure.
|
|
83
|
+
*
|
|
84
|
+
* This method will `JSON.stringify()` whatever result you supply so that our
|
|
85
|
+
* module understands it within it's private `execute()` method
|
|
86
|
+
*
|
|
87
|
+
* @param error
|
|
88
|
+
* @param result
|
|
89
|
+
* @param error_message
|
|
90
|
+
*/
|
|
91
|
+
static make_module_result<ResultType = string>(error: boolean, result: ResultType, error_message?: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* Returns the common lanague name for the specified language
|
|
94
|
+
*
|
|
95
|
+
* @param language
|
|
96
|
+
*/
|
|
97
|
+
static languageToString(language: CryptoModule.Language): string;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the library name from the specified library type
|
|
100
|
+
*
|
|
101
|
+
* @param type
|
|
102
|
+
* @protected
|
|
103
|
+
*/
|
|
104
|
+
protected static typeToString(type: CryptoModule.Type): string;
|
|
65
105
|
/**
|
|
66
106
|
* Encodes an address into Base58
|
|
67
107
|
*
|
|
@@ -208,7 +248,7 @@ export declare abstract class CryptoModule {
|
|
|
208
248
|
* @param mnenomic_phrase
|
|
209
249
|
* @param language
|
|
210
250
|
*/
|
|
211
|
-
entropy_recover(mnenomic_phrase: string | string[], language?: Language): Promise<crypto_entropy_t>;
|
|
251
|
+
entropy_recover(mnenomic_phrase: string | string[], language?: CryptoModule.Language): Promise<crypto_entropy_t>;
|
|
212
252
|
/**
|
|
213
253
|
* Generates a key derivation
|
|
214
254
|
*
|
|
@@ -713,34 +753,34 @@ export declare abstract class CryptoModule {
|
|
|
713
753
|
* @param entropy
|
|
714
754
|
* @param language
|
|
715
755
|
*/
|
|
716
|
-
mnemonics_encode(entropy: string, language?: Language): Promise<string[]>;
|
|
756
|
+
mnemonics_encode(entropy: string, language?: CryptoModule.Language): Promise<string[]>;
|
|
717
757
|
/**
|
|
718
758
|
* Decodes a mnemonic phrase or list of mnenomic words into as seed value
|
|
719
759
|
*
|
|
720
760
|
* @param mnemonic
|
|
721
761
|
* @param language
|
|
722
762
|
*/
|
|
723
|
-
mnemonics_decode(mnemonic: string | string[], language?: Language): Promise<crypto_entropy_t>;
|
|
763
|
+
mnemonics_decode(mnemonic: string | string[], language?: CryptoModule.Language): Promise<crypto_entropy_t>;
|
|
724
764
|
/**
|
|
725
765
|
* Returns the index number of the specified mnemonic word
|
|
726
766
|
*
|
|
727
767
|
* @param word
|
|
728
768
|
* @param language
|
|
729
769
|
*/
|
|
730
|
-
mnemonics_word_index(word: string, language?: Language): Promise<number>;
|
|
770
|
+
mnemonics_word_index(word: string, language?: CryptoModule.Language): Promise<number>;
|
|
731
771
|
/**
|
|
732
772
|
* Returns the list of mnemonic words
|
|
733
773
|
*
|
|
734
774
|
* @param language
|
|
735
775
|
*/
|
|
736
|
-
word_list(language?: Language): Promise<string[]>;
|
|
776
|
+
word_list(language?: CryptoModule.Language): Promise<string[]>;
|
|
737
777
|
/**
|
|
738
778
|
* Returns the list of mnemonic words that have been trimmed to
|
|
739
779
|
* the minimum number of characters per word
|
|
740
780
|
*
|
|
741
781
|
* @param language
|
|
742
782
|
*/
|
|
743
|
-
word_list_trimmed(language?: Language): Promise<string[]>;
|
|
783
|
+
word_list_trimmed(language?: CryptoModule.Language): Promise<string[]>;
|
|
744
784
|
/**
|
|
745
785
|
* Calculates the exponent of 2^e that matches the target value
|
|
746
786
|
*
|
|
@@ -766,7 +806,7 @@ export declare abstract class CryptoModule {
|
|
|
766
806
|
/**
|
|
767
807
|
* Returns a list of the supported languages
|
|
768
808
|
*/
|
|
769
|
-
languages(): Promise<Language[]>;
|
|
809
|
+
languages(): Promise<CryptoModule.Language[]>;
|
|
770
810
|
/**
|
|
771
811
|
* Generates a BIP-39 seed from the provided entropy
|
|
772
812
|
*
|
|
@@ -805,3 +845,187 @@ export declare abstract class CryptoModule {
|
|
|
805
845
|
*/
|
|
806
846
|
private execute;
|
|
807
847
|
}
|
|
848
|
+
export declare namespace CryptoModule {
|
|
849
|
+
/**
|
|
850
|
+
* The type of the underlying cryptographic library
|
|
851
|
+
*/
|
|
852
|
+
enum Type {
|
|
853
|
+
UNKNOWN = 0,
|
|
854
|
+
NODE = 1,
|
|
855
|
+
WASM = 2,
|
|
856
|
+
JS = 3
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* The type of the mnemonic phrase language
|
|
860
|
+
*
|
|
861
|
+
* Note: You will want to call the module `languages()` to get
|
|
862
|
+
* the list of languages supported by the underlying cryptographic
|
|
863
|
+
* module before attempting to use a particular language
|
|
864
|
+
*/
|
|
865
|
+
enum Language {
|
|
866
|
+
CHINESE_SIMPLIFIED = 0,
|
|
867
|
+
CHINESE_TRADITIONAL = 1,
|
|
868
|
+
CZECH = 2,
|
|
869
|
+
ENGLISH = 3,
|
|
870
|
+
FRENCH = 4,
|
|
871
|
+
ITALIAN = 5,
|
|
872
|
+
JAPANESE = 6,
|
|
873
|
+
KOREAN = 7,
|
|
874
|
+
PORTUGUESE = 8,
|
|
875
|
+
SPANISH = 9
|
|
876
|
+
}
|
|
877
|
+
namespace External {
|
|
878
|
+
/**
|
|
879
|
+
* Defines the structure for when we interact with the generation of ring
|
|
880
|
+
* signatures using our underlying cryptographic library
|
|
881
|
+
*/
|
|
882
|
+
type GenerateRingSignature<SignatureType = any> = {
|
|
883
|
+
message_digest?: string;
|
|
884
|
+
secret_ephemeral?: string;
|
|
885
|
+
public_keys?: string[];
|
|
886
|
+
input_blinding_factor?: string;
|
|
887
|
+
public_commitments?: string[];
|
|
888
|
+
pseudo_blinding_factor?: string;
|
|
889
|
+
pseudo_commitment?: string;
|
|
890
|
+
real_output_index?: number;
|
|
891
|
+
key_image?: string;
|
|
892
|
+
signature?: SignatureType;
|
|
893
|
+
h?: string[];
|
|
894
|
+
mu_P?: string;
|
|
895
|
+
xpow?: string;
|
|
896
|
+
};
|
|
897
|
+
/**
|
|
898
|
+
* Defines the structure for when we interact with the AES methods
|
|
899
|
+
* in our underlying cryptographic library
|
|
900
|
+
*/
|
|
901
|
+
type AES = {
|
|
902
|
+
input: string;
|
|
903
|
+
password: string;
|
|
904
|
+
iterations?: number;
|
|
905
|
+
};
|
|
906
|
+
/**
|
|
907
|
+
* Defines the structure for when we interact with the checking of ring
|
|
908
|
+
* signatures using our underlying cryptographic library
|
|
909
|
+
*/
|
|
910
|
+
type CheckRingSignature<SignatureType> = {
|
|
911
|
+
message_digest: string;
|
|
912
|
+
key_image: string;
|
|
913
|
+
public_keys: string[];
|
|
914
|
+
signature: SignatureType;
|
|
915
|
+
commitments?: string[];
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Defines the Call types going into our underlying cryptographic library
|
|
920
|
+
*/
|
|
921
|
+
namespace Call {
|
|
922
|
+
type WithArguments = (input: string) => Promise<string>;
|
|
923
|
+
type WithoutArguments = () => Promise<string>;
|
|
924
|
+
type Signature = WithArguments | WithoutArguments;
|
|
925
|
+
/**
|
|
926
|
+
* @ignore
|
|
927
|
+
*/
|
|
928
|
+
type Result<Type> = {
|
|
929
|
+
error: boolean;
|
|
930
|
+
result: Type;
|
|
931
|
+
error_message?: string;
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Defines the interface uses with our underlying cryptographic library
|
|
936
|
+
* or an externally provided library
|
|
937
|
+
*/
|
|
938
|
+
type Interface = {
|
|
939
|
+
random_entropy: Call.WithoutArguments;
|
|
940
|
+
random_hash: Call.WithoutArguments;
|
|
941
|
+
random_hashes: Call.WithArguments;
|
|
942
|
+
random_scalar: Call.WithoutArguments;
|
|
943
|
+
random_scalars: Call.WithArguments;
|
|
944
|
+
random_point: Call.WithoutArguments;
|
|
945
|
+
random_points: Call.WithArguments;
|
|
946
|
+
sha3: Call.WithArguments;
|
|
947
|
+
sha3_slow: Call.WithArguments;
|
|
948
|
+
argon2i: Call.WithArguments;
|
|
949
|
+
argon2d: Call.WithArguments;
|
|
950
|
+
argon2id: Call.WithArguments;
|
|
951
|
+
entropy_recover: Call.WithArguments;
|
|
952
|
+
generate_derivation: Call.WithArguments;
|
|
953
|
+
generate_derivation_scalar: Call.WithArguments;
|
|
954
|
+
derive_public_key: Call.WithArguments;
|
|
955
|
+
derive_secret_key: Call.WithArguments;
|
|
956
|
+
generate_key_image: Call.WithArguments;
|
|
957
|
+
generate_key_image_v2: Call.WithArguments;
|
|
958
|
+
generate_keys: Call.WithoutArguments;
|
|
959
|
+
underive_public_key: Call.WithArguments;
|
|
960
|
+
secret_key_to_public_key: Call.WithArguments;
|
|
961
|
+
hash_to_point: Call.WithArguments;
|
|
962
|
+
hash_to_scalar: Call.WithArguments;
|
|
963
|
+
scalar_reduce: Call.WithArguments;
|
|
964
|
+
tree_depth: Call.WithArguments;
|
|
965
|
+
root_hash: Call.WithArguments;
|
|
966
|
+
root_hash_from_branch: Call.WithArguments;
|
|
967
|
+
tree_branch: Call.WithArguments;
|
|
968
|
+
generate_signature: Call.WithArguments;
|
|
969
|
+
prepare_signature: Call.WithArguments;
|
|
970
|
+
complete_signature: Call.WithArguments;
|
|
971
|
+
check_signature: Call.WithArguments;
|
|
972
|
+
generate_borromean_signature: Call.WithArguments;
|
|
973
|
+
prepare_borromean_signature: Call.WithArguments;
|
|
974
|
+
complete_borromean_signature: Call.WithArguments;
|
|
975
|
+
check_borromean_signature: Call.WithArguments;
|
|
976
|
+
generate_clsag_signature: Call.WithArguments;
|
|
977
|
+
prepare_clsag_signature: Call.WithArguments;
|
|
978
|
+
complete_clsag_signature: Call.WithArguments;
|
|
979
|
+
check_clsag_signature: Call.WithArguments;
|
|
980
|
+
generate_triptych_signature: Call.WithArguments;
|
|
981
|
+
prepare_triptych_signature: Call.WithArguments;
|
|
982
|
+
complete_triptych_signature: Call.WithArguments;
|
|
983
|
+
check_triptych_signature: Call.WithArguments;
|
|
984
|
+
generate_bulletproof: Call.WithArguments;
|
|
985
|
+
check_bulletproof: Call.WithArguments;
|
|
986
|
+
check_bulletproof_batch: Call.WithArguments;
|
|
987
|
+
generate_bulletproof_plus: Call.WithArguments;
|
|
988
|
+
check_bulletproof_plus: Call.WithArguments;
|
|
989
|
+
check_bulletproof_plus_batch: Call.WithArguments;
|
|
990
|
+
check_commitment_parity: Call.WithArguments;
|
|
991
|
+
generate_amount_mask: Call.WithArguments;
|
|
992
|
+
generate_commitment_blinding_factor: Call.WithArguments;
|
|
993
|
+
generate_pedersen_commitment: Call.WithArguments;
|
|
994
|
+
generate_pseudo_commitments: Call.WithArguments;
|
|
995
|
+
toggle_masked_amount: Call.WithArguments;
|
|
996
|
+
base58_address_decode: Call.WithArguments;
|
|
997
|
+
cn_base58_address_decode: Call.WithArguments;
|
|
998
|
+
generate_outputs_proof: Call.WithArguments;
|
|
999
|
+
check_outputs_proof: Call.WithArguments;
|
|
1000
|
+
base58_encode: Call.WithArguments;
|
|
1001
|
+
base58_encode_check: Call.WithArguments;
|
|
1002
|
+
base58_decode: Call.WithArguments;
|
|
1003
|
+
base58_decode_check: Call.WithArguments;
|
|
1004
|
+
cn_base58_encode: Call.WithArguments;
|
|
1005
|
+
cn_base58_encode_check: Call.WithArguments;
|
|
1006
|
+
cn_base58_decode: Call.WithArguments;
|
|
1007
|
+
cn_base58_decode_check: Call.WithArguments;
|
|
1008
|
+
check_scalar: Call.WithArguments;
|
|
1009
|
+
check_point: Call.WithArguments;
|
|
1010
|
+
generate_keys_m: Call.WithArguments;
|
|
1011
|
+
mnemonics_encode: Call.WithArguments;
|
|
1012
|
+
mnemonics_decode: Call.WithArguments;
|
|
1013
|
+
mnemonics_calculate_checksum_index: Call.WithArguments;
|
|
1014
|
+
mnemonics_word_index: Call.WithArguments;
|
|
1015
|
+
word_list: Call.WithoutArguments;
|
|
1016
|
+
word_list_trimmed: Call.WithoutArguments;
|
|
1017
|
+
calculate_base2_exponent: Call.WithArguments;
|
|
1018
|
+
aes_encrypt: Call.WithArguments;
|
|
1019
|
+
aes_decrypt: Call.WithArguments;
|
|
1020
|
+
generate_seed: Call.WithArguments;
|
|
1021
|
+
generate_child_key: Call.WithArguments;
|
|
1022
|
+
private_key_to_keys: Call.WithArguments;
|
|
1023
|
+
[key: string]: Call.Signature;
|
|
1024
|
+
};
|
|
1025
|
+
/** @ignore */
|
|
1026
|
+
type Settings = {
|
|
1027
|
+
library?: Interface;
|
|
1028
|
+
type: Type;
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
export default CryptoModule;
|