aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/encryptor.js9
-rw-r--r--app/scripts/lib/idStore.js1
-rw-r--r--app/scripts/lib/sig-util.js23
3 files changed, 32 insertions, 1 deletions
diff --git a/app/scripts/lib/encryptor.js b/app/scripts/lib/encryptor.js
index 3d069ab33..832e6d528 100644
--- a/app/scripts/lib/encryptor.js
+++ b/app/scripts/lib/encryptor.js
@@ -22,6 +22,8 @@ module.exports = {
// Buffer <-> base64 string methods
encodeBufferToBase64,
decodeBase64ToBuffer,
+
+ generateSalt,
}
// Takes a Pojo, returns encrypted text.
@@ -135,3 +137,10 @@ function decodeBase64ToBuffer (base64) {
}))
return buf
}
+
+function generateSalt (byteCount = 32) {
+ var view = new Uint8Array(byteCount)
+ global.crypto.getRandomValues(view)
+ var b64encoded = btoa(String.fromCharCode.apply(null, view))
+ return b64encoded
+}
diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js
index 9d0ca7f19..416b65b85 100644
--- a/app/scripts/lib/idStore.js
+++ b/app/scripts/lib/idStore.js
@@ -114,7 +114,6 @@ IdentityStore.prototype.getState = function () {
conversionRate: configManager.getConversionRate(),
conversionDate: configManager.getConversionDate(),
gasMultiplier: configManager.getGasMultiplier(),
-
}))
}
diff --git a/app/scripts/lib/sig-util.js b/app/scripts/lib/sig-util.js
new file mode 100644
index 000000000..f8748f535
--- /dev/null
+++ b/app/scripts/lib/sig-util.js
@@ -0,0 +1,23 @@
+const ethUtil = require('ethereumjs-util')
+
+module.exports = {
+
+ concatSig: function (v, r, s) {
+ const rSig = ethUtil.fromSigned(r)
+ const sSig = ethUtil.fromSigned(s)
+ const vSig = ethUtil.bufferToInt(v)
+ const rStr = padWithZeroes(ethUtil.toUnsigned(rSig).toString('hex'), 64)
+ const sStr = padWithZeroes(ethUtil.toUnsigned(sSig).toString('hex'), 64)
+ const vStr = ethUtil.stripHexPrefix(ethUtil.intToHex(vSig))
+ return ethUtil.addHexPrefix(rStr.concat(sStr, vStr)).toString('hex')
+ },
+
+}
+
+function padWithZeroes (number, length) {
+ var myString = '' + number
+ while (myString.length < length) {
+ myString = '0' + myString
+ }
+ return myString
+}