poanetwork / threshold_crypto

A pairing-based threshold cryptosystem for collaborative decryption and signatures used in HoneybadgerBFT implementation
Other
191 stars 72 forks source link

Add FFI bindings? #95

Open vkomenda opened 4 years ago

vkomenda commented 4 years ago

This is not an issue with the crate but rather a question. As it happens, not all projects using this crate are written in Rust. Which is why such projects need to import the crate using FFI. When writing Ocaml FFI, I found that it is an extension of what a standard C API would have been, although I hadn't intended to write a C FFI in the first place.

Would it make sense to add a standard C FFI to this crate so that it could either be used on its own or embedded in more complex FFI for other languages like Ocaml?

The benefit of having a standard FFI from the crate user point of view is peer review and memory safety. For example, the FFI would keep secret keys on the Rust heap and not pass it over the FFI.

afck commented 4 years ago

I like the idea, but do you think it would be feasible to implement that as a separate crate, i.e. have a threshold_crypto_c crate that depends on threshold_crypto and exposes a C-compatible API, and ships with C header files? It would be cleaner to have it separate, and I don't think it would require access to any private internals of the threshold_crypto crate.

vkomenda commented 4 years ago

Thanks for the suggestion. A separate crate should do the job perfectly.

afck commented 4 years ago

Great! I won't be able to work on it any time soon, but I'd be happy to help with the review.

vkomenda commented 4 years ago

Thank you very much!

afck commented 4 years ago

Actually, let's keep this open until such a crate exists. It would be really great to have FFI bindings.