ralexstokes / ssz-rs

Implementation of ethereum's `ssz`
Apache License 2.0
103 stars 42 forks source link

Add support for verifying compact multiproofs #153

Open rista404 opened 6 months ago

rista404 commented 6 months ago

Hi! Thanks for maintaining this great library. We were using it in a (soon to be open-source) project but found ourselves missing the compact multiproof support. This PR adds the support for verifying such proofs.

You can read the spec here: https://github.com/ethereum/consensus-specs/pull/3148 You can also see a full TypeScript implementation here: https://github.com/ChainSafe/ssz/pull/292

I think those two PRs explain why compact proofs are useful! Lodestar, which we interact with, is already using them in production as the only format for certain proofs.

I've marked the implementation as experimental and added some very basic tests. I could do a follow-up PR that adds proof generation as well as more tests. Let me know if something needs changing!

ralexstokes commented 6 months ago

hi @rista404 this is great, thank you!

can you address the linter errors?

otherwise I'd generally lean to merge this soon

rista404 commented 6 months ago

@ralexstokes thanks for the review, I'll go back and make those changes in the same PR! I also highly recommend looking into the spec to get a better understanding of the compact multiproofs.

rista404 commented 6 months ago

@ralexstokes on a second thought, could we make an issue to refactor the code to use bitvec? I would have to see what's the best way to do that as the descriptor is a format defined in the spec, that you can for example send hex encoded over the wire etc.

Still very keen to optimise but I think I would need some more time. If the rest looks okay and you've had the time to look into the spec PR, feel free to merge 🙏🏻

Thanks again!

rista404 commented 6 months ago

@ralexstokes ping on this! anything else I can do to help get this merged?