Skip to content

Commit fe41117

Browse files
committed
Update readme and PyPI adjustments.
1 parent 541116d commit fe41117

3 files changed

Lines changed: 68 additions & 5 deletions

File tree

README.md

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,73 @@
1-
# js2pysecrets
2-
3-
[![codecov](https://codecov.io/gh/poing/JS2PySecrets/branch/main/graph/badge.svg?token=JS2PySecrets_token_here)](https://codecov.io/gh/poing/JS2PySecrets)
41
[![CI](https://github.com/poing/JS2PySecrets/actions/workflows/main.yml/badge.svg)](https://github.com/poing/JS2PySecrets/actions/workflows/main.yml)
2+
[![codecov](https://codecov.io/gh/poing/JS2PySecrets/branch/main/graph/badge.svg?token=JS2PySecrets_token_here)](https://codecov.io/gh/poing/JS2PySecrets)
3+
[![PyPI version](https://badge.fury.io/py/js2pysecrets.svg)](https://badge.fury.io/py/js2pysecrets)
54
[![Built with Material for MkDocs](https://img.shields.io/badge/Material_for_MkDocs-526CFE?logo=MaterialForMkDocs&logoColor=white)](https://squidfunk.github.io/mkdocs-material/)
6-
75
[![JS2PySecrets Documentation](https://img.shields.io/badge/Documentation-white?labelColor=3F00FF&logo=data:image/svg%2bxml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJiIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNDEuNTUgMTUwLjUiPjxnIGlkPSJjIj48cGF0aCBkPSJNOTEuMy4yNWw1OC4yOC4wOGM2LjQ3LDAsMTEuNzIsNS4yNiwxMS43MiwxMS43M2gwYzAsNS4zLTIuMTEsMTAuMzktNS44NiwxNC4xNGwtMy41LDMuNWMtNi4wMyw2LjAzLTYuNDYsMTUuNjYtMS4wMSwyMi4yMWgwYzgsOS42LDIyLjczLDkuNiwzMC43MywwaDBjNS40Ni02LjU1LDUuMDItMTYuMTgtMS4wMS0yMi4yMWwtMy41LTMuNWMtMy43NS0zLjc1LTUuODYtOC44NC01Ljg2LTE0LjE0aDBjMC02LjQ3LDUuMjQtMTEuNzIsMTEuNzItMTEuNzNsNTguMjgtLjA4YzAsODIuMjktNjcuNzEsMTUwLTE1MCwxNTAtMjYuMzMsMC01Mi4yLTYuOTMtNzUtMjAuMWwyOS4xNy01MC41MmMzLjI0LTUuNiwxLjMyLTEyLjc3LTQuMjktMTZoMGMtNC41OS0yLjY1LTEwLjA1LTMuMzctMTUuMTgtMmwtNC43OCwxLjI4Yy04LjIzLDIuMjEtMTYuNzktMi4yMy0xOS43My0xMC4yM2gwYy00LjMxLTExLjcyLDMuMDYtMjQuNDgsMTUuMzYtMjYuNjFoMGM4LjQtMS40NSwxNi41MiwzLjc0LDE4LjczLDExLjk4bDEuMjgsNC43OGMxLjM3LDUuMTIsNC43Miw5LjQ5LDkuMzIsMTIuMTRoMGM1LjYsMy4yNCwxMi43NywxLjMyLDE2LTQuMjlMOTEuMy4yNVoiIHN0eWxlPSJmaWxsOiNmZmZmZmY7ICIvPjwvZz48L3N2Zz4=)](https://poing.github.io/JS2PySecrets/)
86

7+
# About
8+
9+
`js2pysecrets` is a port of the [`secrets.js-grempe`](https://github.com/grempe/secrets.js) JavaScript package to Python.
10+
11+
This package allows for cross-platform compatible shares, *generated using [Shamir's Secret Sharing](http://en.wikipedia.org/wiki/Shamir's_Secret_Sharing)*, to seamlessly interoperate between JavaScript and Python.
12+
13+
Function names and arguments used in the JavaScript package have been maintained for consistency and maintainability.
14+
15+
The functionality is essentially the same as the JavaScript package, with an exception around random number generation. Python doesn't have to adapt to different environments for random number generation like the JavaScript does.
16+
17+
*For additional details, see the [documentation](https://poing.github.io/JS2PySecrets/).*
18+
19+
20+
## Installation and Usage
21+
22+
Install the PyPI package:
23+
24+
```
25+
pip install js2pysecrets
26+
```
27+
28+
Import the library:
29+
30+
```
31+
import js2pysecrets as secrets
32+
```
33+
34+
### Examples
35+
36+
Divide a 512-bit key, expressed in hexadecimal form, into 10 shares, requiring that any 5 of them are necessary to reconstruct the original key:
37+
38+
```python
39+
import js2pysecrets as secrets
40+
41+
# generate a 512-bit key
42+
key = secrets.random(512)
43+
print(key) # => key is a hex string
44+
45+
# split into 10 shares with a threshold of 5
46+
shares = secrets.share(key, 10, 5)
47+
print(shares) # => ['801xxx...xxx','802xxx...xxx', ... ,'809xxx...xxx','810xxx...xxx']
48+
49+
# combine 4 shares
50+
comb = secrets.combine(shares[:4])
51+
print(comb == key) # => False
52+
53+
# combine 5 shares
54+
comb = secrets.combine(shares[:5])
55+
print(comb == key) # => True
56+
57+
# combine ALL shares
58+
comb = secrets.combine(shares)
59+
print(comb == key) # => True
60+
61+
# create another share with id 8
62+
new_share = secrets.newShare(8, shares)
63+
print(new_share) # => '808xxx...xxx'
64+
65+
# reconstruct using 4 original shares and the new share:
66+
comb = secrets.combine(shares[:4] + [new_share])
67+
print(comb == key) # => True
68+
```
969

70+
---
1071

1172
This is a `Python` implementation of [Shamir's threshold secret sharing scheme](http://en.wikipedia.org/wiki/Shamir's_Secret_Sharing), based **and compatible with** the `JavaScript` fork of `secrets.js` [*maintained by `grempe`*](https://github.com/grempe/secrets.js). Which is orginally based on the code created by `amper5and` on Github. The [original secrets.js can be found there](https://github.com/amper5and/secrets.js/).
1273

js2pysecrets/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
from .base import * # noqa
22

3+
init()
4+
35
# import .node # noqa

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def read_requirements(path):
3232
setup(
3333
name="js2pysecrets",
3434
version=read("js2pysecrets", "VERSION"),
35-
description="Shamir's Secret Sharing - Port of secrets.js-grempe to Python, allowing cross-platform compatable share usage between JavaScript and Python.",
35+
description="Shamir's Secret Sharing - A port of secrets.js-grempe to Python, allowing cross-platform compatable shares between JavaScript and Python.",
3636
url="https://github.com/poing/JS2PySecrets/",
3737
project_urls={
3838
'Documentation': 'https://poing.github.io/JS2PySecrets',

0 commit comments

Comments
 (0)