mirror of
https://github.com/luxfi/threshold.git
synced 2026-10-30 15:15:53 +00:00
- Fix go vet error in lss_bench_test.go: replace b.Fatal with panic in goroutine - Fix go vet error in lss_test.go: remove t.Skip call from goroutine - Apply gofmt to all files to fix formatting issues All go vet errors and formatting issues have been resolved.
32 lines
760 B
Go
32 lines
760 B
Go
package polynomial_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/cronokirby/saferith"
|
|
"github.com/luxfi/threshold/internal/test"
|
|
"github.com/luxfi/threshold/pkg/math/curve"
|
|
"github.com/luxfi/threshold/pkg/math/polynomial"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestLagrange(t *testing.T) {
|
|
group := curve.Secp256k1{}
|
|
|
|
N := 10
|
|
allIDs := test.PartyIDs(N)
|
|
coefsEven := polynomial.Lagrange(group, allIDs)
|
|
coefsOdd := polynomial.Lagrange(group, allIDs[:N-1])
|
|
sumEven := group.NewScalar()
|
|
sumOdd := group.NewScalar()
|
|
one := group.NewScalar().SetNat(new(saferith.Nat).SetUint64(1))
|
|
for _, c := range coefsEven {
|
|
sumEven.Add(c)
|
|
}
|
|
for _, c := range coefsOdd {
|
|
sumOdd.Add(c)
|
|
}
|
|
assert.True(t, sumEven.Equal(one))
|
|
assert.True(t, sumOdd.Equal(one))
|
|
}
|