Skip to content

Commit

Permalink
update command:
Browse files Browse the repository at this point in the history
* change `open-share` command name to `reveal-share`;
* change extention to `.secret-share` instead of just `.share`
  • Loading branch information
NicolasDP committed Feb 19, 2018
1 parent b7d8512 commit 3599462
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions README.md
Expand Up @@ -49,12 +49,12 @@ sharesafe pvss new --secret encryption.key --threshold 2 --participant rick.pub
This command will create:

* a share secret and will convert it into a **ChaChaPoly1305** compatible encryption key `encryption.key` (see below);
* for every participant a `.share` file is created:
* `rick.share`: rick's share, encrypted with its public key (only rick's private key can unlock the share);
* `morty.share`: morty's share, encrypted with its public key (only morty's private key can unlock the share);
* `jerry.share`: jerry's share, encrypted with its public key (only jerry's private key can unlock the share);
* for every participant a `.secret-share` file is created:
* `rick.secret-share`: rick's share, encrypted with its public key (only rick's private key can unlock the share);
* `morty.secret-share`: morty's share, encrypted with its public key (only morty's private key can unlock the share);
* `jerry.secret-share`: jerry's share, encrypted with its public key (only jerry's private key can unlock the share);

> the `.share` files can safely be shared over any support, secured or not.
> the `.secret-share` files can safely be shared over any support, secured or not.
> They are encrypted a way only the owner of the private key can open it.
In this command, the `threshold` is the minimum number of _opened shares_ needed
Expand All @@ -63,17 +63,17 @@ to recover the `encryption.key`. See next command.
#### Recover a secret

To recover a shared secret, we need _n_ participants (`threshold`) to open
their `.share`.
their `.secret-share`.

```shell
sharesafe pvss open-share -share rick.share --key rick.key --password "c-137" -o rick.opened-share
sharesafe pvss reveal-share -share rick.secret-share --key rick.key --password "c-137" -o rick.revealed-share
```

In the example above we set the threshold to 2 participants, so to retrieve the
secret (`encryption.key`):

```shell
sharesafe pvss recover --share rick.opened-share --share morty.opened-share -o encryption.key
sharesafe pvss recover --share rick.revealed-share --share morty.revealed-share -o encryption.key
```

#### Use the generated/recovered to encrypt or decrypt a file
Expand Down
6 changes: 3 additions & 3 deletions app/Main.hs
Expand Up @@ -274,7 +274,7 @@ pvssSubProgram = do

pvssNewShareSubProgram :: OptionDesc (IO ()) ()
pvssNewShareSubProgram = command "new" $ do
description "generate a new share secret. The Participant's shares are generated based on the participants's public key filename. (filename -<.> share)"
description "generate a new share secret. The Participant's shares are generated based on the participants's public key filename. (filename -<.> secret-share)"
pkssf <- flagMany $ flagParam (FlagShort 'p' <> FlagLong "participant" <> FlagDescription "Public key of the participants")
(FlagRequired (Right . fromString))
thresholdf <- flagParam (FlagShort 't' <> FlagLong "threshold" <> FlagDescription "Threshold to retrive the secrets (default: 1)")
Expand All @@ -301,7 +301,7 @@ pvssNewShareSubProgram = command "new" $ do
withFileOr (toParam outf) WriteMode stdout $ \h ->
hPut h (B.convertToBase B.Base64 ek)
forM_ (zip pkss shares) $ \(fp, share) ->
let fp' = fromString $ filePathToLString fp -<.> "share"
let fp' = fromString $ filePathToLString fp -<.> "secret-share"
in withFile fp' WriteMode $ flip hPut (convert $ encodeJSON share)

pvssVerifyShareSubProgram :: OptionDesc (IO ()) ()
Expand All @@ -321,7 +321,7 @@ pvssVerifyShareSubProgram = command "verify" $ do
unless (verifyShare commitments share) $ error "invalid share"

pvssOpenShareSubProgram :: OptionDesc (IO ()) ()
pvssOpenShareSubProgram = command "open-share" $ do
pvssOpenShareSubProgram = command "reveal-share" $ do
description "open the given share"
sharef <- flagParam (FlagShort 's' <> FlagLong "share" <> FlagDescription "Share to verify participant")
(FlagRequired (Right . fromString))
Expand Down
12 changes: 6 additions & 6 deletions tests/sharesafe-test.sh
Expand Up @@ -34,14 +34,14 @@ ${CMD} pvss new -p rick.pub -p morty.pub -p jerry.pub \
-c commitments \
-o encryption-key

${CMD} pvss verify -s rick.share -c commitments
${CMD} pvss verify -s morty.share -c commitments
${CMD} pvss verify -s jerry.share -c commitments
${CMD} pvss verify -s rick.secret-share -c commitments
${CMD} pvss verify -s morty.secret-share -c commitments
${CMD} pvss verify -s jerry.secret-share -c commitments

${CMD} pvss open-share -s rick.share -k rick.key -o rick.opened-share
${CMD} pvss open-share -s morty.share -k morty.key -o morty.opened-share
${CMD} pvss reveal-share -s rick.secret-share -k rick.key -o rick.revealed-share
${CMD} pvss reveal-share -s morty.secret-share -k morty.key -o morty.revealed-share

${CMD} pvss recover -s $(cat rick.opened-share) -s $(cat morty.opened-share) \
${CMD} pvss recover -s $(cat rick.revealed-share) -s $(cat morty.revealed-share) \
-o encryption-key.recovered

test $(cat encryption-key) = $(cat encryption-key.recovered)
Expand Down

0 comments on commit 3599462

Please sign in to comment.