• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created about 6 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

python-shamir-mnemonic

Reference implementation of SLIP-0039: Shamir's Secret-Sharing for Mnemonic Codes

Abstract

This SLIP describes a standard and interoperable implementation of Shamir's secret sharing (SSS). SSS splits a secret into unique parts which can be distributed among participants, and requires a specified minimum number of parts to be supplied in order to reconstruct the original secret. Knowledge of fewer than the required number of parts does not leak information about the secret.

Specification

See https://github.com/satoshilabs/slips/blob/master/slip-0039.md for full specification.

Security

This implementation is not using any hardening techniques. Secrets are passed in the open, and calculations are most likely trivially vulnerable to side-channel attacks.

The purpose of this code is to verify correctness of other implementations. It should not be used for handling sensitive secrets.

Installation

With pip from GitHub:

$ pip3 install shamir-mnemonic

From local checkout for development:

$ python3 setup.py develop

CLI usage

CLI tool is included as a reference and UX testbed.

Warning: this tool makes no attempt to protect sensitive data! Use at your own risk. If you need this to recover your wallet seeds, make sure to do it on an air-gapped computer, preferably running a live system such as Tails.

When the shamir_mnemonic package is installed, you can use the shamir command:

$ shamir create 3of5   # create a 3-of-5 set of shares
$ shamir recover       # interactively recombine shares to get the master secret

You can supply your own master secret as a hexadecimal string:

$ shamir create 3of5 --master-secret=cb21904441dfd01a392701ecdc25d61c

You can specify a custom scheme. For example, to create three groups, with 2-of-3, 2-of-5, and 4-of-5, and require completion of all three groups, use:

$ shamir create custom --group-threshold 3 --group 2 3 --group 2 5 --group 4 5

Use shamir --help or shamir create --help to see all available options.

If you want to run the CLI from a local checkout without installing, use the following command:

$ python3 -m shamir_mnemonic.cli

Test vectors

The test vectors in vectors.json are given as a list of triples. The first member of the triple is a description of the test vector, the second member is a list of mnemonics and the third member is the master secret which results from combining the mnemonics. The master secret is encoded as a string containing two hexadecimal digits for each byte. If the string is empty, then attempting to combine the given set of mnemonics should result in error. The passphrase "TREZOR" is used for all valid sets of mnemonics.

More Repositories

1

trezor-firmware

πŸ”’ Trezor Firmware Monorepo
C
1,286
star
2

python-mnemonic

🐍 Mnemonic code for generating deterministic keys, BIP39
Python
762
star
3

trezor-suite

🍬 Trezor Suite Monorepo
TypeScript
619
star
4

blockbook

πŸ“˜ Trezor address/account balance backend
Go
585
star
5

trezor-crypto

πŸ”’ Don't use this repo, use the new monorepo instead:
C
493
star
6

trezor-core

πŸ”’ Don't use this repo, use the new monorepo instead:
Python
353
star
7

connect

πŸ”— A platform for easy integration of Trezor into 3rd party services
JavaScript
350
star
8

trezor-mcu

πŸ”’ Don't use this repo, use the new monorepo instead:
C
318
star
9

cython-hidapi

🐍 Python wrapper for the HIDAPI
Cython
255
star
10

trezord-go

😈 Trezor Communication Daemon (written in Go)
C
226
star
11

python-trezor

🐍 Don't use this repo, use the new monorepo instead:
Python
203
star
12

trezor-hardware

πŸ”§ Hardware design of Trezor
171
star
13

trezor.js

⚠️ OBSOLETE. DO NOT USE! Use https://github.com/trezor/connect instead
JavaScript
95
star
14

trezor-common

πŸ”’ Don't post issues/PRs to here, use the new monorepo:
Python
89
star
15

trezor-android

πŸ“± TREZOR Communication Library for Android
Java
78
star
16

hd-wallet

πŸ’° High-performance Bitcoin HD Wallet in Javascript
JavaScript
56
star
17

trezor-password-manager

Password Management via TREZOR
SCSS
42
star
18

data

πŸ“¦ Data files for Trezor
HTML
39
star
19

trezor-wallet

⚠️ OBSOLETE. DO NOT USE! Use https://github.com/trezor/trezor-suite instead
JavaScript
29
star
20

trezor-user-env

Development tool for Trezor developers
Python
24
star
21

trezor-link

Javascript module for integrating TREZOR into Node.js and web applications.
TypeScript
18
star
22

connect-explorer

Connect Examples
JavaScript
12
star
23

trezor-suite-guide

User Guide present in Trezor Suite
11
star
24

rng-test

🎲 Random Number Generator (RNG) tests
C
10
star
25

community

πŸ‘« TREZOR Developer Community Discussion
9
star
26

trezor-ui-components

⚠️ OBSOLETE. DO NOT USE! Use https://github.com/trezor/trezor-suite instead
JavaScript
9
star
27

trezor-storage

πŸ”’ Don't use this repo, use the new monorepo instead:
C
9
star
28

coinjoin-backend

Python
6
star
29

omni-trezor

OMNI Wallet for Trezor
JavaScript
6
star
30

ui

🍺 User Interface Mockups and Experiments
HTML
6
star
31

trezor-rollout

⚠️ OBSOLETE. DO NOT USE! Use https://github.com/trezor/trezor-suite instead
JavaScript
5
star
32

trezor-test-scenarios

Python
5
star
33

trezor-core-ui

HTML
5
star
34

trezor-storage-test

πŸ”’ Don't use this repo, use the new monorepo instead:
Python
4
star
35

trezor-onboarding

⚠️ OBSOLETE. DO NOT USE! Use https://github.com/trezor/trezor-suite instead
TypeScript
4
star
36

.github

4
star
37

trezor-flags

JavaScript
4
star
38

trezor-translations-manager

⚠️ OBSOLETE. DO NOT USE! Use https://github.com/trezor/trezor-suite instead
JavaScript
3
star
39

trezor-blockchain-link

⚠️ OBSOLETE. DO NOT USE! Use https://github.com/trezor/trezor-suite instead
TypeScript
3
star
40

upysize

Tool for decreasing the size of compiled micropython code
Python
3
star
41

trezor-docker-images

Collection of docker images and configurations used across various trezor projects.
Dockerfile
2
star
42

binsize

Tool to analyze the size of a binary from .elf file
Python
2
star
43

definitions

Python
1
star