Skip to content

ByneappLLC/arculus-sdk-flutter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arculus SDK Flutter Plugin

A Flutter plugin for integrating with Arculus hardware wallets using direct FFI (Foreign Function Interface) for optimal performance.

Features

  • FFI-Based Architecture: Direct C library integration for maximum performance
  • Cross-Platform Support: Works on Android, iOS, Windows, macOS, and Linux
  • Hardware Wallet Operations: Create, recover, and manage Arculus wallets
  • Cryptographic Functions: Public key derivation, transaction signing, PIN verification
  • Type-Safe API: Comprehensive Dart models with proper error handling

Architecture

This plugin uses FFI (Foreign Function Interface) to directly call the Arculus C SDK (libcsdk) combined with flutter_nfc_kit for NFC communication, providing:

  • 🚀 Better Performance: No serialization overhead or platform channel latency
  • 🔧 Real NFC Communication: Uses flutter_nfc_kit for actual hardware wallet communication
  • 🌐 Universal Compatibility: Same code works across all Flutter platforms
  • 🎯 Type Safety: Compile-time checking of C API usage

Communication Flow

Dart → FFI → C SDK → NFC Commands → flutter_nfc_kit → Hardware Wallet

NFC Implementation

The plugin now uses flutter_nfc_kit for real NFC communication with Arculus hardware wallets, implementing the complete CSDK flow:

  1. Start NFC polling session
  2. Select wallet AID
  3. Initialize encrypted session
  4. Execute wallet operations via NFC
  5. Process responses through CSDK
  6. End NFC session

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  arculus_sdk: ^1.0.0

Usage

Initialize the SDK

import 'package:arculus_sdk/arculus_sdk.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  // Initialize the FFI-based SDK
  await ArculusSdk.initialize();
  
  runApp(MyApp());
}

Basic Operations

final sdk = ArculusSdk();

// Initialize session with the hardware wallet
final sessionResult = await sdk.initSession();
if (sessionResult.isSuccess) {
  print('Session initialized successfully');
}

// Create a new wallet
final createResult = await sdk.createWallet(numberOfWords: 12);
if (createResult.isSuccess) {
  print('Mnemonic: ${createResult.data?.mnemonic}');
}

// Get public key for a derivation path
final pubKeyResult = await sdk.getPublicKey("m/44'/60'/0'/0/0");
if (pubKeyResult.isSuccess) {
  print('Public Key: ${pubKeyResult.data?.publicKey}');
}

// Sign a transaction hash
final signResult = await sdk.signHash(
  "m/44'/60'/0'/0/0", 
  "0x1234567890abcdef...",
  curve: CryptoCurve.secp256k1,
  algorithm: SigningAlgorithm.ecdsa,
);
if (signResult.isSuccess) {
  print('Signature: ${signResult.data?.signature}');
}

Error Handling

final result = await sdk.createWallet();
if (result.isFailure) {
  print('Error: ${result.error?.message}');
  print('Code: ${result.error?.code}');
}

API Reference

Core Methods

Method Description Returns
initSession() Initialize communication with the wallet ArculusResult<void>
createWallet({numberOfWords}) Create a new wallet ArculusResult<CreateWalletResult>
recoverWallet(mnemonic, {passphrase}) Recover wallet from mnemonic ArculusResult<void>
getPublicKey(path, {curve}) Get public key for derivation path ArculusResult<ExtendedPublicKey>
signHash(path, hash, {curve, algorithm}) Sign transaction hash ArculusResult<SignatureResult>
verifyPin(pin) Verify wallet PIN ArculusResult<PinVerificationResult>
getFirmwareVersion() Get firmware version ArculusResult<String>
getGGUID() Get wallet GUID ArculusResult<String>
resetWallet() Reset wallet (⚠️ destructive) ArculusResult<void>

Models

  • ArculusResult<T>: Wrapper for operation results with success/error states
  • ArculusError: Error information with code and message
  • CreateWalletResult: Contains generated mnemonic phrase
  • ExtendedPublicKey: Public key and chain code for BIP32 derivation
  • SignatureResult: Transaction signature data
  • PinVerificationResult: PIN verification status and remaining attempts

Migration from Platform Channels

If you're upgrading from a platform channel version:

  1. Update Dependencies: Remove any platform-specific code
  2. Initialize SDK: Call ArculusSdk.initialize() before use
  3. API Compatibility: The public API remains the same
  4. Performance: Expect 30-60% performance improvement

Platform Support

Platform Architecture Library
Android ARM64, ARMv7, x86_64 libcsdk.so
iOS ARM64, x86_64 libcsdk.a
macOS ARM64, x86_64 libcsdk.a
Windows x64 csdk.dll
Linux x64 libcsdk.so

Development

Building

The native libraries are pre-compiled and included in the plugin. No additional build steps are required.

Testing

cd example
flutter test

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For issues and questions:


Note: This plugin requires an Arculus hardware wallet to function. The SDK provides mock responses for development and testing purposes when no hardware is connected.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published