-
Notifications
You must be signed in to change notification settings - Fork 9
/
fri_test.go
42 lines (30 loc) · 1.2 KB
/
fri_test.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
package zkstarks
import (
"testing"
"github.com/actuallyachraf/algebra/ff"
"github.com/actuallyachraf/algebra/poly"
"github.com/stretchr/testify/assert"
)
func TestFRIOperations(t *testing.T) {
t.Run("TestPolynomialIndexer", func(t *testing.T) {
p := poly.NewPolynomialInts(1, 2, 3, 4, 5, 6)
evenP := evenCoeffs(p)
oddP := oddCoeffs(p)
actualOddP := poly.NewPolynomialInts(2, 4, 6)
actualEvenP := poly.NewPolynomialInts(1, 3, 5)
assert.Equal(t, evenP, actualEvenP)
assert.Equal(t, oddP, actualOddP)
})
t.Run("TestNextFRILayer", func(t *testing.T) {
testPoly := poly.NewPolynomialInts(2, 3, 0, 1)
testDomain := []ff.FieldElement{PrimeField.NewFieldElementFromInt64(3), PrimeField.NewFieldElementFromInt64(5)}
beta := PrimeField.NewFieldElementFromInt64(7)
nextDomain, nextPoly, nextLayer := NextFRILayer(testDomain, testPoly, beta)
actualNextPoly := poly.NewPolynomialInts(23, 7)
actualNextDomain := []ff.FieldElement{PrimeField.NewFieldElementFromInt64(9)}
actualNextLayer := []ff.FieldElement{PrimeField.NewFieldElementFromInt64(86)}
assert.Equal(t, nextPoly, actualNextPoly)
assert.Equal(t, nextDomain, actualNextDomain)
assert.Equal(t, nextLayer, actualNextLayer)
})
}