secp256k1cipher 0.1.6

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


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:

  secp256k1cipher: ^0.1.6

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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19


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 140 col 60: Avoid types as parameter names.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
hex ^0.1.2 0.1.2
pointycastle ^1.0.1 1.0.1
Dev dependencies
test >=0.12.30 <1.4.0