Why Nostr? What is Njump?
2023-09-02 04:05:09
in reply to

arkinox on Nostr: I'm having a really weird problem... I'm using noble/hashes/sha256 to get my event id ...

I'm having a really weird problem... I'm using noble/hashes/sha256 to get my event id from my serialized event. Somehow, the hash I get is sometimes 0b10000000 less than it should be.

example:
hash I get: ...2cce628 (invalid)
valid hash: ...2cce6a8

How is this even possible? Has anyone seen anything like this before? I'm using the bytesToHex util from noble as well.

If the input to the sha256 is different, I should get a completely different output. But I get a nearly identical output that is either off by 0b10000000 or it is perfect.

Might have to do with the binary-to-hex string conversion? But I'm using noble utils for that too...

Here is where I get the hash: https://github.com/arkin0x/construct-miner/blob/14103cc2d0c59571f59b254427c272e34c8dfdfc/src/workers/ConstructMiner.worker.js#L63

And here is where I get the Event ID wiith bytesToHex: https://github.com/arkin0x/construct-miner/blob/14103cc2d0c59571f59b254427c272e34c8dfdfc/src/components/MinerController.tsx#L137
Author Public Key
npub1arkn0xxxll4llgy9qxkrncn3vc4l69s0dz8ef3zadykcwe7ax3dqrrh43w