Skip to content

Commit

Permalink
Better function naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff R. Allen committed Oct 11, 2018
1 parent ae279d9 commit f3dccc1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions share/poly.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (p *PriPoly) Coefficients() []kyber.Scalar {
// RecoverSecret reconstructs the shared secret p(0) from a list of private
// shares using Lagrange interpolation.
func RecoverSecret(g kyber.Group, shares []*PriShare, t, n int) (kyber.Scalar, error) {
x := xScalar(g, shares, t, n)
x := filterPriShares(g, shares, t, n)

if len(x) < t {
return nil, errors.New("share: not enough shares to recover secret")
Expand All @@ -199,7 +199,7 @@ func RecoverSecret(g kyber.Group, shares []*PriShare, t, n int) (kyber.Scalar, e
return acc, nil
}

func xScalar(g kyber.Group, shares []*PriShare, t, n int) map[int]kyber.Scalar {
func filterPriShares(g kyber.Group, shares []*PriShare, t, n int) map[int]kyber.Scalar {
x := make(map[int]kyber.Scalar)
for i, s := range shares {
if s == nil || s.V == nil || s.I < 0 || n <= s.I {
Expand All @@ -213,7 +213,7 @@ func xScalar(g kyber.Group, shares []*PriShare, t, n int) map[int]kyber.Scalar {
return x
}

func xMinusConst(g kyber.Group, c kyber.Scalar) *PriPoly {
func minusConst(g kyber.Group, c kyber.Scalar) *PriPoly {
neg := g.Scalar().Neg(c)
return &PriPoly{
g: g,
Expand All @@ -227,7 +227,7 @@ func xMinusConst(g kyber.Group, c kyber.Scalar) *PriPoly {
// shares to correctly re-construct the polynomial. There must be at least t
// shares.
func RecoverPriPoly(g kyber.Group, shares []*PriShare, t, n int) (*PriPoly, error) {
x := xScalar(g, shares, t, n)
x := filterPriShares(g, shares, t, n)
if len(x) != t {
return nil, errors.New("share: not enough shares to recover private polynomial")
}
Expand Down Expand Up @@ -458,7 +458,7 @@ func RecoverPubPoly(g kyber.Group, shares []*PubShare, t, n int) (*PubPoly, erro

// lagrangeBasis returns a PriPoly containing the Lagrange coefficients for the
// i-th position. xs is a mapping between the indices and the values that the
// interpolation is using, computed with xScalar().
// interpolation is using, computed with filterPriShares().
func lagrangeBasis(g kyber.Group, i int, xs map[int]kyber.Scalar) *PriPoly {
var basis = &PriPoly{
g: g,
Expand All @@ -471,7 +471,7 @@ func lagrangeBasis(g kyber.Group, i int, xs map[int]kyber.Scalar) *PriPoly {
if i == m {
continue
}
basis = basis.Mul(xMinusConst(g, xm))
basis = basis.Mul(minusConst(g, xm))
den.Sub(xs[i], xm) // den = xi - xm
den.Inv(den) // den = 1 / den
acc.Mul(acc, den) // acc = acc * den
Expand Down

0 comments on commit f3dccc1

Please sign in to comment.