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.
37 lines
976 B
37 lines
976 B
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR) |
|
#pragma warning disable |
|
using System; |
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Multiplier |
|
{ |
|
/** |
|
* Class implementing the NAF (Non-Adjacent Form) multiplication algorithm (left-to-right). |
|
*/ |
|
|
|
public class NafL2RMultiplier |
|
: AbstractECMultiplier |
|
{ |
|
protected override ECPoint MultiplyPositive(ECPoint p, BigInteger k) |
|
{ |
|
int[] naf = WNafUtilities.GenerateCompactNaf(k); |
|
|
|
ECPoint addP = p.Normalize(), subP = addP.Negate(); |
|
|
|
ECPoint R = p.Curve.Infinity; |
|
|
|
int i = naf.Length; |
|
while (--i >= 0) |
|
{ |
|
int ni = naf[i]; |
|
int digit = ni >> 16, zeroes = ni & 0xFFFF; |
|
|
|
R = R.TwicePlus(digit < 0 ? subP : addP); |
|
R = R.TimesPow2(zeroes); |
|
} |
|
|
|
return R; |
|
} |
|
} |
|
} |
|
#pragma warning restore |
|
#endif
|
|
|