summary refs log tree commit diff
path: root/crypto/src/math/ec/multiplier/ZSignedDigitL2RMultiplier.cs
blob: 1c7a5d104d500fe63e71692602ffdbe5bdcd6446 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;

namespace Org.BouncyCastle.Math.EC.Multiplier
{
    [Obsolete("Will be removed")]
    public class ZSignedDigitL2RMultiplier 
        : AbstractECMultiplier
    {
        /**
         * 'Zeroless' Signed Digit Left-to-Right.
         */
        protected override ECPoint MultiplyPositive(ECPoint p, BigInteger k)
        {
            ECPoint addP = p.Normalize(), subP = addP.Negate();

            ECPoint R0 = addP;

            int n = k.BitLength;
            int s = k.GetLowestSetBit();

            int i = n;
            while (--i > s)
            {
                R0 = R0.TwicePlus(k.TestBit(i) ? addP : subP);
            }

            R0 = R0.TimesPow2(s);

            return R0;
        }
    }
}