substrate_sign_flutter 0.1.1 copy "substrate_sign_flutter: ^0.1.1" to clipboard
substrate_sign_flutter: ^0.1.1 copied to clipboard

Substrate signing bindings in flutter, which could be used to sign messages locally or to sign extrinsics in order to interact with API.

Substrate Sign Flutter Plugin #

Flutter plugin for using Substrate signing functions offline.

This plugin use Dart ffi module to bind Rust function.

Now works on Android, check this thread to get update for ios

More details about using rust in flutter please check this great article

Usage #

Introduce SURI

SURI refers to Secret URI, it is with format of:

"$seedPhrase//$derivationPath///derivationPassword"

for example:

SURI bottom drive obey lake curtain smoke basket hold race lonely fit walk//kusama/1///000000.

Functions

randomPhrase: Generate random seed phrase

String randomPhrase(int digits)

substrateAddress: Generate substrate address with provided suri(Secret URI).

String substrateAddress(String seed, int prefix) 

substrateSign: Sign hex string with the provided seed

String substrateSign(String suri, String message)

encryptData: encrypt data with ethsign

String encryptData(String data, String password) 

decryptData: decrypt data with ethsign

String decryptData(String data, String password)

Functions with seed pointer

By using seed phrase, we could keep seed phrase in the protected Rust runtime and avoid it to be exposed to the dart Runtime and avoid it to keep in the app state. To interact with seed reference functions user need give the seed pointer as an argument.

//get address with seed pointer
String substrateAddressWithRef(int seedRef, String suriSuffix, int prefix)

//sign hex data with seed pointer
String substrateSignWithRef(int seedRef, String suriSuffix, String message)

//decrypt the cipher text and return the seed pointer
int decryptDataWithRef(String data, String password)

//destroy the pointer, deallocate the memory assigned to the seed
void destroyDataRef(int ref)

NOTICE: here suriSuffix refer to the combination of derivation path and derivation password like //some_path/1///123456 or only path but without password like //another_path

Develop #

To customize the library or add more functions. First run

./scripts/init.sh

to setup required toolchains, you will also need Android NDK for generating android native code, download it here and pointer environment variable NDK_HOME to it.

After customizing the rust code, run

./scripts/build.sh

to generate the glue code and binaries for Rust, Flutter, iOS and Android.

Test #

Now use integration test for testing the native binding functions.

cd example && flutter drive --target=test_driver/app.dart

License #

GNU 3.0

1
likes
40
pub points
0%
popularity

Publisher

unverified uploader

Substrate signing bindings in flutter, which could be used to sign messages locally or to sign extrinsics in order to interact with API.

Repository (GitHub)
View/report issues

License

GPL-3.0 (LICENSE)

Dependencies

ffi, flutter

More

Packages that depend on substrate_sign_flutter