/
math.go
86 lines (78 loc) · 1.24 KB
/
math.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package driver
import (
"io"
)
type Curve interface {
Pairing(G2, G1) Gt
Pairing2(p2a, p2b G2, p1a, p1b G1) Gt
FExp(Gt) Gt
ModMul(a1, b1, m Zr) Zr
ModNeg(a1, m Zr) Zr
GenG1() G1
GenG2() G2
GenGt() Gt
GroupOrder() Zr
FieldBytes() int
NewG1() G1
NewG2() G2
NewG1FromCoords(ix, iy Zr) G1
NewZrFromBytes(b []byte) Zr
NewZrFromInt(i int64) Zr
NewG1FromBytes(b []byte) G1
NewG2FromBytes(b []byte) G2
NewGtFromBytes(b []byte) Gt
ModAdd(a, b, m Zr) Zr
ModSub(a, b, m Zr) Zr
HashToZr(data []byte) Zr
HashToG1(data []byte) G1
NewRandomZr(rng io.Reader) Zr
Rand() (io.Reader, error)
}
type Zr interface {
Plus(Zr) Zr
Mul(Zr) Zr
Mod(Zr)
PowMod(Zr) Zr
InvModP(Zr)
Bytes() []byte
Equals(Zr) bool
Copy() Zr
Clone(a Zr)
String() string
}
type G1 interface {
Clone(G1)
Copy() G1
Add(G1)
Mul(Zr) G1
Mul2(e Zr, Q G1, f Zr) G1
Equals(G1) bool
Bytes() []byte
Sub(G1)
IsInfinity() bool
String() string
}
type G2 interface {
Clone(G2)
Copy() G2
Mul(Zr) G2
Add(G2)
Sub(G2)
Affine()
Bytes() []byte
String() string
Equals(G2) bool
}
type Gt interface {
Equals(Gt) bool
Inverse()
Mul(Gt)
IsUnity() bool
ToString() string
Bytes() []byte
Exp(Zr) Gt
}