-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecretpart.go
54 lines (45 loc) · 1.72 KB
/
secretpart.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) Pedersen authors.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
package pedersen
import (
"encoding/json"
"github.com/matteoarella/pedersen/big"
)
// SecretPart represents a secret part associated to a shareholder.
type SecretPart struct {
SShare *big.Int
TShare *big.Int
}
// Shares represents the shares obtained from splitting a secret.
type Shares struct {
// Abscissae is the abscissae vector used for computing the ordinate values of
// the secret parts.
// There is one abscissa for each shareholder, so if shareholderIdx represents
// the index of one shareholder, Abscissae[shareholderIdx] is the abscissa
// related to that shareholder.
Abscissae []*big.Int
// Parts is the matrix of secret parts.
// If the secret that has to be split is not representable in the cyclic group,
// the secret is split into chunks, and each chunk is split into secret parts according
// to Pedersen verifiable secret sharing.
// The first index of Parts represents the shareholder index, while the second index
// represents the chunk index (Parts[shareholderIdx][chunkIdx]).
Parts [][]SecretPart
// Commitments is the matrix of commitments.
// The first index of Commitments represents the chunk index so Commitments[chunkIdx]
// is the vector of commitments related to the chunk with index chunkIdx.
Commitments [][]*big.Int
}
// Returns a string representation of a SecretPart struct.
func (p *SecretPart) String() string {
data, _ := json.Marshal(p)
return string(data)
}
// Returns a string representation of a Shares struct.
func (s *Shares) String() string {
data, _ := json.Marshal(s)
return string(data)
}