2018-12-03 23:07:01 +00:00
|
|
|
// +build amd64,!noasm arm64,!noasm
|
2018-07-23 23:18:38 +01:00
|
|
|
|
2018-09-11 12:02:29 +01:00
|
|
|
package p751
|
|
|
|
|
|
|
|
import . "github.com/henrydcase/nobs/dh/sidh/internal/isogeny"
|
2018-07-23 23:18:38 +01:00
|
|
|
|
|
|
|
// If choice = 0, leave x,y unchanged. If choice = 1, set x,y = y,x.
|
|
|
|
// If choice is neither 0 nor 1 then behaviour is undefined.
|
|
|
|
// This function executes in constant time.
|
|
|
|
//go:noescape
|
2018-09-11 12:02:29 +01:00
|
|
|
func fp751ConditionalSwap(x, y *FpElement, choice uint8)
|
2018-07-23 23:18:38 +01:00
|
|
|
|
|
|
|
// Compute z = x + y (mod p).
|
|
|
|
//go:noescape
|
2018-09-11 12:02:29 +01:00
|
|
|
func fp751AddReduced(z, x, y *FpElement)
|
2018-07-23 23:18:38 +01:00
|
|
|
|
|
|
|
// Compute z = x - y (mod p).
|
|
|
|
//go:noescape
|
2018-09-11 12:02:29 +01:00
|
|
|
func fp751SubReduced(z, x, y *FpElement)
|
2018-07-23 23:18:38 +01:00
|
|
|
|
|
|
|
// Compute z = x + y, without reducing mod p.
|
|
|
|
//go:noescape
|
2018-09-11 12:02:29 +01:00
|
|
|
func fp751AddLazy(z, x, y *FpElement)
|
2018-07-23 23:18:38 +01:00
|
|
|
|
|
|
|
// Compute z = x + y, without reducing mod p.
|
|
|
|
//go:noescape
|
2018-09-11 12:02:29 +01:00
|
|
|
func fp751X2AddLazy(z, x, y *FpElementX2)
|
2018-07-23 23:18:38 +01:00
|
|
|
|
|
|
|
// Compute z = x - y, without reducing mod p.
|
|
|
|
//go:noescape
|
2018-09-11 12:02:29 +01:00
|
|
|
func fp751X2SubLazy(z, x, y *FpElementX2)
|
2018-07-23 23:18:38 +01:00
|
|
|
|
|
|
|
// Compute z = x * y.
|
|
|
|
//go:noescape
|
2018-09-11 12:02:29 +01:00
|
|
|
func fp751Mul(z *FpElementX2, x, y *FpElement)
|
2018-07-23 23:18:38 +01:00
|
|
|
|
2018-12-03 23:07:01 +00:00
|
|
|
// Compute Montgomery reduction: set z = x * R^{-1} (mod 2*p).
|
|
|
|
// It may destroy the input value.
|
2018-07-23 23:18:38 +01:00
|
|
|
//go:noescape
|
2018-09-11 12:02:29 +01:00
|
|
|
func fp751MontgomeryReduce(z *FpElement, x *FpElementX2)
|
2018-07-23 23:18:38 +01:00
|
|
|
|
|
|
|
// Reduce a field element in [0, 2*p) to one in [0,p).
|
|
|
|
//go:noescape
|
2018-09-11 12:02:29 +01:00
|
|
|
func fp751StrongReduce(x *FpElement)
|