File: double.go

package info (click to toggle)
golang-github-tscholl2-siec 0.0~git20210707.9bdfc48-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 360 kB
  • sloc: makefile: 3
file content (20 lines) | stat: -rw-r--r-- 460 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package ff

var (
	doublep = Element{0xfff3ff3cf6e79f3d, 0x7fffffffffffffff, 0xfffffffff9ffcf3e, 0x3fffffffffffffff}
)

// Note: only works if 2*a < 2^256. One way to garuntee this works is:
//
//    b := double(a)
//    if a[3]>>63 == 0 {
//      b = add(doublep, normalize(a))
//    }
//
func double(a Element) (b Element) {
	b[0] = a[0] << 1
	b[1] = (a[1] << 1) | (a[0] >> 63)
	b[2] = (a[2] << 1) | (a[1] >> 63)
	b[3] = (a[3] << 1) | (a[2] >> 63)
	return
}