ZSignedDigitL2RMultiplier.cs 846 B

123456789101112131415161718192021222324252627282930313233343536
  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 ZSignedDigitL2RMultiplier
  7. : AbstractECMultiplier
  8. {
  9. /**
  10. * 'Zeroless' Signed Digit Left-to-Right.
  11. */
  12. protected override ECPoint MultiplyPositive(ECPoint p, BigInteger k)
  13. {
  14. ECPoint addP = p.Normalize(), subP = addP.Negate();
  15. ECPoint R0 = addP;
  16. int n = k.BitLength;
  17. int s = k.GetLowestSetBit();
  18. int i = n;
  19. while (--i > s)
  20. {
  21. R0 = R0.TwicePlus(k.TestBit(i) ? addP : subP);
  22. }
  23. R0 = R0.TimesPow2(s);
  24. return R0;
  25. }
  26. }
  27. }
  28. #pragma warning restore
  29. #endif