{"action":"created","issue":{"url":"https://api.github.com/repos/weilu/bip39/issues/21","labels_url":"https://api.github.com/repos/weilu/bip39/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/weilu/bip39/issues/21/comments","events_url":"https://api.github.com/repos/weilu/bip39/issues/21/events","html_url":"https://github.com/weilu/bip39/issues/21","id":98347529,"number":21,"title":"pbkdf2 performance vs sjcl","user":{"login":"rubensayshi","id":649160,"avatar_url":"https://avatars.githubusercontent.com/u/649160?v=3","gravatar_id":"","url":"https://api.github.com/users/rubensayshi","html_url":"https://github.com/rubensayshi","followers_url":"https://api.github.com/users/rubensayshi/followers","following_url":"https://api.github.com/users/rubensayshi/following{/other_user}","gists_url":"https://api.github.com/users/rubensayshi/gists{/gist_id}","starred_url":"https://api.github.com/users/rubensayshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubensayshi/subscriptions","organizations_url":"https://api.github.com/users/rubensayshi/orgs","repos_url":"https://api.github.com/users/rubensayshi/repos","events_url":"https://api.github.com/users/rubensayshi/events{/privacy}","received_events_url":"https://api.github.com/users/rubensayshi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-31T09:04:09Z","updated_at":"2015-07-31T15:50:53Z","closed_at":null,"body":"I was trying to figure out how to optimize bip39 a bit for mobile (cordova), the `sjcl` package is about 10x faster for me than the `pbkdf` package, could be interesting to switch?\r\n\r\n* note you have to `./configure --with-sha512 --with-hmac --with-pbkdf2 --with-bitArray && make` the sjcl, the default npm package does not contain sha512.... *\r\n\r\n```\r\nvar sjcl = require('sjcl');\r\nvar pbkdf = require('pbkdf');\r\n\r\nvar mnemonic = \"later arrest fit foil goat excess online question trumpet grape license term bounce job nominee nuclear credit artefact measure record buyer service husband april tower average athlete pole alpha law picnic tail prepare satisfy dizzy hire illness legal forum rain sniff ask asthma pond present beach either minimum\";\r\nvar salt = \"roooooooobs\";\r\nvar mnemonicBuffer = new Buffer(mnemonic, 'utf8');\r\nvar saltBuffer = new Buffer(password, 'utf8');\r\n\r\nt = (new Date).getTime();\r\n\r\nconsole.log(typeof sjcl.hash.sha512);\r\n\r\nvar hmacSHA512 = function (key) {\r\n    var hasher = new sjcl.misc.hmac( key, sjcl.hash.sha512 );\r\n    this.encrypt = function () {\r\n        return hasher.encrypt.apply( hasher, arguments );\r\n    };\r\n};\r\n\r\nvar sjclResult = sjcl.misc.pbkdf2(sjcl.codec.utf8String.toBits(mnemonic), sjcl.codec.utf8String.toBits(salt), 2048, 64 * 8, hmacSHA512);\r\nconsole.log(\"sjcl.misc.pbkdf2 \" + ((new Date).getTime() - t));\r\nconsole.log(sjcl.codec.hex.fromBits(sjclResult));\r\n\r\nt = (new Date).getTime();\r\n\r\nvar pbkdf2Result = pbkdf2.pbkdf2Sync(mnemonicBuffer, saltBuffer, 2048, 64, 'sha512');\r\nconsole.log(\"pbkdf2.pbkdf2Sync \" + ((new Date).getTime() - t));\r\nconsole.log(pbkdf2Result.toString('hex'));\r\n```"},"comment":{"url":"https://api.github.com/repos/weilu/bip39/issues/comments/126730842","html_url":"https://github.com/weilu/bip39/issues/21#issuecomment-126730842","issue_url":"https://api.github.com/repos/weilu/bip39/issues/21","id":126730842,"user":{"login":"rubensayshi","id":649160,"avatar_url":"https://avatars.githubusercontent.com/u/649160?v=3","gravatar_id":"","url":"https://api.github.com/users/rubensayshi","html_url":"https://github.com/rubensayshi","followers_url":"https://api.github.com/users/rubensayshi/followers","following_url":"https://api.github.com/users/rubensayshi/following{/other_user}","gists_url":"https://api.github.com/users/rubensayshi/gists{/gist_id}","starred_url":"https://api.github.com/users/rubensayshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubensayshi/subscriptions","organizations_url":"https://api.github.com/users/rubensayshi/orgs","repos_url":"https://api.github.com/users/rubensayshi/repos","events_url":"https://api.github.com/users/rubensayshi/events{/privacy}","received_events_url":"https://api.github.com/users/rubensayshi/received_events","type":"User","site_admin":false},"created_at":"2015-07-31T15:50:53Z","updated_at":"2015-07-31T15:50:53Z","body":"ios is also factor 10x and is by far the worst, pdkdf2 takes 23s, sjcl 2.8s"}}