nanodart 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 84

NanoDart #

A Nano and Banano cryptocurrency library for the Dart programming language

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.0 #

  • Initial release

example/nanodart_example.dart

import 'dart:typed_data';

import 'package:nanodart/nanodart.dart';

main() {
  // 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
  String 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');
}

Use this package as a library

1. Depend on it

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


dependencies:
  nanodart: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:nanodart/nanodart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
79
Health:
Code health derived from static analysis. [more]
81
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
84
Learn more about scoring.

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

  • Dart: 2.7.0
  • pana: 0.13.1+4

Health suggestions

Fix lib/src/crypto/tweetnacl_blake2b.dart. (-19.39 points)

Analysis of lib/src/crypto/tweetnacl_blake2b.dart reported 43 hints, including:

line 53 col 42: DO use curly braces for all flow control structures.

line 65 col 47: DO use curly braces for all flow control structures.

line 67 col 7: DO use curly braces for all flow control structures.

line 213 col 29: DO use curly braces for all flow control structures.

line 729 col 30: DO use curly braces for all flow control structures.

Format lib/src/account/account_coder.dart.

Run dartfmt to format lib/src/account/account_coder.dart.

Format lib/src/account/account_type.dart.

Run dartfmt to format lib/src/account/account_type.dart.

Fix additional 15 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/account/account_util.dart (Run dartfmt to format lib/src/account/account_util.dart.)
  • lib/src/blocks/state_block.dart (Run dartfmt to format lib/src/blocks/state_block.dart.)
  • lib/src/crypto/blake2b.dart (Run dartfmt to format lib/src/crypto/blake2b.dart.)
  • lib/src/crypto/sha.dart (Run dartfmt to format lib/src/crypto/sha.dart.)
  • lib/src/encrypt/aes/aes_cbcpkcs7.dart (Run dartfmt to format lib/src/encrypt/aes/aes_cbcpkcs7.dart.)
  • lib/src/encrypt/crypter.dart (Run dartfmt to format lib/src/encrypt/crypter.dart.)
  • lib/src/encrypt/kdf/kdf.dart (Run dartfmt to format lib/src/encrypt/kdf/kdf.dart.)
  • lib/src/encrypt/kdf/pbkdf2_kdf.dart (Run dartfmt to format lib/src/encrypt/kdf/pbkdf2_kdf.dart.)
  • lib/src/encrypt/kdf/sha256_kdf.dart (Run dartfmt to format lib/src/encrypt/kdf/sha256_kdf.dart.)
  • lib/src/encrypt/model/keyiv.dart (Run dartfmt to format lib/src/encrypt/model/keyiv.dart.)
  • lib/src/keys/keys.dart (Run dartfmt to format lib/src/keys/keys.dart.)
  • lib/src/keys/mnemonics.dart (Run dartfmt to format lib/src/keys/mnemonics.dart.)
  • lib/src/keys/seeds.dart (Run dartfmt to format lib/src/keys/seeds.dart.)
  • lib/src/signing/signer.dart (Run dartfmt to format lib/src/signing/signer.dart.)
  • lib/src/util.dart (Run dartfmt to format lib/src/util.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
bip39 ^1.0.3 1.0.3
convert ^2.1.1 2.1.1
fixnum ^0.10.9 0.10.11
hex ^0.1.2 0.1.2
pointycastle ^1.0.1 1.0.2
Transitive dependencies
charcode 1.1.2
collection 1.14.12
crypto 2.1.4
typed_data 1.1.6
Dev dependencies
pedantic ^1.8.0+1
test ^1.6.8