You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

43 line
1.1 KiB

  1. // +build amd64,!noasm
  2. package p751toolbox
  3. // If choice = 0, leave x,y unchanged. If choice = 1, set x,y = y,x.
  4. // If choice is neither 0 nor 1 then behaviour is undefined.
  5. // This function executes in constant time.
  6. //go:noescape
  7. func fp751ConditionalSwap(x, y *Fp751Element, choice uint8)
  8. // Compute z = x + y (mod p).
  9. //go:noescape
  10. func fp751AddReduced(z, x, y *Fp751Element)
  11. // Compute z = x - y (mod p).
  12. //go:noescape
  13. func fp751SubReduced(z, x, y *Fp751Element)
  14. // Compute z = x + y, without reducing mod p.
  15. //go:noescape
  16. func fp751AddLazy(z, x, y *Fp751Element)
  17. // Compute z = x + y, without reducing mod p.
  18. //go:noescape
  19. func fp751X2AddLazy(z, x, y *fp751X2)
  20. // Compute z = x - y, without reducing mod p.
  21. //go:noescape
  22. func fp751X2SubLazy(z, x, y *fp751X2)
  23. // Compute z = x * y.
  24. //go:noescape
  25. func fp751Mul(z *fp751X2, x, y *Fp751Element)
  26. // Perform Montgomery reduction: set z = x R^{-1} (mod 2*p).
  27. // Destroys the input value.
  28. //go:noescape
  29. func fp751MontgomeryReduce(z *Fp751Element, x *fp751X2)
  30. // Reduce a field element in [0, 2*p) to one in [0,p).
  31. //go:noescape
  32. func fp751StrongReduce(x *Fp751Element)