Last active
August 29, 2015 14:20
-
-
Save evilaliv3/060b2cc8a075f4704e32 to your computer and use it in GitHub Desktop.
openpgp_deterministic_key.worker.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
importScripts('openpgp.worker.js'); | |
importScripts('scrypt.js'); | |
var generateKeyPair = window.openpgp.generateKeyPair; | |
window.openpgp.generateKeyPair = function(options) { | |
var scrypt = scrypt_module_factory(33554432); | |
var utf8_pwd = scrypt.encode_utf8(options.receipt); | |
var salt = options.salt; | |
var offset = 0; | |
var seed = scrypt.crypto_scrypt(utf8_pwd, salt, 4096, 8, 1, 128 * 2); | |
function getDeterministicRandomOctet() { | |
return seed[offset++ % seed.length]; | |
} | |
window.openpgp.crypto.random.getSecureRandomOctet = getDeterministicRandomOctet; | |
return generateKeyPair(options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment