Skip to content

Commit

Permalink
Create CLI tool & Readme updates
Browse files Browse the repository at this point in the history
Create a simple CLI tool that allows you to create shares of files and
recombine them. Document how to use it and the library.

Add goreleaser so I can release binaries for easy installation for
people who want to test this.
  • Loading branch information
jakecraige committed Jun 21, 2020
1 parent 947d509 commit 15508c5
Show file tree
Hide file tree
Showing 8 changed files with 356 additions and 102 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin
dist
tmp
27 changes: 27 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod download
builds:
- main: ./cmd/adss/adss.go
env:
- CGO_ENABLED=0
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ $(BIN)/%: | $(BIN) ; $(info $(M) building $(PACKAGE)…)
|| ret=$$?; \
git checkout go.mod go.sum; exit $$ret

GORELEASER = $(BIN)/goreleaser
$(BIN)/goreleaser: PACKAGE=github.com/goreleaser/goreleaser

GOIMPORTS = $(BIN)/goimports
$(BIN)/goimports: PACKAGE=golang.org/x/tools/cmd/goimports

Expand Down Expand Up @@ -56,7 +59,7 @@ check: check-fmt test-race ## Run all checks

.PHONY: clean
clean: ; $(info $(M) cleaning…) @ ## Cleanup everything
$Q rm -rf $(BIN)
$Q rm -rf $(BIN) dist

.PHONY: help
help:
Expand All @@ -66,3 +69,15 @@ help:
.PHONY: version
version:
@echo $(VERSION)

.PHONY: bin/adss
bin/adss: ## Build the adss binary to bin/adss
$(GO) build -o ./bin/adss ./cmd/adss

.PHONY: release/latest
release-latest: | $(GORELEASER) ## Compile and release the latest version
$(GORELEASER) --snapshot

.PHONY: release/test
release-test: | $(GORELEASER) @ ## Test creating a release build
$(GORELEASER) --snapshot --skip-publish --rm-dist
69 changes: 67 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,72 @@
# Adept Secret Sharing (ADSS)

An example implementation of adept secret sharing (ADSS) as described by
Bellare, Dai and Rogaway.
A CLI tool and library implementation of dept secret sharing (ADSS) as described
by Bellare, Dai and Rogaway.

## Usage

### CLI

Install by downloading pre-build binaries on the releases pages or it install
from source with `go install github.com/jakecraige/adss`.

```sh
# Split the secret into a 2-of-3 sharing. First we create a file with the
# secret, it can be of any type, not just txt.
$ echo "some secret" > /tmp/secret.txt
$ bin/adss split -threshold 2 -count 3 -out-dir /tmp -secret-path secret.txt
Share written to: tmp/share-0.json
Share written to: tmp/share-1.json
Share written to: tmp/share-2.json
Complete.

# We can recover by providing all shares. It prints to stdout in base64 by
# default, so we decode it with base64 for this example.
$ bin/adss recover --share-paths /tmp/share-0.json,/tmp/share-1.json,/tmp/share-2.json | base64 -d
some secret

# We can also store the result in a file
$ bin/adss recover --share-paths /tmp/share-0.json,/tmp/share-1.json,/tmp/share-2.json -out-path /tmp/recovered-secret.txt
$ cat /tmp/recovered-secret.txt
some secret

# We can also recover by providing only two
$ bin/adss recover --share-paths /tmp/share-0.json,/tmp/share-1.json | base64 -d
some secret

# If we manually modify the secret value of one of the shares and attempt
# recovery, we are warned about the invalid share but we still recover it.
$ bin/adss recover --share-paths /tmp/share-0.json,/tmp/share-1.json,/tmp/share-2-modified.json | base64 -d
WARN: Invalid share at ./tmp/share-2-modified.json
some secret
```

### Library

```golang
// Split the secret into shares. The shares can be json serialized with the
// golang marshaller to be persisted on disk.
as := adss.NewAccessStructure(2, 3)
secret := []byte("the secret")
ad := []byte("the associated data")
shares, err := adss.Share(as, secret, ad)
if err != nil {
return err
}

// Given a set of shares, attempt to recover the secret. If it can be recovered
// it returns the secret and the set of shares that were valid inputs. If it
// cannot be recovered, an error is returned.
secret, validShares, err := adss.Recover(shares)
if err != nil {
return err
}

fmt.Printf("%s", secret)
if len(validShares) < len(shares) {
fmt.Println("Some shares were invalid")
}
```

## Security

Expand Down
Loading

0 comments on commit 15508c5

Please sign in to comment.