Skip to content

Commit 04a749a

Browse files
authored
Merge pull request #11 from Adamant-im/feature/add-lisk
Feature/add lisk
2 parents 29f920b + 4066a42 commit 04a749a

File tree

4 files changed

+55
-3
lines changed

4 files changed

+55
-3
lines changed

groups/coinNetworks.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,11 @@ coininfo = require('coininfo');
33
module.exports = {
44
DOGE: coininfo.dogecoin.main.toBitcoinJS(),
55
DASH: coininfo.dash.main.toBitcoinJS(),
6-
BTC: coininfo.bitcoin.main.toBitcoinJS()
6+
BTC: coininfo.bitcoin.main.toBitcoinJS(),
7+
LSK: {
8+
name: 'Lisk',
9+
port: 8000,
10+
wsPort: 8001,
11+
unit: 'LSK'
12+
},
713
}

groups/lsk.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const cryptography = require('@liskhq/lisk-cryptography')
2+
const sodium = require('sodium-browserify-tweetnacl')
3+
const pbkdf2 = require('pbkdf2');
4+
5+
const coinNetworks = require('./coinNetworks');
6+
const {bytesToHex} = require('../helpers/encryptor');
7+
8+
const lsk = {};
9+
10+
const LiskHashSettings = {
11+
SALT: 'adm',
12+
ITERATIONS: 2048,
13+
KEYLEN: 32,
14+
DIGEST: 'sha256'
15+
}
16+
17+
/**
18+
* Generates a LSK account from the passphrase specified.
19+
* @param {string} passphrase ADAMANT account passphrase
20+
* @returns {object} network info, keyPair, address, addressHexBinary, addressHex, privateKey
21+
*/
22+
23+
lsk.keys = passphrase => {
24+
const network = coinNetworks.LSK;
25+
const liskSeed = pbkdf2.pbkdf2Sync(passphrase, LiskHashSettings.SALT, LiskHashSettings.ITERATIONS, LiskHashSettings.KEYLEN, LiskHashSettings.DIGEST);
26+
const keyPair = sodium.crypto_sign_seed_keypair(liskSeed);
27+
const address = cryptography.getBase32AddressFromPublicKey(keyPair.publicKey);
28+
const addressHexBinary = cryptography.getAddressFromPublicKey(keyPair.publicKey);
29+
const addressHex = bytesToHex(addressHexBinary);
30+
const privateKey = keyPair.secretKey.toString('hex');
31+
32+
return {
33+
network,
34+
keyPair,
35+
address,
36+
addressHexBinary,
37+
addressHex,
38+
privateKey
39+
}
40+
};
41+
42+
module.exports = lsk;

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const eth = require('./groups/eth');
1111
const dash = require('./groups/dash');
1212
const btc = require('./groups/btc');
1313
const doge = require('./groups/doge');
14+
const lsk = require('./groups/lsk');
1415
const transactionFormer = require('./helpers/transactionFormer');
1516
const keys = require('./helpers/keys');
1617
const encryptor = require('./helpers/encryptor');
@@ -34,6 +35,7 @@ module.exports = (params, log) => {
3435
dash,
3536
btc,
3637
doge,
38+
lsk,
3739
transactionFormer,
3840
keys,
3941
encryptor,

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "adamant-api",
3-
"version": "1.4.0",
3+
"version": "1.5.0",
44
"description": "REST API for ADAMANT Blockchain",
55
"main": "index.js",
66
"scripts": {
@@ -14,10 +14,12 @@
1414
"bitcoinjs-lib": "^5.2.0",
1515
"bitcore-mnemonic": "^8.25.25",
1616
"bytebuffer": "^5.0.1",
17-
"coininfo": "^5.1.0",
17+
"coininfo": "^5.1.0",
1818
"ed2curve": "^0.3.0",
1919
"ethereumjs-util": "^7.1.4",
2020
"hdkey": "^2.0.1",
21+
"pbkdf2": "^3.1.2",
22+
"@liskhq/lisk-cryptography": "3.2.0",
2123
"socket.io-client": "^2.4.0",
2224
"sodium-browserify-tweetnacl": "^0.2.6"
2325
},

0 commit comments

Comments
 (0)