Shamir's Secret Sharing
The cli provides an example of using Share
with multiple types and multiple values
$ echo Some text to split > input.txt
$ swift run Share split -c 3 -n 2 -s 0 -i input.txt -o share.%.txt
$ swift run Share merge -o output.txt share.2.txt share.1.txt
$ xxd input.txt
00000000: 536f 6d65 2074 6578 7420 746f 2073 706c Some text to spl
00000010: 6974 0a it.
$ xxd output.txt
00000000: 536f 6d65 2074 6578 7420 746f 2073 706c Some text to spl
00000010: 6974 0a00 00 it...
$ swift run Share split
Missing count
OPTIONS:
--count, -c <value> Number of parts to create
--needed, -n <value> Number of parts needed
--security, -s <value> The security level (0,1,2,3,4,5,9)
--input, -i <value> Input file
--output, -o <value> Output file pattern (A%B.txt -> A1B.txt, A2B.txt)
--help, -h
$ swift run Share merge
Usage: Share merge <options> <input...>
OPTIONS:
--output, -o <value> Output file
.package(url: "https://github.com/DavidSkrundz/Share.git", .upToNextMinor(from: "1.0.0"))
Provides split
and join
to either create a list of shares into a value, or combine a list of shares into a value:
static func split(value: T, count: Int, needed: Int) -> [Share]
static func join<S: RandomAccessCollection>(shares: S) -> T where S.Element == Share, S.Index == Int