DoubleAddMultiplier.cs 773 B

12345678910111213141516171819202122232425262728293031
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Multiplier
  5. {
  6. public class DoubleAddMultiplier
  7. : AbstractECMultiplier
  8. {
  9. /**
  10. * Joye's double-add algorithm.
  11. */
  12. protected override ECPoint MultiplyPositive(ECPoint p, BigInteger k)
  13. {
  14. ECPoint[] R = new ECPoint[]{ p.Curve.Infinity, p };
  15. int n = k.BitLength;
  16. for (int i = 0; i < n; ++i)
  17. {
  18. int b = k.TestBit(i) ? 1 : 0;
  19. int bp = 1 - b;
  20. R[bp] = R[bp].TwicePlus(R[b]);
  21. }
  22. return R[0];
  23. }
  24. }
  25. }
  26. #pragma warning restore
  27. #endif