filecoin-project / blstrs

Other
58 stars 37 forks source link

Support of hash_to_curve using blst_map_to_g1/g2 #48

Open dev0x1 opened 1 year ago

dev0x1 commented 1 year ago

Hello, blst exposes blst_map_to_g1 and blst_map_to_g2. These APIs are useful in the case when a user of this library wants to do hash-to-curve using different XMD and XOF based hashing of the messages. It would be nice if wrapper of these APIs are added in blstrs.

Below is the link for an implementation where I have copied hash-to-curve generic traits from zkcrypto/bls12_381 and implemented the wrappers under a feature flag. I have used zkcrypto/bls12_381's test cases too(test vectors are from hash_to_curve spec draft 10) and the tests pass.

Implementation: https://github.com/filecoin-project/blstrs/compare/master...dev0x1:blstrs:gaurav/h2c

To test,

cargo test --features h2c_generic_hash --features alloc

Thanks,

NashAiomos commented 9 months ago

This is great