From d1d8699fc4f1599de39e643acc1d8be52114dd58 Mon Sep 17 00:00:00 2001 From: Shawn Arney Date: Wed, 29 Apr 2020 16:48:00 -0600 Subject: [PATCH] Adding FIO -Foundation for Interwallet Operability FIO - Foundation for Interwallet Operability. https://fioprotocol.io --- libs/combined/index.js | 20 ++++++++++++++++++++ libs/combined/package.json | 3 +++ src/index.html | 1 + src/js/fio-util.js | 19 +++++++++++++++++++ src/js/index.js | 13 +++++++++++++ tests/spec/tests.js | 9 +++++++++ 6 files changed, 65 insertions(+) mode change 100644 => 100755 libs/combined/package.json create mode 100644 src/js/fio-util.js diff --git a/libs/combined/index.js b/libs/combined/index.js index a9b716a..43524ef 100644 --- a/libs/combined/index.js +++ b/libs/combined/index.js @@ -88,4 +88,24 @@ module.exports.unorm = require('unorm') module.exports.zxcvbn = require('zxcvbn') +/* handshake */ module.exports.handshake = require('handshake-util') + +/* bs58 */ +try { + module.exports.bs58 = require('bs58') +} +catch (e) { + console.warn("Error loading bs58 library"); + console.warn(e); +}; + +/* create-hash */ +try { + module.exports.createHash = require('create-hash') +} +catch (e) { + console.warn("Error loading create-hash library"); + console.warn(e); +}; + diff --git a/libs/combined/package.json b/libs/combined/package.json old mode 100644 new mode 100755 index de0badc..76d908d --- a/libs/combined/package.json +++ b/libs/combined/package.json @@ -11,7 +11,9 @@ "bip38": "2.0.2", "bip38grs": "git://github.com/Groestlcoin/bip38grs.git#091975b01679b74dc0a4136bb743fe17791b0151", "bitcoinjs-lib": "git://github.com/iancoleman/bitcoinjs-lib.git#v3.3.2_16bit", + "bs58": "^4.0.1", "buffer": "5.4.3", + "create-hash": "^1.2.0", "ed25519-hd-key": "^1.0.0", "elastos-wallet-js": "git://github.com/johnnynanjiang/Elastos.SDK.Keypair.Javascript.git#491dc51b64efaf0a8aae62028b68e2c8e38fde06", "ethereumjs-util": "6.0.0", @@ -19,6 +21,7 @@ "fast-levenshtein": "2.0.6", "groestlcoinjs-lib": "git://github.com/Groestlcoin/groestlcoinjs-lib.git#3.3.2", "javascript-biginteger": "0.9.2", + "jsrsasign": "^8.0.15", "kjua": "0.6.0", "nebulas": "0.5.6", "stellar-base": "^0.10.0", diff --git a/src/index.html b/src/index.html index ae39c11..4e685a5 100644 --- a/src/index.html +++ b/src/index.html @@ -966,6 +966,7 @@ + diff --git a/src/js/fio-util.js b/src/js/fio-util.js new file mode 100644 index 0000000..35cb1ba --- /dev/null +++ b/src/js/fio-util.js @@ -0,0 +1,19 @@ +function FIObufferToPublic(pubBuf) { + const Buffer = libs.buffer.Buffer; + const FIO_PUBLIC_PREFIX = "FIO"; + + let checksum = libs.createHash("rmd160").update(pubBuf).digest("hex").slice(0, 8); + pubBuf = Buffer.concat([pubBuf, Buffer.from(checksum, "hex")]); + return FIO_PUBLIC_PREFIX.concat(libs.bs58.encode(pubBuf)); +} + +function FIObufferToPrivate(privBuf) { + const Buffer = libs.buffer.Buffer; + const FIO_PRIVATE_PREFIX = "80"; + + privBuf = Buffer.concat([Buffer.from(FIO_PRIVATE_PREFIX, "hex"), privBuf]); + let tmp = libs.createHash("sha256").update(privBuf).digest(); + let checksum = libs.createHash("sha256").update(tmp).digest("hex").slice(0, 8); + privBuf = Buffer.concat([privBuf, Buffer.from(checksum, "hex")]); + return libs.bs58.encode(privBuf); +} \ No newline at end of file diff --git a/src/js/index.js b/src/js/index.js index 32825b2..e8072e4 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -1241,6 +1241,12 @@ privkey = eosUtil.bufferToPrivate(keyPair.d.toBuffer(32)); } + if (networks[DOM.network.val()].name == "FIO - Foundation for Interwallet Operability") { + address = "" + pubkey = FIObufferToPublic(keyPair.getPublicKeyBuffer()); + privkey = FIObufferToPrivate(keyPair.d.toBuffer(32)); + } + //Groestlcoin Addresses are different if(isGRS()) { @@ -2498,6 +2504,13 @@ setHdCoin(40); }, }, + { + name: "FIO - Foundation for Interwallet Operability", + onSelect: function() { + network = libs.bitcoin.networks.bitcoin; + setHdCoin(235); + }, + }, { name: "FIX - FIX", onSelect: function() { diff --git a/tests/spec/tests.js b/tests/spec/tests.js index 15a52b3..dc6e4b5 100644 --- a/tests/spec/tests.js +++ b/tests/spec/tests.js @@ -1205,6 +1205,15 @@ it('Allows selection of Feathercoin', function(done) { }; testNetwork(done, params); }); +it('Allows selection of FIO', function(done) { + var params = { + selectText: "FIO - Foundation for Interwallet Operability", + phrase: "valley alien library bread worry brother bundle hammer loyal barely dune brave", + firstPubKey: "FIO5kJKNHwctcfUM5XZyiWSqSTM5HTzznJP9F3ZdbhaQAHEVq575o", + firstPrivKey: "5Kbb37EAqQgZ9vWUHoPiC2uXYhyGSFNbL6oiDp24Ea1ADxV1qnu", + }; + testNetwork(done, params); +}); it('Allows selection of Firstcoin', function(done) { var params = { selectText: "FRST - Firstcoin", -- 2.41.0