-
Notifications
You must be signed in to change notification settings - Fork 0
/
activityWrap.go
65 lines (54 loc) · 1018 Bytes
/
activityWrap.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
58
59
60
61
62
63
64
65
package txhelper
// #cgo CFLAGS: -g -Wall
// #cgo LDFLAGS: -lcrypto
// #include <stdlib.h>
// #include <stdint.h>
// #include <openssl/bn.h>
import "C"
import (
"bytes"
"fmt"
)
// We use OpenSSL/BN, hence this only tests the cgo code.
func privateCtestWrap() bool {
ctx := NewContext(100, 1, 5, 1, 32, 3, 2, 3, 1, false, 2)
a := make([]byte, 33)
b := make([]byte, 33)
expectedC := make([]byte, 33)
expectedC[32] = 4
a[32] = 8
b[32] = 2
c := ctx.ModDiv(a, b)
if !bytes.Equal(c, expectedC) {
fmt.Println("point 1")
return false
}
a[32] = 4
a[31] = 1
b[32] = 4
expectedC[32] = 65
c = ctx.ModDiv(a, b)
if !bytes.Equal(c, expectedC) {
fmt.Println("point 2")
return false
}
a[32] = 4
a[31] = 0
b[32] = 4
expectedC[32] = 16
c = ctx.ModMul(a, b)
if !bytes.Equal(c, expectedC) {
fmt.Println("point 3")
return false
}
a[32] = 16
a[31] = 0
b[32] = 16
expectedC[32] = 0
expectedC[31] = 1
c = ctx.ModMul(a, b)
if !bytes.Equal(c, expectedC) {
return false
}
return true
}