Qortal UI - Main Code Repository A User Interface for the Qortal Blockchain Project. Truly decentralized web hosting, application hosting, communications, data storage, and full infrastructure for the future global decentralized digital world.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

22 lines
879 B

import {Epml, EpmlReadyPlugin, EpmlWorkerPlugin, RequestPlugin} from 'epml'
import utils from './cryptoUtils.js'
import {bytes_to_base64 as bytesToBase64, Sha512} from 'asmcrypto.js'
import bcrypt from 'bcryptjs'
Epml.registerPlugin(RequestPlugin)
Epml.registerPlugin(EpmlReadyPlugin)
Epml.registerPlugin(EpmlWorkerPlugin)
const parentEpml = new Epml({ type: 'WORKER', source: self })
parentEpml.route('kdf', async req => {
const { salt, key, nonce, staticSalt, staticBcryptSalt } = req.data
const combinedBytes = utils.appendBuffer(salt, utils.stringtoUTF8Array(staticSalt + key + nonce))
const sha512Hash = new Sha512().process(combinedBytes).finish().result
const sha512HashBase64 = bytesToBase64(sha512Hash)
const result = bcrypt.hashSync(sha512HashBase64.substring(0, 72), staticBcryptSalt)
return { key, nonce, result }
})
parentEpml.imReady()