-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwallet.js
More file actions
38 lines (30 loc) · 733 Bytes
/
Copy pathwallet.js
File metadata and controls
38 lines (30 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict'
/*
THIS IS GOING TO BE HERE FOR NOW
*/
// imports
import crypto from 'crypto';
const createWallet = () => {
// generates a pair of keys, returns them as buffers
const pair = crypto.generateKeyPairSync('ec', {
namedCurve: 'secp256k1', // Options
publicKeyEncoding: {
type: 'spki',
format: 'der'
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'der'
}
});
// keys to hex for easy access
const publicKey = pair.publicKey.toString('hex');
const privateKey = pair.privateKey.toString('hex');
return {
publicKey,
privateKey,
pair
}
}
// exports
export {createWallet};