From 8a2a9c4399a49820f9869684922755045af7b65d Mon Sep 17 00:00:00 2001 From: arnaucube Date: Fri, 12 Apr 2019 10:13:54 +0200 Subject: [PATCH] add Create shares from secret with given parameters --- shamirsecretsharing.go | 73 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 shamirsecretsharing.go diff --git a/shamirsecretsharing.go b/shamirsecretsharing.go new file mode 100644 index 0000000..2d138d2 --- /dev/null +++ b/shamirsecretsharing.go @@ -0,0 +1,73 @@ +package shamirsecretsharing + +import ( + "crypto/rand" + "errors" + "math/big" +) + +const ( + // bits = 1024 + bits = 2048 +) + +// Create calculates the secrets to share from given parameters +// t: number of secrets needed +// n: number of shares +// p: random point +// k: secret to share +func Create(t, n, p, k *big.Int) (result [][]*big.Int, err error) { + if k.Cmp(p) > 0 { + return nil, errors.New("Error: need k