secp256k1cipher 0.2.1

secp256k1Cipher #

Encrypt and decrypt data use secp256k1

Changelog #

Version 0.1.0 (2019-06-06) #

  • Add example code and this file.

Version 0.1.1 (2019-06-10) #

    1. sha256 compress the secret length to 32, just fix the salsa20 key langth;
    1. Change IV to base64 string, will be shorter for transport;

Version 0.1.2 (2019-06-21) #

    1. add uint8list encrypt decrypt support

Version 0.1.3 (2019-07-02) #

    1. add strict check for point on curve
    1. fix bug's on serialization of public key

Version 0.1.4 (2019-07-03) #

    1. add compressed publickey support

Version 0.1.5 (2019-07-03) #

    1. Change secret to encrypt key method to eliminate ambiguity;

Version 0.1.6 (2019-07-11) #

    1. fix bugs when encrypt and decrypt unicode String

Version 0.1.7 (2019-07-11) #

    1. support use part of secret as iv

Version 0.1.8 (2019-08-03) #

    1. fix bugs when generate iv

Version 0.2.0 (2019-08-15) #

    1. PublicKey generate BTC Address
    1. PublicKey generate ETH Address

Version 0.2.1 (2019-09-12) #

    1. Remove unused logs.

example/main.dart

import 'package:secp256k1cipher/secp256k1cipher.dart';

void main(){
  var alic = generateKeyPair(); // Create Alic keypair
  var bob = generateKeyPair();  // Create Bob keypair
  var raw_str = 'Encrypt and decrypt data use secp256k1';  // This is what alic want to say to bob
  var enc_map = pubkeyEncrypt(strinifyPrivateKey(alic.privateKey), strinifyPublicKey(bob.publicKey), raw_str); // use alic's privatekey and bob's publickey means alic say to bob
  var enc_str = enc_map['enc']; // Get encrypted base64 string
  var iv = enc_map['iv'];       // Get random IV
  // next thing, you can send enc_str and IV via internet to bob
  var decryptd = privateDecrypt(strinifyPrivateKey(bob.privateKey), strinifyPublicKey(alic.publicKey), enc_str, iv); // use bob's privatekey and alic's publickey means bob can read message from alic
  print('alic say:${decryptd}');
}

Use this package as a library

1. Depend on it

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


dependencies:
  secp256k1cipher: ^0.2.1

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:secp256k1cipher/secp256k1cipher.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
43
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
71
Learn more about scoring.

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

  • Dart: 2.5.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:secp256k1cipher/secp256k1cipher.dart.

Health suggestions

Fix lib/src/operator.dart. (-1.99 points)

Analysis of lib/src/operator.dart reported 4 hints:

line 17 col 7: Equality operator == invocation with references of unrelated types.

line 40 col 9: The value of the local variable 'y' isn't used.

line 89 col 7: Equality operator == invocation with references of unrelated types.

line 95 col 7: Don't explicitly initialize variables to null.

Fix lib/secp256k1cipher.dart. (-0.50 points)

Analysis of lib/secp256k1cipher.dart reported 1 hint:

line 1 col 9: Name libraries using lowercase_with_underscores.

Fix lib/src/secp256k1Cipher.dart. (-0.50 points)

Analysis of lib/src/secp256k1Cipher.dart reported 1 hint:

line 175 col 60: Avoid types as parameter names.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
base58check ^1.0.1 1.0.1
hex ^0.1.2 0.1.2
pointycastle ^1.0.1 1.0.1
Transitive dependencies
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.3
typed_data 1.1.6
Dev dependencies
test >=0.12.30 <1.4.0