@@ -85,7 +85,7 @@ var DashHd = ("object" === typeof module && exports) || {};
85
85
const PUBLIC = false ;
86
86
87
87
//@ts -ignore
88
- let Crypto = window . crypto || require ( "crypto" ) ;
88
+ let Crypto = globalThis . crypto ;
89
89
90
90
//@ts -ignore
91
91
/** @type {import('dashkeys').DashKeys } */
@@ -99,8 +99,6 @@ var DashHd = ("object" === typeof module && exports) || {};
99
99
* @param {Object.<String, any> } [opts]
100
100
*/
101
101
Utils . decode = async function ( base58key , opts ) {
102
- //@ts -ignore - wth?
103
- let DashKeys = window . DashKeys || require ( "dashkeys" ) ;
104
102
//@ts -ignore
105
103
return await DashKeys . decode ( base58key , opts ) ;
106
104
} ;
@@ -111,8 +109,6 @@ var DashHd = ("object" === typeof module && exports) || {};
111
109
* @param {Number } [opts.version]
112
110
*/
113
111
Utils . encodeXPrv = async function ( keyBytes , opts ) {
114
- //@ts -ignore - wth?
115
- let DashKeys = window . DashKeys || require ( "dashkeys" ) ;
116
112
let version = "xprv" ;
117
113
if ( opts ?. version ) {
118
114
version = opts ?. version . toString ( 16 ) ;
@@ -127,8 +123,6 @@ var DashHd = ("object" === typeof module && exports) || {};
127
123
* TODO - pass tpub
128
124
*/
129
125
Utils . encodeXPub = async function ( keyBytes ) {
130
- //@ts -ignore - wth?
131
- let DashKeys = window . DashKeys || require ( "dashkeys" ) ;
132
126
//@ts -ignore
133
127
return await DashKeys . encodeKey ( keyBytes , { version : "xpub" } ) ;
134
128
} ;
@@ -177,30 +171,19 @@ var DashHd = ("object" === typeof module && exports) || {};
177
171
178
172
/** @type {HDHasher } */
179
173
Utils . ripemd160sum = async function ( bytes ) {
180
- //@ts -ignore
181
- let DashKeys = window . DashKeys || require ( "dashkeys" ) ;
182
174
//@ts -ignore
183
175
return await DashKeys . utils . ripemd160sum ( bytes ) ;
184
176
} ;
185
177
186
178
/** @type {HDHasher } */
187
179
Utils . sha256sum = async function ( bytes ) {
188
- if ( ! Crypto . subtle ) {
189
- let sha256 = Crypto . createHash ( "sha256" ) . update ( bytes ) . digest ( ) ;
190
- return new Uint8Array ( sha256 ) ;
191
- }
192
180
let arrayBuffer = await Crypto . subtle . digest ( "SHA-256" , bytes ) ;
193
181
let hashBytes = new Uint8Array ( arrayBuffer ) ;
194
182
return hashBytes ;
195
183
} ;
196
184
197
185
/** @type {HDHmac } */
198
186
Utils . sha512hmac = async function ( entropy , data ) {
199
- if ( ! Crypto . subtle ) {
200
- let buf = Crypto . createHmac ( "sha512" , entropy ) . update ( data ) . digest ( ) ;
201
- return new Uint8Array ( buf ) ;
202
- }
203
-
204
187
/** @type {"raw"|"pkcs8"|"spki" } */
205
188
let format = "raw" ;
206
189
let algo = {
@@ -241,11 +224,6 @@ var DashHd = ("object" === typeof module && exports) || {};
241
224
242
225
/** @type {HDSecureErase } */
243
226
Utils . secureErase = function ( buf ) {
244
- if ( ! Crypto . getRandomValues ) {
245
- Crypto . randomBytes ( buf . length ) . copy ( buf ) ;
246
- return ;
247
- }
248
-
249
227
Crypto . getRandomValues ( buf ) ;
250
228
} ;
251
229
0 commit comments