eth-crypto-ts 0.0.5 → 0.0.6

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 (2) hide show
  1. package/README.md +103 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,9 +2,108 @@
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/eth-crypto-ts.svg)](https://badge.fury.io/js/eth-crypto-ts)
4
4
 
5
- This repository aims to transform `eth-crypto` to a typescript library.
5
+ A **lightweight, TypeScript-first** cryptography library for Ethereum. Built as an improvement over the original `eth-crypto`, with a curated subset of functions and **zero Node.js polyfill requirements**.
6
6
 
7
- It fixes a few issues with building as well as polyfilling node native packages.
8
- This is particularily useful when using the package on a client or native environment where default node packages may not be availabe.
7
+ ## Why eth-crypto-ts?
9
8
 
10
- It has not been tested thoroughly yet due to time limitations, so use on your own risk. However I do not advise using it in a production environment.
9
+ - **Lightweight** Uses [`@noble/hashes`](https://github.com/paulmillr/noble-hashes) instead of heavy alternatives, significantly reducing bundle size
10
+ - **No polyfills** — Works seamlessly in browsers, React Native, and Node.js without requiring crypto or other Node.js native module polyfills
11
+ - **TypeScript-first** — Fully typed, built with modern TypeScript
12
+ - **Focused API** — Exports only the essential crypto functions needed for Ethereum applications
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install eth-crypto-ts
18
+ ```
19
+
20
+ ## API
21
+
22
+ ### `createIdentity()`
23
+
24
+ Creates a new Ethereum identity (private key + public key).
25
+
26
+ ```typescript
27
+ import { createIdentity } from 'eth-crypto-ts';
28
+
29
+ const identity = createIdentity();
30
+ // { privateKey: '0x...', publicKey: '0x...' }
31
+ ```
32
+
33
+ ### `sign(privateKey, message)`
34
+
35
+ Sign a message with a private key.
36
+
37
+ ```typescript
38
+ import { sign } from 'eth-crypto-ts';
39
+
40
+ const signature = sign(privateKey, messageHash);
41
+ ```
42
+
43
+ ### `encryptWithPublicKey(publicKey, message)`
44
+
45
+ Encrypt data with a public key using ECIES.
46
+
47
+ ```typescript
48
+ import { encryptWithPublicKey } from 'eth-crypto-ts';
49
+
50
+ const encrypted = encryptWithPublicKey(publicKey, 'secret message');
51
+ // { iv, ephemPublicKey, ciphertext, mac }
52
+ ```
53
+
54
+ ### `decryptWithPrivateKey(privateKey, encrypted)`
55
+
56
+ Decrypt ECIES-encrypted data with a private key.
57
+
58
+ ```typescript
59
+ import { decryptWithPrivateKey } from 'eth-crypto-ts';
60
+
61
+ const message = decryptWithPrivateKey(privateKey, encrypted);
62
+ ```
63
+
64
+ ### `publicKeyByPrivateKey(privateKey)`
65
+
66
+ Derive the public key from a private key.
67
+
68
+ ```typescript
69
+ import { publicKeyByPrivateKey } from 'eth-crypto-ts';
70
+
71
+ const publicKey = publicKeyByPrivateKey(privateKey);
72
+ ```
73
+
74
+ ### `recoverPublicKey(messageHash, signature)`
75
+
76
+ Recover the public key from a message and its signature.
77
+
78
+ ```typescript
79
+ import { recoverPublicKey } from 'eth-crypto-ts';
80
+
81
+ const publicKey = recoverPublicKey(messageHash, signature);
82
+ ```
83
+
84
+ ### `keccak256(data)`
85
+
86
+ Compute the Keccak-256 hash.
87
+
88
+ ```typescript
89
+ import { keccak256 } from 'eth-crypto-ts';
90
+
91
+ const hash = keccak256('0x' + Buffer.from('data').toString('hex'));
92
+ ```
93
+
94
+ Or use the namespaced version:
95
+
96
+ ```typescript
97
+ import { hash } from 'eth-crypto-ts';
98
+
99
+ const h = hash.keccak256('0x...');
100
+ ```
101
+
102
+ ## Notes
103
+
104
+ - This library is a **curated subset** of the original `eth-crypto`, focusing on the most commonly needed functions
105
+ - Ideal for applications where bundle size and environment compatibility matter
106
+
107
+ ## License
108
+
109
+ ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eth-crypto-ts",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "eth-crypto library with typescript",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",