π¦ zetrix_vc_flutter
Plugin
A Flutter plugin that enables Verifiable Credential (VC) and Verifiable Presentation (VP) generation using BBS+ signatures, built on top of Zetrix blockchain specifications.
This implementation uses platform-specific native libraries (Rust-compiled via JNI/FFI) and exposes functionality to Dart via MethodChannel.
β Features
- π§ BBS+ key generation (BLS12-381)
- βοΈ BBS+ signature creation
- π Selective disclosure proofs
- π§± Works across Android and iOS (iOS soon)
- π¦ Built as a Flutter plugin (no manual linking for consumers)
π§Ή Project Structure
zetrix_vc_flutter/
βββ android/
β βββ src/main/java/.../MethodChannelHandler.java
β βββ src/main/jniLibs/arm64-v8a/libbbs.so
β βββ ...
βββ ios/
β βββ (pending FFI integration)
βββ lib/
β βββ bbs_bindings.dart
β βββ bbs.dart
β βββ zetrix_vc_flutter.dart
βββ example/
βββ pubspec.yaml
π§ How We Integrated Using MethodChannel
β Step-by-step:
1. Expose Native Methods via Java (Android)
We created a wrapper class in android/src/main/java/.../BbsMethodHandler.java
that maps Dart calls to native Rust bindings via JNI.
Example:
methodChannel.setMethodCallHandler((call, result) -> {
switch (call.method) {
case "createBbsProof":
// call Rust JNI wrapper
byte[] proof = Bbs.createProof(...);
result.success(proof);
break;
default:
result.notImplemented();
}
});
2. Implement Dart MethodChannel
In bbs.dart
, we use Flutter's MethodChannel
to call native methods:
const _channel = MethodChannel('zetrix_vc');
Future<Uint8List> createBbsProof(Map<String, dynamic> args) async {
final result = await _channel.invokeMethod<Uint8List>('createBbsProof', args);
return result!;
}
3. Link Native .so
Library Automatically
We placed libbbs.so
in android/src/main/jniLibs/
so it is automatically bundled into the APK:
android/
βββ src/main/jniLibs/
βββ arm64-v8a/
βββ libbbs.so
No manual linking needed from consumers.
4. Generate and Use JNI Headers
To link Java and Rust, we generated bbs_signatures_Bbs.h
using javac -h
. This header defines all native functions that the Rust/C side must implement.
javac -h . Bbs.java
π Why MethodChannel?
We chose MethodChannel over Dart FFI for Android because:
- JNI is well-documented and stable for native Rust β Java bindings.
- Flutter Android's MethodChannel provides simple serialization and error propagation.
- No need to handle cross-platform memory management at Dart-level.
- Works well with
.so
libraries generated from Rust (cargo-ndk
,jni
crate).
π Usage in Flutter
final proof = await createBbsProof({
"publicKey": [...],
"signature": [...],
"nonce": [...],
"messages": [...],
});
π TODOs
πͺ Build Notes
To rebuild the plugin after modifying native libs:
flutter clean
flutter pub get
flutter build apk
If your app uses this plugin as a dependency:
dependencies:
zetrix_vc_flutter: <VERSION>