forked from kilic/bls12-381
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fp_lazy.go
83 lines (66 loc) · 1.25 KB
/
fp_lazy.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
// +build !nolazy
package bls
import (
"golang.org/x/sys/cpu"
)
type fp struct {
mul func(c, a, b *fe)
mulAssign func(a, b *fe)
lmul func(c *lfe, a, b *fe)
reduce func(c *fe, a *lfe)
}
func newFp() *fp {
if cpu.X86.HasBMI2 && !enforceNonBMI2 {
return &fp{
mul: montmul_bmi2,
mulAssign: montmul_assign_bmi2,
lmul: mul_bmi2,
reduce: mont_bmi2,
}
}
return &fp{
mul: montmul_nobmi2,
mulAssign: montmul_assign_nobmi2,
lmul: mul_nobmi2,
reduce: mont_nobmi2,
}
}
func (f *fp) zero12() *lfe {
return &lfe{}
}
func (f *fp) lcopy(dst, src *lfe) {
dst.Set(src)
}
func (f *fp) copyMixed(dst *lfe, src *fe) {
dst.SetSingle(src)
}
func (f *fp) add12(c, a, b *lfe) {
add12(c, a, b)
}
func (f *fp) addAssign12(a, b *lfe) {
add_assign_12(a, b)
}
func (f *fp) ladd12(c, a, b *lfe) {
ladd12(c, a, b)
}
func (f *fp) double12(c, a *lfe) {
double12(c, a)
}
func (f *fp) doubleAssign12(a *lfe) {
double_assign_12(a)
}
func (f *fp) ldouble12(c, a *lfe) {
ldouble12(c, a)
}
func (f *fp) sub12(c, a, b *lfe) {
sub12(c, a, b)
}
func (f *fp) subAssign12(a, b *lfe) {
sub_assign_12(a, b)
}
func (f *fp) lsub12(c, a, b *lfe) {
lsub12(c, a, b)
}
func (f *fp) lsubAssign12(a, b *lfe) {
lsub_assign_12(a, b)
}