-
Notifications
You must be signed in to change notification settings - Fork 2
/
discrete_logarithm_test.go
44 lines (34 loc) · 845 Bytes
/
discrete_logarithm_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
package gontl
import(
"testing"
"math/big"
"log"
)
func TestPollardRho(t *testing.T){
// test Pollard Rho
problem := SetScalar(549862755487)
modulus := SetScalar(1127698306139)
order := SetScalar(563849153069)
secret := SetScalar(150672668021)
//fmt.Println("testing Pollard Rho, secret to find is", secret)
result := Pollard_Rho(problem, Big2, modulus, order, Big0, Big0)
//fmt.Println("secret found:", result)
if result.Cmp(secret) != 0 {
t.Error("Expected", secret, ", got ", result)
}
}
func Test2CRT(t *testing.T){
x := SetScalar(39248302948940234)
p := SetScalar(2706403677983)
q := SetScalar(2402895179297)
n := new(big.Int)
n.Mul(p, q)
xp := new(big.Int)
xp.Mod(x, p)
xq := new(big.Int)
xq.Mod(x, q)
result := CRT2(xp, xq, p, q)
if result.Cmp(x) != 0 {
t.Error("Expected", x, ", got ", result)
}
}