@wavesenterprise/commission-key-tool
Advanced tools
Comparing version 1.0.0-RC10 to 1.0.0-RC11
@@ -11,2 +11,3 @@ #! /usr/bin/env node | ||
const crypto_1 = require("./crypto"); | ||
const fs_1 = require("fs"); | ||
function customParseInt(value) { | ||
@@ -19,2 +20,7 @@ const parsedValue = parseInt(value, 10); | ||
} | ||
const maskKey = (privateKey, lastCharsNum = 5) => { | ||
const lastChars = Buffer.from(privateKey).toString('hex').padStart(64, '0').substr(64 - lastCharsNum); | ||
fs_1.writeFileSync(`./.commission-pk-${lastChars}`, `${Buffer.from(privateKey).toString('hex')}`); | ||
return Array(64 - lastCharsNum).fill('*').join('') + lastChars; | ||
}; | ||
class RutokenWrapper { | ||
@@ -113,2 +119,10 @@ constructor() { | ||
let { n, k } = options; | ||
if (!n && +n > 0) { | ||
console.log(`Некорректное значение n: ${n}`); | ||
process.exit(0); | ||
} | ||
if (!k && +k > 0) { | ||
console.log(`Некорректное значение k: ${k}`); | ||
process.exit(0); | ||
} | ||
try { | ||
@@ -121,6 +135,6 @@ const rutokenWrapper = new RutokenWrapper(); | ||
console.log('publicKey', Buffer.from(publicKey).toString('hex')); | ||
console.log('privateKey', Buffer.from(privateKey).toString('hex')); | ||
console.log('privateKey', maskKey(privateKey)); | ||
console.log(`Разделяем ключ на ${n} частей`); | ||
const shares = crypto.splitPrivateKey(privateKey, k, n); | ||
console.log(shares.map((x) => `${x.idx}. ${Buffer.from(x.val).toString('hex').padStart(64, '0')}`)); | ||
console.log(shares.map((x) => `${x.idx}. ${maskKey(x.val)}`)); | ||
for (const share of shares) { | ||
@@ -133,2 +147,6 @@ const rutoken = await rutokenWrapper.waitInitialization(); | ||
}); | ||
if (!pin) { | ||
console.log('Некорректный пароль'); | ||
process.exit(0); | ||
} | ||
rutoken.connect(pin); | ||
@@ -157,2 +175,6 @@ rutoken.writeShare(share); | ||
}); | ||
if (!sharesCount && +sharesCount > 0) { | ||
console.log(`Некорректное значние sharesCount: ${sharesCount}`); | ||
process.exit(0); | ||
} | ||
const shares = []; | ||
@@ -166,2 +188,6 @@ for (let i = 0; i < sharesCount; i++) { | ||
}); | ||
if (!pin) { | ||
console.log('Некорректный пароль'); | ||
process.exit(0); | ||
} | ||
rutoken.connect(pin); | ||
@@ -168,0 +194,0 @@ const share = rutoken.readShares()[0]; |
{ | ||
"name": "@wavesenterprise/commission-key-tool", | ||
"version": "1.0.0-RC10", | ||
"version": "1.0.0-RC11", | ||
"description": "Library for commission key splitting tool", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -21,3 +21,3 @@ ## Системные требования | ||
- скачать и установить свежую версию Node.js | ||
- скачать и установить версию Node.js v15 | ||
- установить Python 3+ из Microsoft Store | ||
@@ -24,0 +24,0 @@ - установить https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
526
10721922
11
2