Is there an implementation of Shamir's Secret Sharing that can be regarded as a "canonical" (or "reference" or "standard") implementation, so that I can test other implementations to be "standard compliant"?
The above question is pretty vague. I have more details in mind, but some of them might be misleading or based on false assumptions. So possibly not all of them can be fulfilled or are relevant.
- I'm looking for a pure implementation of Shamir's Secret Sharing - pure means without additional (security) features.
- The input should be an array of bytes as secret, a threshold t and a number of shares n.
- The output should be n shares, where each share consists of the share number and an array of bytes of the same size as the secret.
- The algorithm should use GF(256). This is based on the following assumptions:
- When a field other than GF(256) is used for sharing, there is no guarantee that the secret can be reconstructed using GF(256).
- Requiring the use of GF(256) is enough to ensure that each correct split implementation will be compatible with any other correct join implementation. If this assumption is not complete - what is missing for a full specification of the method?
The motivation for this question is: I noticed that when I share a secret with implementation A, it is not sure I can reconstruct the secret with implementation B.
For example, "hello" shared with the implementation https://github.com/codahale/shamir has given me the shares
1-081dea6049
2-c869462a01
3-a811c02627
4-a8a0cc833b
5-c8d84a8f1d
// Implemented like:
Scheme scheme = new Scheme(new SecureRandom(), 5, 3);
Map<Integer, byte[]> split = scheme.split("hello".getBytes("UTF-8"));
Reconstructing the secret from shares 5, 2, 3 using https://github.com/codahale/shamir works fine, like this:
Scheme scheme = new Scheme(new SecureRandom(), 5, 3);
Map<Integer, byte[]> example = Map.of(
5, java.util.HexFormat.of().parseHex("c8d84a8f1d"),
2, java.util.HexFormat.of().parseHex("c869462a01"),
3, java.util.HexFormat.of().parseHex("a811c02627")
);
byte[] exampleJoined = scheme.join(example);
But reconstructing the secret from the same shares using the debian package "ssss" (http://point-at-infinity.org/ssss/, version v0.5, January 2006) gives me the byte array 056bcedfa2 (where I would have expected the bytes of "hello", i.e. 68656c6c6f):
> ssss-combine -t 3 -x -D
Enter 3 shares separated by newlines:
Share [1/3]: 5-c8d84a8f1d
Share [2/3]: 2-c869462a01
Share [3/3]: 3-a811c02627
Resulting secret: 056bcedfa2