Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion groups/coinNetworks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ coininfo = require('coininfo');
module.exports = {
DOGE: coininfo.dogecoin.main.toBitcoinJS(),
DASH: coininfo.dash.main.toBitcoinJS(),
BTC: coininfo.bitcoin.main.toBitcoinJS()
BTC: coininfo.bitcoin.main.toBitcoinJS(),
LSK: {
name: 'Lisk',
port: 8000,
wsPort: 8001,
unit: 'LSK'
},
}
42 changes: 42 additions & 0 deletions groups/lsk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const cryptography = require('@liskhq/lisk-cryptography')
const sodium = require('sodium-browserify-tweetnacl')
const pbkdf2 = require('pbkdf2');

const coinNetworks = require('./coinNetworks');
const {bytesToHex} = require('../helpers/encryptor');

const lsk = {};

const LiskHashSettings = {
SALT: 'adm',
ITERATIONS: 2048,
KEYLEN: 32,
DIGEST: 'sha256'
}

/**
* Generates a LSK account from the passphrase specified.
* @param {string} passphrase ADAMANT account passphrase
* @returns {object} network info, keyPair, address, addressHexBinary, addressHex, privateKey
*/

lsk.keys = passphrase => {
const network = coinNetworks.LSK;
const liskSeed = pbkdf2.pbkdf2Sync(passphrase, LiskHashSettings.SALT, LiskHashSettings.ITERATIONS, LiskHashSettings.KEYLEN, LiskHashSettings.DIGEST);
const keyPair = sodium.crypto_sign_seed_keypair(liskSeed);
const address = cryptography.getBase32AddressFromPublicKey(keyPair.publicKey);
const addressHexBinary = cryptography.getAddressFromPublicKey(keyPair.publicKey);
const addressHex = bytesToHex(addressHexBinary);
const privateKey = keyPair.secretKey.toString('hex');

return {
network,
keyPair,
address,
addressHexBinary,
addressHex,
privateKey
}
};

module.exports = lsk;
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const eth = require('./groups/eth');
const dash = require('./groups/dash');
const btc = require('./groups/btc');
const doge = require('./groups/doge');
const lsk = require('./groups/lsk');
const transactionFormer = require('./helpers/transactionFormer');
const keys = require('./helpers/keys');
const encryptor = require('./helpers/encryptor');
Expand All @@ -34,6 +35,7 @@ module.exports = (params, log) => {
dash,
btc,
doge,
lsk,
transactionFormer,
keys,
encryptor,
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adamant-api",
"version": "1.4.0",
"version": "1.5.0",
"description": "REST API for ADAMANT Blockchain",
"main": "index.js",
"scripts": {
Expand All @@ -14,10 +14,12 @@
"bitcoinjs-lib": "^5.2.0",
"bitcore-mnemonic": "^8.25.25",
"bytebuffer": "^5.0.1",
"coininfo": "^5.1.0",
"coininfo": "^5.1.0",
"ed2curve": "^0.3.0",
"ethereumjs-util": "^7.1.4",
"hdkey": "^2.0.1",
"pbkdf2": "^3.1.2",
"@liskhq/lisk-cryptography": "3.2.0",
"socket.io-client": "^2.4.0",
"sodium-browserify-tweetnacl": "^0.2.6"
},
Expand Down