flutter_nano_ffi 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 91

Flutter NANO FFI #

Pub CI

A Nano and Banano cryptocurrency library for the Dart programming language

Based on NanoDart, but uses C functions for blake2b hashing and ed25519 cryptogaphy - using Dart's FFI features.

Features #

NanoDart supports seed generation, key derivation, validators, signing, block creation, and other essential functions of the Nano and Banano cryptocurrencies.

Usage #

See the example and test folders for examples and usage.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

1.0.2 #

  • Use C for all blake2b hash calculations (Account checksum, block hash calculation)

1.0.1 #

  • Address pub analysis warnings

1.0.0 #

  • Initial release
  • Same API as nanodart
  • Uses dart FFI to run ed25519/blake2b functions natively

example/lib/main.dart

import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter_nano_ffi/flutter_nano_ffi.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String address;

  @override
  void initState() {
    super.initState();
    // Generating a random seed
    String seed = NanoSeeds.generateSeed();
    // Getting private key at index-0 of this seed
    String privateKey = NanoKeys.seedToPrivate(seed, 0);
    // Getting public key from this private key
    String pubKey = NanoKeys.createPublicKey(privateKey);
    // Getting address (nano_, ban_) from this pubkey
    address = NanoAccounts.createAccount(NanoAccountType.NANO, pubKey);
    // Validating address
    NanoAccounts.isValid(NanoAccountType.NANO, address);

    // Creating a block
    int accountType = NanoAccountType.NANO;
    String account =
        'xrb_3igf8hd4sjshoibbbkeitmgkp1o6ug4xads43j6e4gqkj5xk5o83j8ja9php';
    String previous = '0';
    String representative =
        'xrb_3p1asma84n8k84joneka776q4egm5wwru3suho9wjsfyuem8j95b3c78nw8j';
    BigInt balance = BigInt.parse('1');
    String link =
        '1EF0AD02257987B48030CC8D38511D3B2511672F33AF115AD09E18A86A8355A8';
    String calculatedHash = NanoBlocks.computeStateHash(
        accountType, account, previous, representative, balance, link);
    // Signing a block
    NanoSignatures.signBlock(calculatedHash, privateKey);

    // Encrypting and decrypting a seed
    Uint8List encrypted = NanoCrypt.encrypt(seed, 'thisisastrongpassword');
    // String representation:
    String encryptedSeedHex = NanoHelpers.byteToHex(encrypted);
    // Decrypting (if incorrect password, will throw an exception)
    Uint8List decrypted = NanoCrypt.decrypt(
        NanoHelpers.hexToBytes(encryptedSeedHex), 'thisisastrongpassword');
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter nano FFI'),
        ),
        body: Center(
          child: Text(address),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_nano_ffi: ^1.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_nano_ffi/flutter_nano_ffi.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
82
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
91
Learn more about scoring.

We analyzed this package on Jul 10, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:flutter_nano_ffi/flutter_nano_ffi.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:flutter_nano_ffi/flutter_nano_ffi.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:flutter_nano_ffi/flutter_nano_ffi.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:flutter_nano_ffi/flutter_nano_ffi.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • flutter_nano_ffi that is a package requiring null.

Health suggestions

Format lib/src/account/account_util.dart.

Run flutter format to format lib/src/account/account_util.dart.

Format lib/src/blocks/state_block.dart.

Run flutter format to format lib/src/blocks/state_block.dart.

Format lib/src/ffi/ed25519_blake2b.dart.

Run flutter format to format lib/src/ffi/ed25519_blake2b.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
bip39 ^1.0.3 1.0.3
ffi ^0.1.3 0.1.3
flutter 0.0.0
hex ^0.1.2 0.1.2
pointycastle ^1.0.2 1.0.2
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.5
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test