Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

42 linhas
945 B

  1. package p751toolbox
  2. import (
  3. . "github.com/cloudflare/p751sidh/internal/utils"
  4. )
  5. type context struct {
  6. xPA, xQA, xRA ProjectivePoint
  7. xPB, xQB, xRB ProjectivePoint
  8. xR ProjectivePoint
  9. curve ProjectiveCurveParameters
  10. }
  11. func (c *context) LoadBasePoints() {
  12. // Load points for A
  13. c.xPA.FromAffine(&P751_affine_PA)
  14. c.xPA.Z.One()
  15. c.xQA.FromAffine(&P751_affine_QA)
  16. c.xQA.Z.One()
  17. c.xRA.FromAffine(&P751_affine_RA)
  18. c.xRA.Z.One()
  19. // Load points for B
  20. c.xRB.FromAffine(&P751_affine_RB)
  21. c.xRB.Z.One()
  22. c.xQB.FromAffine(&P751_affine_QB)
  23. c.xQB.Z.One()
  24. c.xPB.FromAffine(&P751_affine_PB)
  25. c.xPB.Z.One()
  26. }
  27. func (c *context) ScalarMul(scalar []byte, sz uint) {
  28. c.curve.A.Zero()
  29. c.curve.C.One()
  30. // OZAPTF: PA QA RA -> PB QB ... if used for B
  31. c.xR = RightToLeftLadder(&tmp, &c.xPA, &c.xQA, &c.xRA, sz, scalar)
  32. }
  33. func NewCtx() OperationContext {
  34. return new(context)
  35. }