In order to maintain a unified user experience and equivalent functionalities between the different programming languages, we implement all functionalities in Rust (stable) and bridge each one to every language-specific SDK trough FFI (foreign function interface).
To achieve interoperability between different programming languages, we use an architecture that has the following elements:
- Bloock Libs: Contain specific utilities used accross different features. Such as: hashing algorithms, digital signature algorithms, encrytption algorigthms, HTTP communication, ...
- Bloock Core: Contains all the bussiness logic for every feature.
- Bloock Bridge: Implements the GRPC-like endpoints and connects them with the features implemented in the Core.
- Language-specific libraries: Contains all the interfaces for the consumer and connects with the bridge using the different endpoints available.
The communication between different languages is done by using a language-specific interoperability layer and a generic transport layer.
To support this two cases, we chose Rust as a Core programming language because is able to compile to C and WebAssembly.
In order to minimize the effort dedicated to interact with the FFI layer which, specially in C, is time consuming we use Protocol Buffers and a modified GRPC protocol in such a way that we define in-memory endpoints that are called by the language-specific SDKs (client) and served by the Rust Bridge (server)