diff --git a/.gitignore b/.gitignore index 2b000c8..624a59e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,8 @@ node_modules test .c9revisions -index.html \ No newline at end of file +index.html +*~ +secret-gen.js +shares.txt +*-share.html diff --git a/README.md b/README.md index 0e2cfc9..55b5f74 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,10 @@ To use it in node.js: To use it in the browser, include *secrets.js* or *secrets.min.js* (minified using Google Closure Compiler) + +To create stand-alone HTML files that each contain one share of a secret, plus a form with an in-line copy of secrets.js to recover the secret: + make-secret-shares.sh ## API @@ -232,4 +235,4 @@ secrets.js is released under the MIT License. See `LICENSE`. * Operate on [node.js streams](http://nodejs.org/api/stream.html) * [Cheater-detection](http://h.web.umkc.edu/harnl/papers/J68.pdf) * [Dynamic threshold](http://www1.spms.ntu.edu.sg/~ctartary/Dynamic_Threshold_INSCRYPT2006.pdf) -* Investigate speed enhancements in polynomial evaluation and polynomial interpolation \ No newline at end of file +* Investigate speed enhancements in polynomial evaluation and polynomial interpolation diff --git a/make-secret-shares.sh b/make-secret-shares.sh new file mode 100755 index 0000000..2f687b5 --- /dev/null +++ b/make-secret-shares.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash + +echo "name your secret: "; +read name; + +echo "enter secret: "; +read secret; + +echo "enter names of shares, separated by spaces: "; +read shares; + +sharect=$(echo $shares | tr ' ' '\n' | wc -l); + +echo "how many of the $sharect shares ($shares) are required to recover the $name secret?"; +read threshold; + +#construct a js file that will generate and print the shares + +#stub out just enough of the browser environment +#expected by secrets.js to get things working +cat > secret-gen.js <> secret-gen.js; +echo >> secret-gen.js; + +cat >> secret-gen.js < shares.txt + +rm -f ${name}-*-share.html + +for i in $(seq 1 $sharect); do + share=$(head -n $i shares.txt | tail -n 1); + sharename=$(echo $shares | tr ' ' '\n' | head -n $i | tail -n 1); + sharefile="${name}-${sharename}-share.html"; + + cat > ${sharefile} <Share ${sharename} of ${name} + + + +

Shared Secret "${name}"

+

This secret was split into ${sharect} "shares". Any ${threshold} of those can be combined to recover the secret.

+

Your share (labeled "${sharename}") is: ${share}

+

You can send your share to someone else to help them recover the secret.

+

Or, you can get shares from others and enter them below (in any order) to recover the secret yourself.

+
+EOF + + for i in $(seq 2 ${threshold}); do + echo "

" >> ${sharefile} + done; + + cat >> ${sharefile} < + + + +EOF + +done + +rm secret-gen.js shares.txt; + +echo; +echo "shares generated in the following files:"; +ls ${name}-*-share.html; +echo; +echo "so long as $threshold of these files remain together, your secret is exposed!";