Does a library for nostr PoW in the browser exist? Given an event and a target difficulty I want it to search for a nonce. #asknostr

Reply to this note

Please Login to reply.

Discussion

just loop whatever you’re using to get ur event hash https://github.com/nbd-wtf/nostr-tools/blob/master/nip13.ts

Didn't know nostr-tools had this, thanks!

it uses SHA256 right? It uses a nonce field to change the hash output right?

I haven't actually looked at the nostr PoW but I'd guess one could write a note hash grinder in Go in a day that uses SIMD AVX2.

Using javascript for this seems like torture to me.

Yes. I know it's not the most optimal solution but wanted to experiment with a web app that allows to create events with PoW. iirc there was a WASM implementation that could be a lot faster than JS.

I made my current nostr key using my tool signr. it has 'mleku' at the end. it didn't take that long but adding one more letter and it ran all day. But elliptic curve key derivation doesn't have acceleration. PoW does. I could write a hash grinder pretty easy if I had lots of spare time but I'm busy atm. It wouldn't be hard to write a zero copy nonce rolling thingy.

I could probably write a back-end that interfaces through websockets that lets you offload the hash/nonce rotation to the faster CPU. It's not that difficult to write interfaces for ASICs also, they are generally running over serial bus of some sort, but AVX2 SHA256 is a LOT faster than the old regular CPU computation. I recall it was about 700ns to compute them before, now it's closer to 200 with the SIMD AVX2 version I use in my code.

Check https://www.getwired.app/. It is uses POW to allow messages in a public agora.

Here’s the repo https://github.com/smolgrrr/Wired