Skip to content

Commit

Permalink
Fixes for ALGO, AION, NEM. Auto-increment account index in path corre…
Browse files Browse the repository at this point in the history
…ctly
  • Loading branch information
PavlosTze committed Mar 23, 2020
1 parent 58367eb commit 66f0847
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 40 deletions.
30 changes: 10 additions & 20 deletions bip39-standalone.html
Original file line number Diff line number Diff line change
Expand Up @@ -190825,16 +190825,12 @@ <h2>This project is 100% open-source code</h2>
var HDNode = require("./util/hdnode");
var nem = require("nem-sdk").default;

var counter = 0;

window.nemUtil = {
account: function account(mnemonic, passphrase) {
account: function account(mnemonic, passphrase,accountIndex) {
var seed = bip39.mnemonicToSeed(mnemonic, passphrase);
var root = HDNode.fromSeedBuffer(seed);

var accountNumberInPath = counter.toString();
counter++;
var nemCustomPath = "m/44'/43'/" + accountNumberInPath + "'/0'/0'";

var nemCustomPath = "m/44'/43'/" + accountIndex.toString() + "'/0'/0'";
var node = root.derivePath(nemCustomPath); /* Check this hard coded path */

var secretKey = nem.utils.convert.hex2ua_reversed(node.getPrivateKeyHex());
Expand Down Expand Up @@ -337969,7 +337965,6 @@ <h2>This project is 100% open-source code</h2>
var replaceDerive = function replaceDerive(val) {
return val.replace("'", '');
};
var counter = 0;

var getMasterKeyFromSeed = function getMasterKeyFromSeed(seed) {
var hmac = createHmac('sha512', ED25519_CURVE);
Expand Down Expand Up @@ -338032,13 +338027,11 @@ <h2>This project is 100% open-source code</h2>
}

window.algorandUtil = {
account: function account(mnemonic, passphrase) {
account: function account(mnemonic, passphrase, accountIndex) {

var seed = bip39.mnemonicToSeed(mnemonic, passphrase);

var accountNumberInPath = counter.toString();
counter++;
var algoPath = "m/44'/283'/" + accountNumberInPath + "'/0'/0'";
var algoPath = "m/44'/283'/" + accountIndex.toString() + "'/0'/0'";

var childKeys = derivePath(algoPath, seed);

Expand Down Expand Up @@ -379186,7 +379179,6 @@ <h2>This project is 100% open-source code</h2>
var replaceDerive = function replaceDerive(val) {
return val.replace("'", '');
};
var counter = 0;

var getMasterKeyFromSeed = function getMasterKeyFromSeed(seed) {
var hmac = createHmac('sha512', ED25519_CURVE);
Expand Down Expand Up @@ -379248,13 +379240,11 @@ <h2>This project is 100% open-source code</h2>
}

window.aionUtil = {
account: function account(mnemonic, passphrase) {
account: function account(mnemonic, passphrase, accountIndex) {

var seed = bip39.mnemonicToSeed(mnemonic, passphrase);

var accountNumberInPath = counter.toString();
counter++;
var algoPath = "m/44'/425'/" + accountNumberInPath + "'/0'/0'";
var algoPath = "m/44'/425'/" + accountIndex.toString() + "'/0'/0'";

var childKeys = derivePath(algoPath, seed);

Expand Down Expand Up @@ -386472,7 +386462,7 @@ <h2>This project is 100% open-source code</h2>
var phrase = DOM.phrase.val();
var passphrase = DOM.passphrase.val();

var nemAccount = nemUtil.account(phrase,passphrase);
var nemAccount = nemUtil.account(phrase,passphrase,index);

privkey = nemAccount.privKey;
pubkey = nemAccount.publicKey;
Expand All @@ -386483,7 +386473,7 @@ <h2>This project is 100% open-source code</h2>
var phrase = DOM.phrase.val();
var passphrase = DOM.passphrase.val();

var algoAccount = algorandUtil.account(phrase,passphrase);
var algoAccount = algorandUtil.account(phrase,passphrase, index);

privkey = algoAccount.privKey;
pubkey = algoAccount.publicKey;
Expand All @@ -386494,7 +386484,7 @@ <h2>This project is 100% open-source code</h2>
var phrase = DOM.phrase.val();
var passphrase = DOM.passphrase.val();

var aionAccount = aionUtil.account(phrase,passphrase);
var aionAccount = aionUtil.account(phrase,passphrase, index);

privkey = aionAccount.privKey;
pubkey = aionAccount.publicKey;
Expand Down
7 changes: 2 additions & 5 deletions src/js/aionjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -41120,7 +41120,6 @@ naclFactory.instantiate(function (nacl) {
var replaceDerive = function replaceDerive(val) {
return val.replace("'", '');
};
var counter = 0;

var getMasterKeyFromSeed = function getMasterKeyFromSeed(seed) {
var hmac = createHmac('sha512', ED25519_CURVE);
Expand Down Expand Up @@ -41182,13 +41181,11 @@ function fixAddressPrefix(address){
}

window.aionUtil = {
account: function account(mnemonic, passphrase) {
account: function account(mnemonic, passphrase, accountIndex) {

var seed = bip39.mnemonicToSeed(mnemonic, passphrase);

var accountNumberInPath = counter.toString();
counter++;
var algoPath = "m/44'/425'/" + accountNumberInPath + "'/0'/0'";
var algoPath = "m/44'/425'/" + accountIndex.toString() + "'/0'/0'";

var childKeys = derivePath(algoPath, seed);

Expand Down
7 changes: 2 additions & 5 deletions src/js/algorandjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -41939,7 +41939,6 @@ naclFactory.instantiate(function (nacl) {
var replaceDerive = function replaceDerive(val) {
return val.replace("'", '');
};
var counter = 0;

var getMasterKeyFromSeed = function getMasterKeyFromSeed(seed) {
var hmac = createHmac('sha512', ED25519_CURVE);
Expand Down Expand Up @@ -42002,13 +42001,11 @@ function encode(address) {
}

window.algorandUtil = {
account: function account(mnemonic, passphrase) {
account: function account(mnemonic, passphrase, accountIndex) {

var seed = bip39.mnemonicToSeed(mnemonic, passphrase);

var accountNumberInPath = counter.toString();
counter++;
var algoPath = "m/44'/283'/" + accountNumberInPath + "'/0'/0'";
var algoPath = "m/44'/283'/" + accountIndex.toString() + "'/0'/0'";

var childKeys = derivePath(algoPath, seed);

Expand Down
6 changes: 3 additions & 3 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@
var phrase = DOM.phrase.val();
var passphrase = DOM.passphrase.val();

var nemAccount = nemUtil.account(phrase,passphrase);
var nemAccount = nemUtil.account(phrase,passphrase,index);

privkey = nemAccount.privKey;
pubkey = nemAccount.publicKey;
Expand All @@ -1022,7 +1022,7 @@
var phrase = DOM.phrase.val();
var passphrase = DOM.passphrase.val();

var algoAccount = algorandUtil.account(phrase,passphrase);
var algoAccount = algorandUtil.account(phrase,passphrase, index);

privkey = algoAccount.privKey;
pubkey = algoAccount.publicKey;
Expand All @@ -1033,7 +1033,7 @@
var phrase = DOM.phrase.val();
var passphrase = DOM.passphrase.val();

var aionAccount = aionUtil.account(phrase,passphrase);
var aionAccount = aionUtil.account(phrase,passphrase, index);

privkey = aionAccount.privKey;
pubkey = aionAccount.publicKey;
Expand Down
10 changes: 3 additions & 7 deletions src/js/nemjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -114058,16 +114058,12 @@ var bip39 = require("bip39");
var HDNode = require("./util/hdnode");
var nem = require("nem-sdk").default;

var counter = 0;

window.nemUtil = {
account: function account(mnemonic, passphrase) {
account: function account(mnemonic, passphrase,accountIndex) {
var seed = bip39.mnemonicToSeed(mnemonic, passphrase);
var root = HDNode.fromSeedBuffer(seed);

var accountNumberInPath = counter.toString();
counter++;
var nemCustomPath = "m/44'/43'/" + accountNumberInPath + "'/0'/0'";

var nemCustomPath = "m/44'/43'/" + accountIndex.toString() + "'/0'/0'";
var node = root.derivePath(nemCustomPath); /* Check this hard coded path */

var secretKey = nem.utils.convert.hex2ua_reversed(node.getPrivateKeyHex());
Expand Down

0 comments on commit 66f0847

Please sign in to comment.