0

If I want to compute the sha256 hash of some bytes, I can use solana_program::hashv::hashv, which works fine for a small piece of data that can be hashed in one transaction. Let's say I want to hash something bigger, which I can't do in one transaction because the data is too long to fit in a tx, or hashing would exceed the compute budget, or some other limitation. Is there a way to hash part of the data in one tx and another part in a second (since sha256 is extendable)?

1 Answer 1

1

Turns out there is a easy way:

I can use solana_program::hash::extend_and_hash and store my intermediary hash in a PDA.

Always cool to see the amount of power some of the solana standard libs pack!

1
  • Note for future readers: Alternatively one could also cut the data into a bunch of equally sized chunks and use a Merkle Tree to achieve the same goal in many cases, however this is much less efficient if you only care about having one hash for all your data and none of the other properties of MTs.
    – McBain
    Commented Apr 15 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.