dart_ssss 0.0.5

dart_ssss #

Build Status Coverage Status

A Dart library that implements Shamir's Secret Sharing Scheme over GF(256).

Given a secret in bytes, this package can assist in splitting up the secret into n parts and would be able to reconstruct the secret in bytes given a t threshold.

I would highly recommend you look at the the wikipedia page above to learn about the workings of Shamir's Secret Sharing Scheme.

Getting Started #

To use dart_ssss, add it to your dependencies in pubspec.yaml:

dependencies:
    dart_ssss: any

Then import the proper package:

import 'package:dart_ssss/dart_ssss.dart';

Usage #

To generate shares / parts for a secret of bytes:

void main() {
    
    List<int> secretInByteValues = [...];
    
    SecretScheme ss = new SecretScheme(numberOfPartsToGenerate, thresholdForJoining);
    
    Map<int, List<int>> shares = ss.createShares(secretInByteValues);
    
    ...
      
     

To combine shares to regenerate a secret:

    List<int> recombinedSecretInBytes = ss.combineShares(shares);
}

Tests #

To run tests on this package:

    pub run test 

in the package directory.

Limitations / Caveats #

Given that the package is implemented over GF(256), it means that the max number of shares / parts it can generate is 255. With that said, it is not advisable to generate 255 shares / parts as an adversary can forge a secret.

Shamir's Secret Sharing Scheme does not guarantee integrity, so if you are looking for something where you can verify shares or the resulting secret, this package is not for you.

License #

Copyright 2018 Gavin Ching

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Changelog #

0.0.1 #

  • Initial version with all functionalities implemented.

0.0.2 #

  • Add coverage analysis through Coveralls (tool/coveralls.sh) and have more tests for higher coverage.
  • Better readme.

0.0.3 #

  • Fix issue of possibly return a 0 x coordinate as a share.
  • Add in branches of code to ensure that it will be tested later on (lowering coverage).

0.0.4 #

  • Remove random byte method from ByteHelper and create ByteRandom singleton to be used to generate random bytes.
  • Add mocks to tests to properly test edge cases involving specific random bytes.

Use this package as a library

1. Depend on it

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


dependencies:
  dart_ssss: ^0.0.5

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

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

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

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

Health suggestions

Fix lib/src/secret_scheme.dart. (-6.31 points)

Analysis of lib/src/secret_scheme.dart reported 13 hints, including:

line 31 col 1: Prefer using /// for doc comments.

line 36 col 3: Prefer using /// for doc comments.

line 41 col 3: Prefer using /// for doc comments.

line 46 col 3: Prefer using /// for doc comments.

line 52 col 3: Prefer using /// for doc comments.

Fix lib/src/byte_polynomial.dart. (-4.89 points)

Analysis of lib/src/byte_polynomial.dart reported 10 hints, including:

line 29 col 1: Prefer using /// for doc comments.

line 47 col 33: Use isEmpty instead of length

line 83 col 3: Prefer using /// for doc comments.

line 88 col 3: Prefer using /// for doc comments.

line 129 col 3: Prefer using /// for doc comments.

Fix lib/src/gf_256.dart. (-2.96 points)

Analysis of lib/src/gf_256.dart reported 6 hints, including:

line 27 col 1: Prefer using /// for doc comments.

line 813 col 3: Prefer using /// for doc comments.

line 825 col 3: Prefer using /// for doc comments.

line 830 col 3: Prefer using /// for doc comments.

line 855 col 3: Prefer using /// for doc comments.

Fix additional 3 files with analysis or formatting issues. (-6.94 points)

Additional issues in the following files:

  • lib/src/utils/byte_random.dart (6 hints)
  • lib/src/lagrange_interpolation.dart (4 hints)
  • lib/src/utils/byte_helper.dart (4 hints)

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and dart_ssss.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <3.0.0
Dev dependencies
mockito any
test ^1.5.0

Admin