-
Notifications
You must be signed in to change notification settings - Fork 0
/
arith_test.go
57 lines (42 loc) · 979 Bytes
/
arith_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package avtc
import (
"fmt"
"math/big"
"testing"
)
func TestDecompose(t *testing.T) {
n := RandomGroupElement()
base := big.NewInt(0).Exp(big.NewInt(2), big.NewInt(WordSize), nil)
dec := Decompose(n, base)
m := Compose(dec, base)
if n.Cmp(m) != 0 {
panic("n != m")
}
}
func TestXtimesY(t *testing.T) {
base := big.NewInt(0).Exp(big.NewInt(2), big.NewInt(WordSize), nil)
x := RandomGroupElement()
y := RandomGroupElement()
z := big.NewInt(0).Mul(x, y)
X := Decompose(x, base)
Y := Decompose(y, base)
Z, _, _ := XmulY(X, Y, base)
z2 := Compose(Z, base)
if z.Cmp(z2) != 0 {
panic("z != z2")
}
}
func TestXplusY(t *testing.T) {
base := big.NewInt(0).Exp(big.NewInt(2), big.NewInt(WordSize), nil)
x := RandomGroupElement()
y := RandomGroupElement()
z := big.NewInt(0).Add(x, y)
X := Decompose(x, base)
Y := Decompose(y, base)
Z := XPlusY(X, Y, base)
z2 := Compose(Z, base)
if z.Cmp(z2) != 0 {
fmt.Println(z, z2)
panic("z != z2")
}
}