Compare commits
No commits in common. "de7bd68872ec727bc3ff9c47108e7c146dfa5ce8" and "db36cb33cf78d7ddbab389af6fd0a330428c63ea" have entirely different histories.
de7bd68872
...
db36cb33cf
@ -18,9 +18,9 @@ module.exports.builder = (yargs) => {
|
|||||||
|
|
||||||
module.exports.handler = (argv) => {
|
module.exports.handler = (argv) => {
|
||||||
console.log("Add lock which we will use our keys on.");
|
console.log("Add lock which we will use our keys on.");
|
||||||
|
console.log("Lock Definition: ", argv["lock-definition"]);
|
||||||
|
|
||||||
const lockDefintion = argv["lock-definition"].js || argv["lock-definition"];
|
const lockDefintion = argv["lock-definition"] || argv["lock-definition"].js;
|
||||||
|
|
||||||
const challenge = JSON.parse(lockDefintion);
|
const challenge = JSON.parse(lockDefintion);
|
||||||
const registerationMessage = JSON.parse(challenge.message);
|
const registerationMessage = JSON.parse(challenge.message);
|
||||||
|
|
||||||
|
@ -1,28 +1,26 @@
|
|||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const algorithm = 'aes-256-ecb';
|
const algorithm = 'aes-256-ctr';
|
||||||
const bip32 = require('bip32');
|
const bip32 = require('bip32');
|
||||||
|
|
||||||
// NOTE I'm not a cryptographer... so don't be reusing any code from below as I don't have no idea what I'm doing
|
|
||||||
|
|
||||||
const iv = null; // If I knew what I was doing I would have a value assigned here...
|
|
||||||
|
|
||||||
module.exports.encrypt = (plainText, password) => {
|
module.exports.encrypt = (plainText, password) => {
|
||||||
const key = crypto.createHash('sha256').update(password, 'utf8').digest();
|
// TODO encrypt text
|
||||||
const cipher = crypto.createCipheriv(algorithm, key, iv);
|
// const cipher = crypto.createCipheriv(algorithm, password);
|
||||||
|
|
||||||
var cipherText = cipher.update(plainText, 'utf8', 'hex');
|
// var cipherText = cipher.update(plainText, 'utf8', 'hex');
|
||||||
cipherText += cipher.final('hex');
|
// cipher += cipher.final('hex');
|
||||||
return cipherText;
|
|
||||||
|
// console.log("CipherText: ", cipherText);
|
||||||
|
return plainText;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.decrypt = (cipherText, password) => {
|
module.exports.decrypt = (cipherText, password) => {
|
||||||
const key = crypto.createHash('sha256').update(password, 'utf8').digest();
|
// TODO decrypt cipherText
|
||||||
const decipher = crypto.createDecipheriv(algorithm, key, iv);
|
// const decipher = crypto.createDecipheriv(algorithm, password)
|
||||||
|
|
||||||
var plainText = decipher.update(cipherText, 'hex', 'utf8');
|
// var plainText = decipher.update(cipherText, 'hex', 'utf8');
|
||||||
plainText += decipher.final('utf8');
|
// plainText += decipher.final('utf8');
|
||||||
|
|
||||||
return plainText;
|
return cipherText;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.randomDerivationPath = function(hardenedDerivation) {
|
module.exports.randomDerivationPath = function(hardenedDerivation) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user