@digitaldefiance/node-ecies-lib 1.0.0 → 1.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/README.md +266 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/interfaces/index.js +1 -0
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/pbkdf2-result.d.ts +6 -0
- package/dist/interfaces/pbkdf2-result.d.ts.map +1 -0
- package/dist/interfaces/pbkdf2-result.js +2 -0
- package/dist/interfaces/pbkdf2-result.js.map +1 -0
- package/dist/services/ecies/crypto-core.d.ts +26 -0
- package/dist/services/ecies/crypto-core.d.ts.map +1 -1
- package/dist/services/ecies/crypto-core.js +36 -0
- package/dist/services/ecies/crypto-core.js.map +1 -1
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +1 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/pbkdf2.d.ts +68 -0
- package/dist/services/pbkdf2.d.ts.map +1 -0
- package/dist/services/pbkdf2.js +130 -0
- package/dist/services/pbkdf2.js.map +1 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +67 -0
- package/dist/utils.js.map +1 -0
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# @digitaldefiance/node-ecies-lib
|
|
2
|
+
|
|
3
|
+
A Node.js-specific implementation of the Digital Defiance ECIES (Elliptic Curve Integrated Encryption Scheme) library, providing secure encryption, decryption, and key management capabilities using Node.js crypto primitives.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **ECIES Encryption/Decryption**: Secure elliptic curve integrated encryption scheme
|
|
8
|
+
- **Multi-recipient Encryption**: Encrypt data for multiple recipients simultaneously
|
|
9
|
+
- **PBKDF2 Key Derivation**: Password-based key derivation with configurable profiles
|
|
10
|
+
- **Digital Signatures**: Sign and verify data using elliptic curve cryptography
|
|
11
|
+
- **Member Management**: Comprehensive user/member system with key management
|
|
12
|
+
- **Cross-platform Compatibility**: Works seamlessly with the browser-based `@digitaldefiance/ecies-lib`
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @digitaldefiance/node-ecies-lib
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { ECIESService, Member, MemberType, EmailString } from '@digitaldefiance/node-ecies-lib';
|
|
24
|
+
import { getEciesI18nEngine } from '@digitaldefiance/ecies-lib';
|
|
25
|
+
|
|
26
|
+
// Initialize the service
|
|
27
|
+
const eciesService = new ECIESService(getEciesI18nEngine());
|
|
28
|
+
|
|
29
|
+
// Create a new member
|
|
30
|
+
const { member, mnemonic } = Member.newMember(
|
|
31
|
+
eciesService,
|
|
32
|
+
MemberType.User,
|
|
33
|
+
'Alice',
|
|
34
|
+
new EmailString('alice@example.com')
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Encrypt data
|
|
38
|
+
const message = 'Hello, secure world!';
|
|
39
|
+
const encrypted = member.encryptData(message);
|
|
40
|
+
|
|
41
|
+
// Decrypt data
|
|
42
|
+
const decrypted = member.decryptData(encrypted);
|
|
43
|
+
console.log(decrypted.toString()); // "Hello, secure world!"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Core Components
|
|
47
|
+
|
|
48
|
+
### ECIESService
|
|
49
|
+
|
|
50
|
+
The main service class providing encryption, decryption, and key management:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { ECIESService } from '@digitaldefiance/node-ecies-lib';
|
|
54
|
+
import { getEciesI18nEngine } from '@digitaldefiance/ecies-lib';
|
|
55
|
+
|
|
56
|
+
const service = new ECIESService(getEciesI18nEngine());
|
|
57
|
+
|
|
58
|
+
// Generate mnemonic
|
|
59
|
+
const mnemonic = service.generateNewMnemonic();
|
|
60
|
+
|
|
61
|
+
// Single recipient encryption
|
|
62
|
+
const encrypted = service.encryptSimpleOrSingle(
|
|
63
|
+
false, // use single mode (not simple)
|
|
64
|
+
recipientPublicKey,
|
|
65
|
+
Buffer.from('message')
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
// Multi-recipient encryption
|
|
69
|
+
const multiEncrypted = service.encryptMultiple(
|
|
70
|
+
[member1, member2, member3],
|
|
71
|
+
Buffer.from('message')
|
|
72
|
+
);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Member Class
|
|
76
|
+
|
|
77
|
+
Represents a user with cryptographic capabilities:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { Member, MemberType, EmailString } from '@digitaldefiance/node-ecies-lib';
|
|
81
|
+
|
|
82
|
+
// Create from mnemonic
|
|
83
|
+
const member = Member.fromMnemonic(mnemonic, eciesService);
|
|
84
|
+
|
|
85
|
+
// Sign data
|
|
86
|
+
const signature = member.sign(Buffer.from('data to sign'));
|
|
87
|
+
|
|
88
|
+
// Verify signature
|
|
89
|
+
const isValid = member.verify(signature, Buffer.from('data to sign'));
|
|
90
|
+
|
|
91
|
+
// Encrypt for another member
|
|
92
|
+
const encrypted = member.encryptData('secret message', otherMember.publicKey);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### PBKDF2 Service
|
|
96
|
+
|
|
97
|
+
Password-based key derivation with multiple security profiles:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { Pbkdf2Service, Pbkdf2ProfileEnum } from '@digitaldefiance/node-ecies-lib';
|
|
101
|
+
|
|
102
|
+
// Use predefined profile
|
|
103
|
+
const result = Pbkdf2Service.deriveKeyFromPasswordWithProfile(
|
|
104
|
+
Buffer.from('password'),
|
|
105
|
+
Pbkdf2ProfileEnum.USER_LOGIN
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// Custom parameters
|
|
109
|
+
const customResult = Pbkdf2Service.deriveKeyFromPassword(
|
|
110
|
+
Buffer.from('password'),
|
|
111
|
+
salt,
|
|
112
|
+
100000, // iterations
|
|
113
|
+
32, // salt bytes
|
|
114
|
+
32, // key bytes
|
|
115
|
+
'sha256' // algorithm
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// Async version
|
|
119
|
+
const asyncResult = await Pbkdf2Service.deriveKeyFromPasswordAsync(
|
|
120
|
+
Buffer.from('password')
|
|
121
|
+
);
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## PBKDF2 Profiles
|
|
125
|
+
|
|
126
|
+
The library includes several predefined PBKDF2 profiles for different use cases:
|
|
127
|
+
|
|
128
|
+
| Profile | Salt Size | Iterations | Algorithm | Hash Size | Use Case |
|
|
129
|
+
|---------|-----------|------------|-----------|-----------|----------|
|
|
130
|
+
| `USER_LOGIN` | 32 bytes | 1,304,000 | SHA-256 | 32 bytes | User authentication |
|
|
131
|
+
| `KEY_WRAPPING` | 32 bytes | 100,000 | SHA-256 | 32 bytes | Key encryption |
|
|
132
|
+
| `BACKUP_CODES` | 32 bytes | 1,304,000 | SHA-256 | 32 bytes | Backup codes |
|
|
133
|
+
| `HIGH_SECURITY` | 64 bytes | 2,000,000 | SHA-512 | 64 bytes | Sensitive operations |
|
|
134
|
+
| `FAST_TEST` | 16 bytes | 1,000 | SHA-256 | 32 bytes | Testing/development |
|
|
135
|
+
|
|
136
|
+
## Encryption Types
|
|
137
|
+
|
|
138
|
+
The library supports multiple encryption modes:
|
|
139
|
+
|
|
140
|
+
- **Simple**: Basic ECIES encryption for single recipients
|
|
141
|
+
- **Single**: Enhanced ECIES with additional metadata
|
|
142
|
+
- **Multiple**: Efficient encryption for multiple recipients
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
// Single recipient
|
|
146
|
+
const singleEncrypted = service.encryptSimpleOrSingle(
|
|
147
|
+
false, // single mode
|
|
148
|
+
recipientPublicKey,
|
|
149
|
+
message
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
// Multiple recipients
|
|
153
|
+
const multiEncrypted = service.encryptMultiple(
|
|
154
|
+
[member1, member2, member3],
|
|
155
|
+
message
|
|
156
|
+
);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Cross-Platform Compatibility
|
|
160
|
+
|
|
161
|
+
This Node.js library is designed to work seamlessly with the browser-based `@digitaldefiance/ecies-lib`:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
// Data encrypted in browser can be decrypted in Node.js
|
|
165
|
+
const browserEncrypted = /* data from browser */;
|
|
166
|
+
const nodeDecrypted = nodeMember.decryptData(browserEncrypted);
|
|
167
|
+
|
|
168
|
+
// Data encrypted in Node.js can be decrypted in browser
|
|
169
|
+
const nodeEncrypted = nodeMember.encryptData('message');
|
|
170
|
+
// Send nodeEncrypted to browser for decryption
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Security Features
|
|
174
|
+
|
|
175
|
+
- **Secure Memory Management**: Uses `SecureBuffer` and `SecureString` for sensitive data
|
|
176
|
+
- **Key Zeroization**: Automatic cleanup of cryptographic material
|
|
177
|
+
- **Configurable Security Levels**: Multiple PBKDF2 profiles for different security requirements
|
|
178
|
+
- **Input Validation**: Comprehensive validation of all cryptographic inputs
|
|
179
|
+
- **Error Handling**: Detailed error types for debugging and security analysis
|
|
180
|
+
|
|
181
|
+
## API Reference
|
|
182
|
+
|
|
183
|
+
### Constants
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
import { Constants, PBKDF2, PBKDF2_PROFILES } from '@digitaldefiance/node-ecies-lib';
|
|
187
|
+
|
|
188
|
+
// Access configuration constants
|
|
189
|
+
const saltSize = Constants.PBKDF2.SALT_BYTES; // 32
|
|
190
|
+
const iterations = Constants.PBKDF2.ITERATIONS_PER_SECOND; // 1,304,000
|
|
191
|
+
const keyWrappingProfile = Constants.PBKDF2_PROFILES.KEY_WRAPPING;
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Interfaces
|
|
195
|
+
|
|
196
|
+
Key interfaces for type safety:
|
|
197
|
+
|
|
198
|
+
- `IPbkdf2Result`: Result of key derivation operations
|
|
199
|
+
- `IMultiEncryptedMessage`: Multi-recipient encrypted data structure
|
|
200
|
+
- `IMemberOperational`: Member interface with operational methods
|
|
201
|
+
- `IWalletSeed`: Wallet and seed information
|
|
202
|
+
|
|
203
|
+
## Testing
|
|
204
|
+
|
|
205
|
+
The library includes comprehensive test coverage:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# Run all tests
|
|
209
|
+
npm test
|
|
210
|
+
|
|
211
|
+
# Run specific test suites
|
|
212
|
+
npm test -- pbkdf2.spec.ts
|
|
213
|
+
npm test -- ecies-compatibility.e2e.spec.ts
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Test categories:
|
|
217
|
+
- Unit tests for individual components
|
|
218
|
+
- Integration tests for cross-component functionality
|
|
219
|
+
- End-to-end tests for complete workflows
|
|
220
|
+
- Cross-platform compatibility tests
|
|
221
|
+
|
|
222
|
+
## Error Handling
|
|
223
|
+
|
|
224
|
+
The library provides detailed error types for different failure scenarios:
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
import { Pbkdf2Error, Pbkdf2ErrorType, MemberError, MemberErrorType } from '@digitaldefiance/node-ecies-lib';
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
const result = Pbkdf2Service.deriveKeyFromPassword(password, invalidSalt);
|
|
231
|
+
} catch (error) {
|
|
232
|
+
if (error instanceof Pbkdf2Error) {
|
|
233
|
+
if (error.type === Pbkdf2ErrorType.InvalidSaltLength) {
|
|
234
|
+
console.log('Salt length is invalid');
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Performance Considerations
|
|
241
|
+
|
|
242
|
+
- **Async Operations**: Use async versions of PBKDF2 operations to avoid blocking the event loop
|
|
243
|
+
- **Memory Management**: Dispose of members and secure buffers when no longer needed
|
|
244
|
+
- **Profile Selection**: Choose appropriate PBKDF2 profiles based on security vs. performance requirements
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
// Use async for better performance
|
|
248
|
+
const result = await Pbkdf2Service.deriveKeyFromPasswordAsync(password);
|
|
249
|
+
|
|
250
|
+
// Dispose of resources
|
|
251
|
+
member.dispose();
|
|
252
|
+
secureString.dispose();
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## License
|
|
256
|
+
|
|
257
|
+
MIT
|
|
258
|
+
|
|
259
|
+
## Contributing
|
|
260
|
+
|
|
261
|
+
Please read the contributing guidelines in the main repository.
|
|
262
|
+
|
|
263
|
+
## Related Packages
|
|
264
|
+
|
|
265
|
+
- `@digitaldefiance/ecies-lib`: Browser-compatible ECIES library
|
|
266
|
+
- `@digitaldefiance/i18n-lib`: Internationalization support
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
|
@@ -7,6 +7,7 @@ export * from './keypair-buffer-with-un-encrypted-private-key';
|
|
|
7
7
|
export * from './keyring-consts';
|
|
8
8
|
export * from './member-operational';
|
|
9
9
|
export * from './pbkdf-profiles';
|
|
10
|
+
export * from './pbkdf2-result';
|
|
10
11
|
export * from './signing-key-private-key-info';
|
|
11
12
|
export * from './simple-keypair';
|
|
12
13
|
export * from './simple-keypair-buffer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,gDAAgD,CAAC;AAC/D,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,gDAAgD,CAAC;AAC/D,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
|
package/dist/interfaces/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from './keypair-buffer-with-un-encrypted-private-key';
|
|
|
7
7
|
export * from './keyring-consts';
|
|
8
8
|
export * from './member-operational';
|
|
9
9
|
export * from './pbkdf-profiles';
|
|
10
|
+
export * from './pbkdf2-result';
|
|
10
11
|
export * from './signing-key-private-key-info';
|
|
11
12
|
export * from './simple-keypair';
|
|
12
13
|
export * from './simple-keypair-buffer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,gDAAgD,CAAC;AAC/D,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,gDAAgD,CAAC;AAC/D,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbkdf2-result.d.ts","sourceRoot":"","sources":["../../src/interfaces/pbkdf2-result.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbkdf2-result.js","sourceRoot":"","sources":["../../src/interfaces/pbkdf2-result.ts"],"names":[],"mappings":""}
|
|
@@ -51,5 +51,31 @@ export declare class EciesCryptoCore {
|
|
|
51
51
|
* @returns {ISimpleKeyPairBuffer} The new key pair
|
|
52
52
|
*/
|
|
53
53
|
mnemonicToSimpleKeyPairBuffer(mnemonic: SecureString): ISimpleKeyPairBuffer;
|
|
54
|
+
/**
|
|
55
|
+
* Generate a random private key
|
|
56
|
+
* @returns {Buffer} The new private key
|
|
57
|
+
*/
|
|
58
|
+
generatePrivateKey(): Buffer;
|
|
59
|
+
/**
|
|
60
|
+
* Get public key from private key
|
|
61
|
+
* @param privateKey {Buffer} The private key
|
|
62
|
+
* @returns {Buffer} The public key
|
|
63
|
+
*/
|
|
64
|
+
getPublicKey(privateKey: Buffer): Buffer;
|
|
65
|
+
/**
|
|
66
|
+
* Generate ephemeral key pair for ECIES
|
|
67
|
+
* @returns {Promise<ISimpleKeyPairBuffer>} The key pair
|
|
68
|
+
*/
|
|
69
|
+
generateEphemeralKeyPair(): Promise<{
|
|
70
|
+
privateKey: Buffer;
|
|
71
|
+
publicKey: Buffer;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Compute ECDH shared secret
|
|
75
|
+
* @param privateKey {Buffer} The private key
|
|
76
|
+
* @param publicKey {Buffer} The public key
|
|
77
|
+
* @returns {Buffer} The shared secret
|
|
78
|
+
*/
|
|
79
|
+
computeSharedSecret(privateKey: Buffer, publicKey: Buffer): Buffer;
|
|
54
80
|
}
|
|
55
81
|
//# sourceMappingURL=crypto-core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-core.d.ts","sourceRoot":"","sources":["../../../src/services/ecies/crypto-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,YAAY,EAEZ,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAS,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"crypto-core.d.ts","sourceRoot":"","sources":["../../../src/services/ecies/crypto-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,YAAY,EAEZ,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAS,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,IAAW,MAAM,IAAI,YAAY,CAEhC;gBAEW,MAAM,EAAE,YAAY;IAIhC;;;;OAIG;IACI,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IA6CpD;;;OAGG;IACI,mBAAmB,IAAI,YAAY;IAI1C;;;;OAIG;IACI,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAO3C;;;;OAIG;IACI,yBAAyB,CAAC,QAAQ,EAAE,YAAY,GAAG,WAAW;IAiBrE;;;;OAIG;IACI,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB;IAYxE;;;;OAIG;IACI,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB;IAKpE;;;;OAIG;IACI,6BAA6B,CAClC,QAAQ,EAAE,YAAY,GACrB,oBAAoB;IAKvB;;;OAGG;IACI,kBAAkB,IAAI,MAAM;IAInC;;;;OAIG;IACI,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAK/C;;;OAGG;IACU,wBAAwB,IAAI,OAAO,CAAC;QAC/C,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAMF;;;;;OAKG;IACI,mBAAmB,CACxB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,MAAM;CAIV"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ECIES, ECIESError, ECIESErrorTypeEnum, getEciesI18nEngine, SecureBuffer, SecureString, } from '@digitaldefiance/ecies-lib';
|
|
2
2
|
import { hdkey } from '@ethereumjs/wallet';
|
|
3
3
|
import { generateMnemonic, mnemonicToSeedSync, validateMnemonic } from 'bip39';
|
|
4
|
+
import { secp256k1 } from 'ethereum-cryptography/secp256k1.js';
|
|
4
5
|
/**
|
|
5
6
|
* Core encryption and decryption functions for ECIES
|
|
6
7
|
* Includes coverage for simple and single modes, does not cover multiple mode which is in a separate module
|
|
@@ -111,5 +112,40 @@ export class EciesCryptoCore {
|
|
|
111
112
|
const { seed } = this.walletAndSeedFromMnemonic(mnemonic);
|
|
112
113
|
return this.seedToSimpleKeyPairBuffer(Buffer.from(seed.value));
|
|
113
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Generate a random private key
|
|
117
|
+
* @returns {Buffer} The new private key
|
|
118
|
+
*/
|
|
119
|
+
generatePrivateKey() {
|
|
120
|
+
return Buffer.from(secp256k1.utils.randomPrivateKey());
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get public key from private key
|
|
124
|
+
* @param privateKey {Buffer} The private key
|
|
125
|
+
* @returns {Buffer} The public key
|
|
126
|
+
*/
|
|
127
|
+
getPublicKey(privateKey) {
|
|
128
|
+
const publicKey = secp256k1.getPublicKey(privateKey, false);
|
|
129
|
+
return Buffer.from(publicKey);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Generate ephemeral key pair for ECIES
|
|
133
|
+
* @returns {Promise<ISimpleKeyPairBuffer>} The key pair
|
|
134
|
+
*/
|
|
135
|
+
async generateEphemeralKeyPair() {
|
|
136
|
+
const privateKey = this.generatePrivateKey();
|
|
137
|
+
const publicKey = this.getPublicKey(privateKey);
|
|
138
|
+
return { privateKey, publicKey };
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Compute ECDH shared secret
|
|
142
|
+
* @param privateKey {Buffer} The private key
|
|
143
|
+
* @param publicKey {Buffer} The public key
|
|
144
|
+
* @returns {Buffer} The shared secret
|
|
145
|
+
*/
|
|
146
|
+
computeSharedSecret(privateKey, publicKey) {
|
|
147
|
+
const sharedSecret = secp256k1.getSharedSecret(privateKey, publicKey, true);
|
|
148
|
+
return Buffer.from(sharedSecret.slice(1)); // Remove the 0x02/0x03 prefix
|
|
149
|
+
}
|
|
114
150
|
}
|
|
115
151
|
//# sourceMappingURL=crypto-core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-core.js","sourceRoot":"","sources":["../../../src/services/ecies/crypto-core.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAElB,YAAY,EACZ,YAAY,GACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,KAAK,EAAU,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAI/
|
|
1
|
+
{"version":3,"file":"crypto-core.js","sourceRoot":"","sources":["../../../src/services/ecies/crypto-core.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAElB,YAAY,EACZ,YAAY,GACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,KAAK,EAAU,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAI/D;;;GAGG;AACH,MAAM,OAAO,eAAe;IACT,OAAO,CAAe;IACvC,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,YAAY,MAAoB;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACI,kBAAkB,CAAC,SAAiB;QACzC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,UAAU,CAClB,kBAAkB,CAAC,yBAAyB,EAC5C,kBAAkB,EAAE,EACpB,SAAS,EACT,SAAS,EACT;gBACE,KAAK,EAAE,uCAAuC;aAC/C,CACF,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC;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yBAAyB,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACI,kBAAkB;QACvB,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAC;IACzD,CAAC;IAED;;;;OAIG;IACI,YAAY,CAAC,UAAkB;QACpC,MAAM,SAAS,GAAG,SAAS,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC5D,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,wBAAwB;QAInC,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC7C,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAChD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACI,mBAAmB,CACxB,UAAkB,EAClB,SAAiB;QAEjB,MAAM,YAAY,GAAG,SAAS,CAAC,eAAe,CAAC,UAAU,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;QAC5E,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,8BAA8B;IAC3E,CAAC;CACF"}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
package/dist/services/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { IPbkdf2Config } from '@digitaldefiance/ecies-lib';
|
|
2
|
+
import { Pbkdf2ProfileEnum } from '../enumerations/pbkdf2-profile';
|
|
3
|
+
import { IPbkdf2Result } from '../interfaces/pbkdf2-result';
|
|
4
|
+
/**
|
|
5
|
+
* Service for handling PBKDF2 (Password-Based Key Derivation Function 2) operations.
|
|
6
|
+
* This service provides functionality for:
|
|
7
|
+
* - Generating secure key derivation configurations
|
|
8
|
+
* - Deriving cryptographic keys from passwords
|
|
9
|
+
* - Managing salt and iteration parameters
|
|
10
|
+
* - Both synchronous and asynchronous key derivation
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class Pbkdf2Service {
|
|
13
|
+
/**
|
|
14
|
+
* Get a predefined configuration profile for common use cases
|
|
15
|
+
* @param profile The name of the profile to use
|
|
16
|
+
* @returns Configuration object for the specified profile
|
|
17
|
+
*/
|
|
18
|
+
static getProfileConfig(profile: Pbkdf2ProfileEnum): IPbkdf2Config;
|
|
19
|
+
/**
|
|
20
|
+
* Generate an options object for pbkdf2
|
|
21
|
+
* @param iterations Optional number of iterations (defaults to Pbkdf2IterationsPerSecond)
|
|
22
|
+
* @param saltBytes Optional salt size in bytes (defaults to PBKDF2.SALT_BYTES)
|
|
23
|
+
* @param hashBytes Optional hash size in bytes (defaults to ECIES.SYMMETRIC.KEY_SIZE)
|
|
24
|
+
* @param algorithm Optional hash algorithm (defaults to PBKDF2.ALGORITHM)
|
|
25
|
+
* @returns Configuration object for PBKDF2
|
|
26
|
+
*/
|
|
27
|
+
static getConfig(iterations?: number, saltBytes?: number, hashBytes?: number, algorithm?: string): IPbkdf2Config;
|
|
28
|
+
/**
|
|
29
|
+
* Given a password, use pbkdf2 to generate an appropriately sized key for AES encryption
|
|
30
|
+
* @param password The password to derive a key from
|
|
31
|
+
* @param salt Optional salt (will be randomly generated if not provided)
|
|
32
|
+
* @param iterations Optional number of iterations
|
|
33
|
+
* @param saltBytes Optional salt size in bytes
|
|
34
|
+
* @param keySize Optional key size in bytes
|
|
35
|
+
* @param algorithm Optional hash algorithm
|
|
36
|
+
* @returns Object containing the derived key, salt, and iteration count
|
|
37
|
+
*/
|
|
38
|
+
static deriveKeyFromPassword(password: Buffer, salt?: Buffer, iterations?: number, saltBytes?: number, keySize?: number, algorithm?: string): IPbkdf2Result;
|
|
39
|
+
/**
|
|
40
|
+
* Async version of deriveKeyFromPassword that uses libuv threadpool via crypto.pbkdf2
|
|
41
|
+
* to avoid blocking the event loop during password verification.
|
|
42
|
+
* @param password The password to derive a key from
|
|
43
|
+
* @param salt Optional salt (will be randomly generated if not provided)
|
|
44
|
+
* @param iterations Optional number of iterations
|
|
45
|
+
* @param saltBytes Optional salt size in bytes
|
|
46
|
+
* @param keySize Optional key size in bytes
|
|
47
|
+
* @param algorithm Optional hash algorithm
|
|
48
|
+
* @returns Promise resolving to object containing the derived key, salt, and iteration count
|
|
49
|
+
*/
|
|
50
|
+
static deriveKeyFromPasswordAsync(password: Buffer, salt?: Buffer, iterations?: number, saltBytes?: number, keySize?: number, algorithm?: string): Promise<IPbkdf2Result>;
|
|
51
|
+
/**
|
|
52
|
+
* Derive a key using a predefined configuration profile
|
|
53
|
+
* @param password The password to derive a key from
|
|
54
|
+
* @param profile The configuration profile to use
|
|
55
|
+
* @param salt Optional salt (will be randomly generated if not provided)
|
|
56
|
+
* @returns Object containing the derived key, salt, and iteration count
|
|
57
|
+
*/
|
|
58
|
+
static deriveKeyFromPasswordWithProfile(password: Buffer, profile: Pbkdf2ProfileEnum, salt?: Buffer): IPbkdf2Result;
|
|
59
|
+
/**
|
|
60
|
+
* Async version of deriveKeyFromPasswordWithProfile
|
|
61
|
+
* @param password The password to derive a key from
|
|
62
|
+
* @param profile The configuration profile to use
|
|
63
|
+
* @param salt Optional salt (will be randomly generated if not provided)
|
|
64
|
+
* @returns Promise resolving to object containing the derived key, salt, and iteration count
|
|
65
|
+
*/
|
|
66
|
+
static deriveKeyFromPasswordWithProfileAsync(password: Buffer, profile: Pbkdf2ProfileEnum, salt?: Buffer): Promise<IPbkdf2Result>;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=pbkdf2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbkdf2.d.ts","sourceRoot":"","sources":["../../src/services/pbkdf2.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAId,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D;;;;;;;GAOG;AACH,8BAAsB,aAAa;IACjC;;;;OAIG;WACW,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,aAAa;IAUzE;;;;;;;OAOG;WACW,SAAS,CACrB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,aAAa;IAkBhB;;;;;;;;;OASG;WACW,qBAAqB,CACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,MAAM,EACb,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,GACjB,aAAa;IAgChB;;;;;;;;;;OAUG;WACiB,0BAA0B,CAC5C,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,MAAM,EACb,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,CAAC;IAiCzB;;;;;;OAMG;WACW,gCAAgC,CAC5C,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,iBAAiB,EAC1B,IAAI,CAAC,EAAE,MAAM,GACZ,aAAa;IAYhB;;;;;;OAMG;WACiB,qCAAqC,CACvD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,iBAAiB,EAC1B,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,aAAa,CAAC;CAW1B"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ECIES, Pbkdf2Error, Pbkdf2ErrorType, getEciesI18nEngine, } from '@digitaldefiance/ecies-lib';
|
|
2
|
+
import { pbkdf2 as pbkdf2Async, pbkdf2Sync, randomBytes } from 'crypto';
|
|
3
|
+
import { promisify } from 'util';
|
|
4
|
+
import { PBKDF2, PBKDF2_PROFILES } from '../constants';
|
|
5
|
+
/**
|
|
6
|
+
* Service for handling PBKDF2 (Password-Based Key Derivation Function 2) operations.
|
|
7
|
+
* This service provides functionality for:
|
|
8
|
+
* - Generating secure key derivation configurations
|
|
9
|
+
* - Deriving cryptographic keys from passwords
|
|
10
|
+
* - Managing salt and iteration parameters
|
|
11
|
+
* - Both synchronous and asynchronous key derivation
|
|
12
|
+
*/
|
|
13
|
+
export class Pbkdf2Service {
|
|
14
|
+
/**
|
|
15
|
+
* Get a predefined configuration profile for common use cases
|
|
16
|
+
* @param profile The name of the profile to use
|
|
17
|
+
* @returns Configuration object for the specified profile
|
|
18
|
+
*/
|
|
19
|
+
static getProfileConfig(profile) {
|
|
20
|
+
const profileConfig = PBKDF2_PROFILES[profile];
|
|
21
|
+
return {
|
|
22
|
+
hashBytes: profileConfig.hashBytes,
|
|
23
|
+
saltBytes: profileConfig.saltBytes,
|
|
24
|
+
iterations: profileConfig.iterations,
|
|
25
|
+
algorithm: profileConfig.algorithm,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Generate an options object for pbkdf2
|
|
30
|
+
* @param iterations Optional number of iterations (defaults to Pbkdf2IterationsPerSecond)
|
|
31
|
+
* @param saltBytes Optional salt size in bytes (defaults to PBKDF2.SALT_BYTES)
|
|
32
|
+
* @param hashBytes Optional hash size in bytes (defaults to ECIES.SYMMETRIC.KEY_SIZE)
|
|
33
|
+
* @param algorithm Optional hash algorithm (defaults to PBKDF2.ALGORITHM)
|
|
34
|
+
* @returns Configuration object for PBKDF2
|
|
35
|
+
*/
|
|
36
|
+
static getConfig(iterations, saltBytes, hashBytes, algorithm) {
|
|
37
|
+
// larger numbers mean better security, less
|
|
38
|
+
return {
|
|
39
|
+
// size of the generated hash
|
|
40
|
+
hashBytes: hashBytes ?? ECIES.SYMMETRIC.KEY_SIZE,
|
|
41
|
+
// larger salt means hashed passwords are more resistant to rainbow table, but
|
|
42
|
+
// you get diminishing returns pretty fast
|
|
43
|
+
saltBytes: saltBytes ?? PBKDF2.SALT_BYTES,
|
|
44
|
+
// more iterations means an attacker has to take longer to brute force an
|
|
45
|
+
// individual password, so larger is better. however, larger also means longer
|
|
46
|
+
// to hash the password. tune so that hashing the password takes about a
|
|
47
|
+
// second
|
|
48
|
+
iterations: iterations ?? PBKDF2.ITERATIONS_PER_SECOND,
|
|
49
|
+
// hash algorithm
|
|
50
|
+
algorithm: algorithm ?? PBKDF2.ALGORITHM,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Given a password, use pbkdf2 to generate an appropriately sized key for AES encryption
|
|
55
|
+
* @param password The password to derive a key from
|
|
56
|
+
* @param salt Optional salt (will be randomly generated if not provided)
|
|
57
|
+
* @param iterations Optional number of iterations
|
|
58
|
+
* @param saltBytes Optional salt size in bytes
|
|
59
|
+
* @param keySize Optional key size in bytes
|
|
60
|
+
* @param algorithm Optional hash algorithm
|
|
61
|
+
* @returns Object containing the derived key, salt, and iteration count
|
|
62
|
+
*/
|
|
63
|
+
static deriveKeyFromPassword(password, salt, iterations, saltBytes, keySize, algorithm) {
|
|
64
|
+
const config = Pbkdf2Service.getConfig(iterations, saltBytes, keySize, algorithm);
|
|
65
|
+
const saltBytes_ = salt ?? randomBytes(config.saltBytes);
|
|
66
|
+
if (saltBytes_.length !== config.saltBytes) {
|
|
67
|
+
throw new Pbkdf2Error(Pbkdf2ErrorType.InvalidSaltLength, getEciesI18nEngine());
|
|
68
|
+
}
|
|
69
|
+
const hashBytes = pbkdf2Sync(password, saltBytes_, config.iterations, config.hashBytes, config.algorithm);
|
|
70
|
+
if (hashBytes.length !== config.hashBytes) {
|
|
71
|
+
throw new Pbkdf2Error(Pbkdf2ErrorType.InvalidHashLength, getEciesI18nEngine());
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
salt: saltBytes_,
|
|
75
|
+
hash: hashBytes,
|
|
76
|
+
iterations: config.iterations,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Async version of deriveKeyFromPassword that uses libuv threadpool via crypto.pbkdf2
|
|
81
|
+
* to avoid blocking the event loop during password verification.
|
|
82
|
+
* @param password The password to derive a key from
|
|
83
|
+
* @param salt Optional salt (will be randomly generated if not provided)
|
|
84
|
+
* @param iterations Optional number of iterations
|
|
85
|
+
* @param saltBytes Optional salt size in bytes
|
|
86
|
+
* @param keySize Optional key size in bytes
|
|
87
|
+
* @param algorithm Optional hash algorithm
|
|
88
|
+
* @returns Promise resolving to object containing the derived key, salt, and iteration count
|
|
89
|
+
*/
|
|
90
|
+
static async deriveKeyFromPasswordAsync(password, salt, iterations, saltBytes, keySize, algorithm) {
|
|
91
|
+
const config = Pbkdf2Service.getConfig(iterations, saltBytes, keySize, algorithm);
|
|
92
|
+
const saltBytes_ = salt ?? randomBytes(config.saltBytes);
|
|
93
|
+
if (saltBytes_.length !== config.saltBytes) {
|
|
94
|
+
throw new Pbkdf2Error(Pbkdf2ErrorType.InvalidSaltLength, getEciesI18nEngine());
|
|
95
|
+
}
|
|
96
|
+
const pbkdf2 = promisify(pbkdf2Async);
|
|
97
|
+
const hashBytes = (await pbkdf2(password, saltBytes_, config.iterations, config.hashBytes, config.algorithm));
|
|
98
|
+
if (hashBytes.length !== config.hashBytes) {
|
|
99
|
+
throw new Pbkdf2Error(Pbkdf2ErrorType.InvalidHashLength, getEciesI18nEngine());
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
salt: saltBytes_,
|
|
103
|
+
hash: hashBytes,
|
|
104
|
+
iterations: config.iterations,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Derive a key using a predefined configuration profile
|
|
109
|
+
* @param password The password to derive a key from
|
|
110
|
+
* @param profile The configuration profile to use
|
|
111
|
+
* @param salt Optional salt (will be randomly generated if not provided)
|
|
112
|
+
* @returns Object containing the derived key, salt, and iteration count
|
|
113
|
+
*/
|
|
114
|
+
static deriveKeyFromPasswordWithProfile(password, profile, salt) {
|
|
115
|
+
const config = Pbkdf2Service.getProfileConfig(profile);
|
|
116
|
+
return Pbkdf2Service.deriveKeyFromPassword(password, salt, config.iterations, config.saltBytes, config.hashBytes, config.algorithm);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Async version of deriveKeyFromPasswordWithProfile
|
|
120
|
+
* @param password The password to derive a key from
|
|
121
|
+
* @param profile The configuration profile to use
|
|
122
|
+
* @param salt Optional salt (will be randomly generated if not provided)
|
|
123
|
+
* @returns Promise resolving to object containing the derived key, salt, and iteration count
|
|
124
|
+
*/
|
|
125
|
+
static async deriveKeyFromPasswordWithProfileAsync(password, profile, salt) {
|
|
126
|
+
const config = Pbkdf2Service.getProfileConfig(profile);
|
|
127
|
+
return Pbkdf2Service.deriveKeyFromPasswordAsync(password, salt, config.iterations, config.saltBytes, config.hashBytes, config.algorithm);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=pbkdf2.js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,CAAC;CACF"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encodes the length of the data in the buffer
|
|
3
|
+
* @param buffer The buffer to encode
|
|
4
|
+
* @returns The encoded buffer
|
|
5
|
+
*/
|
|
6
|
+
export declare function lengthEncodeData(buffer: Buffer): Buffer;
|
|
7
|
+
export declare function decodeLengthEncodedData(buffer: Buffer): {
|
|
8
|
+
data: Buffer;
|
|
9
|
+
totalLength: number;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAuBvD;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,CA0CA"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { EciesStringKey, getEciesI18nEngine, getLengthEncodingTypeForLength, getLengthEncodingTypeFromValue, getLengthForLengthType, LengthEncodingType, TranslatableError, } from '@digitaldefiance/ecies-lib';
|
|
2
|
+
/**
|
|
3
|
+
* Encodes the length of the data in the buffer
|
|
4
|
+
* @param buffer The buffer to encode
|
|
5
|
+
* @returns The encoded buffer
|
|
6
|
+
*/
|
|
7
|
+
export function lengthEncodeData(buffer) {
|
|
8
|
+
const lengthType = getLengthEncodingTypeForLength(buffer.length);
|
|
9
|
+
const lengthTypeSize = getLengthForLengthType(lengthType);
|
|
10
|
+
const result = Buffer.alloc(1 + lengthTypeSize + buffer.length);
|
|
11
|
+
result.writeUInt8(lengthType, 0);
|
|
12
|
+
switch (lengthType) {
|
|
13
|
+
case LengthEncodingType.UInt8:
|
|
14
|
+
result.writeUInt8(buffer.length, 1);
|
|
15
|
+
break;
|
|
16
|
+
case LengthEncodingType.UInt16:
|
|
17
|
+
result.writeUInt16BE(buffer.length, 1);
|
|
18
|
+
break;
|
|
19
|
+
case LengthEncodingType.UInt32:
|
|
20
|
+
result.writeUInt32BE(buffer.length, 1);
|
|
21
|
+
break;
|
|
22
|
+
case LengthEncodingType.UInt64:
|
|
23
|
+
result.writeBigUInt64BE(BigInt(buffer.length), 1);
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
buffer.copy(result, 1 + lengthTypeSize);
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
export function decodeLengthEncodedData(buffer) {
|
|
30
|
+
if (buffer.length < 1) {
|
|
31
|
+
throw new RangeError('Buffer is too short to read length type.');
|
|
32
|
+
}
|
|
33
|
+
const lengthType = getLengthEncodingTypeFromValue(buffer.readUint8(0));
|
|
34
|
+
const lengthTypeSize = getLengthForLengthType(lengthType);
|
|
35
|
+
if (buffer.length < 1 + lengthTypeSize) {
|
|
36
|
+
throw new RangeError('Buffer is too short to read the full length value.');
|
|
37
|
+
}
|
|
38
|
+
let length;
|
|
39
|
+
switch (lengthType) {
|
|
40
|
+
case LengthEncodingType.UInt8:
|
|
41
|
+
length = buffer.readUint8(1);
|
|
42
|
+
break;
|
|
43
|
+
case LengthEncodingType.UInt16:
|
|
44
|
+
length = buffer.readUint16BE(1);
|
|
45
|
+
break;
|
|
46
|
+
case LengthEncodingType.UInt32:
|
|
47
|
+
length = buffer.readUint32BE(1);
|
|
48
|
+
break;
|
|
49
|
+
case LengthEncodingType.UInt64:
|
|
50
|
+
length = buffer.readBigUInt64BE(1);
|
|
51
|
+
if (Number(length) > Number.MAX_SAFE_INTEGER) {
|
|
52
|
+
throw new RangeError('Length exceeds maximum safe integer value');
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
throw new TranslatableError(EciesStringKey.Error_LengthError_LengthIsInvalidType, getEciesI18nEngine());
|
|
57
|
+
}
|
|
58
|
+
const totalLength = 1 + lengthTypeSize + Number(length);
|
|
59
|
+
if (totalLength > buffer.length) {
|
|
60
|
+
throw new RangeError('Buffer is too short for declared data length');
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
data: buffer.subarray(1 + lengthTypeSize, totalLength),
|
|
64
|
+
totalLength,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,8BAA8B,EAC9B,8BAA8B,EAC9B,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AAEpC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,MAAM,UAAU,GAAuB,8BAA8B,CACnE,MAAM,CAAC,MAAM,CACd,CAAC;IACF,MAAM,cAAc,GAAW,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAClE,MAAM,MAAM,GAAW,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACxE,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IACjC,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,kBAAkB,CAAC,KAAK;YAC3B,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACpC,MAAM;QACR,KAAK,kBAAkB,CAAC,MAAM;YAC5B,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACvC,MAAM;QACR,KAAK,kBAAkB,CAAC,MAAM;YAC5B,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,C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,CAAC;gBAC7C,MAAM,IAAI,UAAU,CAAC,2CAA2C,CAAC,CAAC;YACpE,CAAC;YACD,MAAM;QACR;YACE,MAAM,IAAI,iBAAiB,CAAC,cAAc,CAAC,qCAAqC,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAC5G,CAAC;IAED,MAAM,WAAW,GAAG,CAAC,GAAG,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACxD,IAAI,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAChC,MAAM,IAAI,UAAU,CAAC,8CAA8C,CAAC,CAAC;IACvE,CAAC;IACD,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,cAAc,EAAE,WAAW,CAAC;QACtD,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/node-ecies-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Digital Defiance Node ECIES Library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -52,13 +52,14 @@
|
|
|
52
52
|
"type": "module",
|
|
53
53
|
"packageManager": "yarn@4.10.3",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@digitaldefiance/ecies-lib": "^1.0.
|
|
55
|
+
"@digitaldefiance/ecies-lib": "^1.0.20",
|
|
56
56
|
"@digitaldefiance/i18n-lib": "^1.0.33",
|
|
57
57
|
"@ethereumjs/wallet": "^10.0.0",
|
|
58
58
|
"@noble/curves": "^2.0.1",
|
|
59
59
|
"@noble/hashes": "^2.0.1",
|
|
60
60
|
"@scure/bip32": "^2.0.0",
|
|
61
61
|
"bson": "^6.10.4",
|
|
62
|
+
"ethereum-cryptography": "^3.2.0",
|
|
62
63
|
"ts-brand": "^0.2.0"
|
|
63
64
|
}
|
|
64
65
|
}
|