HigherOrderCO / Bend

A massively parallel, high-level programming language
https://higherorderco.com
Apache License 2.0
17.14k stars 421 forks source link

Request: Built in native Hash functions and other cryptographic tools #368

Open partylikeits1983 opened 3 months ago

partylikeits1983 commented 3 months ago

Is your feature request related to a problem? Please describe. Not a problem, but a feature request. It would be extremely useful to have various hash functions and other cryptographic primitives inside of bend.

Describe the solution you'd like Having standard hash functions such as SHA256 or keccak256, and then ZK oriented hash functions such as Poseidon2, Blake3, RPO, would make Bend a bombshell in the cryptography / blockchain engineering world.

Describe alternatives you've considered Implementing these hash functions natively in Bend would be time intensive, I was wondering if it is possible to import rust hash function implementations into bend.

bhavik-goplani commented 1 month ago

@developedby I'd like to work on this issue. Is there anything you think I should look into before implementing this?

developedby commented 1 month ago

It's not really possible to add this at this moment with good performance.

I think it makes more sense to implement these functions in Bend and then optimize HVM to run these functions efficiently.

Right now you could implement it as a dynamic IO library or as a fork of HVM that has the basic operations as primitives, but it's not really possible to run all of a hash in a single step. You'd need to either add operations that run on lists (tuple lists for the most dense possible HVM representation) or add native array types with their own set of interactions, which would be a bit more complicated.

bhavik-goplani commented 1 month ago

@developedby Thanks for the heads up! I'll start with one hash function as a prototype and see what works best. If I have any questions, I'll reach out.