-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
I'm building a reactJS app for finding vanity addresses using this library and web workers to get multithreading. It all works great and the following code does the address creation and matching. However I have problem with performance. Without the derivePublicKey below I can do 150,000 loops per second. With the derivePublicKey the performance drops to 600/s. Another strange thing is that there is no difference using 2 threads or 12 when doing that. Just using "currentAddressesCount += 1" boost the loop count to 120 million per second so nothing wrong with the multithreading implementation. Perhaps there is nothing wrong with your library but maybe you know what's wrong?
function search() {
currentAddressesCount += 1
const array = new Uint8Array(32)
// eslint-disable-next-line no-restricted-globals
self.crypto.getRandomValues(array)
const seed = array.reduce((hex, idx) => hex + (`0${idx.toString(16)}`).slice(-2), '')
const secretKey = nano.deriveSecretKey(seed, 0)
const publicKey = nano.derivePublicKey(secretKey)
const address = nano.deriveAddress(publicKey, {useNanoPrefix: true})
if (isMatch(address)) {
postMessage(address)
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels