Last active
January 5, 2021 16:50
-
-
Save weissjeffm/5296372 to your computer and use it in GitHub Desktop.
Bitcoin private key sharing, with shamir's secret splitting using secrets.js and bitaddress.org
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//init - not sure if necessary | |
secrets.setRNG() | |
secrets.init(3) | |
//encode | |
secrets.share( | |
ninja.publicKey.getHexFromByteArray( | |
Bitcoin.Base58.decode("5HyLghwYt9hGVZVSuSJwpj2tgfUqWqdVd2jy7ZC45m55b8zAKeN")), | |
4, 2) | |
//where "5H..." is the private key, 4 is the number of shares, 2 is the threshhold | |
//output. put these codes in 4 separate places. | |
["uHMdmF9NJnG2ppKyo5XsnxtgLcD9JUyLF45Nk3fW74gfhagA3emwB", | |
"uLT3FKdQemTx5rLH9oE6iKJT9b1bxQ7P6SShXbRGzeAZaYYKeQYJ8", | |
"uNQ2fbF3RqQ2Y7PnCZPsm8iuYCQkJwGjKxTJoudva9YEK3fZ9hDZV", | |
"uS799uzDE2i9CobekBN7iMRF714UjWs85Csn7qSbGVVKRX3JFEibw"] | |
//decode | |
Bitcoin.Base58.encode( | |
Crypto.util.hexToBytes( | |
secrets.combine(["uHMdmF9NJnG2ppKyo5XsnxtgLcD9JUyLF45Nk3fW74gfhagA3emwB", "uLT3FKdQemTx5rLH9oE6iKJT9b1bxQ7P6SShXbRGzeAZaYYKeQYJ8"]. | |
map(Bitcoin.Base58.decode). | |
map(ninja.publicKey.getHexFromByteArray)))) | |
//where ["uH ...", "uL ..."] is the available shares (minimum threshhold) | |
//output | |
"5HyLghwYt9hGVZVSuSJwpj2tgfUqWqdVd2jy7ZC45m55b8zAKeN" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment