Skip to content

Instantly share code, notes, and snippets.

@brimston3
Created September 13, 2017 20:39
Show Gist options
  • Save brimston3/951e2e9d598654b855906e919eb2f853 to your computer and use it in GitHub Desktop.
Save brimston3/951e2e9d598654b855906e919eb2f853 to your computer and use it in GitHub Desktop.
shamir's secret sharing with libgfshare-bin
#!/bin/sh
##
# Briefly demonstrate splitting a key with libgfshare-bin
# This breaks the key into M parts, N of which are needed for key recovery.
rm -vf key key.[2345] gfkey.*
dd if=/dev/urandom of=key bs=4k count=1
echo
sha256sum key
# default is 3-of-5
gfsplit key gfkey
for each in $(seq 2 5); do
keyparts=$(ls gfkey.* | sort -R | head -3 | tr $'\n' ' ' ; echo)
gfcombine -o key.$each $keyparts
echo -n $(sha256sum key.$each) " "
echo $keyparts
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment