allow storing private keys in the vault

This commit is contained in:
Eugene Pankov
2021-06-19 21:54:27 +02:00
parent e41fe9f4c0
commit 51f62c9719
17 changed files with 567 additions and 44 deletions

View File

@@ -206,3 +206,31 @@ function utf8ToBytes (string, units) {
}
return bytes
}
// Create lookup table for `toString('hex')`
// See: https://github.com/feross/buffer/issues/219
const hexSliceLookupTable = (function () {
const alphabet = '0123456789abcdef'
const table = new Array(256)
for (let i = 0; i < 16; ++i) {
const i16 = i * 16
for (let j = 0; j < 16; ++j) {
table[i16 + j] = alphabet[i] + alphabet[j]
}
}
return table
})()
export function hexSlice (start, end) {
const len = this.length
if (!start || start < 0) {start = 0}
if (!end || end < 0 || end > len) {end = len}
let out = ''
for (let i = start; i < end; ++i) {
out += hexSliceLookupTable[this[i]]
}
return out
}