summary refs log tree commit diff
path: root/crypto/src/math/ec/multiplier/WNafPreCompInfo.cs
blob: f979f33d9152718cfcac6cf8579e5147d8a04f33 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
namespace Org.BouncyCastle.Math.EC.Multiplier
{
    /**
    * Class holding precomputation data for the WNAF (Window Non-Adjacent Form)
    * algorithm.
    */
    public class WNafPreCompInfo
        : PreCompInfo
    {
        internal volatile int m_promotionCountdown = 4;

        protected int m_confWidth = -1;

        /**
         * Array holding the precomputed <code>ECPoint</code>s used for a Window
         * NAF multiplication.
         */
        protected ECPoint[] m_preComp = null;

        /**
         * Array holding the negations of the precomputed <code>ECPoint</code>s used
         * for a Window NAF multiplication.
         */
        protected ECPoint[] m_preCompNeg = null;

        /**
         * Holds an <code>ECPoint</code> representing Twice(this). Used for the
         * Window NAF multiplication to create or extend the precomputed values.
         */
        protected ECPoint m_twice = null;

        protected int m_width = -1;

        internal int DecrementPromotionCountdown()
        {
            int t = m_promotionCountdown;
            if (t > 0)
            {
                m_promotionCountdown = --t;
            }
            return t;
        }

        internal int PromotionCountdown
        {
            get { return m_promotionCountdown; }
            set { this.m_promotionCountdown = value; }
        }

        public virtual bool IsPromoted
        {
            get { return m_promotionCountdown <= 0; }
        }

        public virtual int ConfWidth
        {
            get { return m_confWidth; }
            set { this.m_confWidth = value; }
        }

        public virtual ECPoint[] PreComp
        {
            get { return m_preComp; }
            set { this.m_preComp = value; }
        }

        public virtual ECPoint[] PreCompNeg
        {
            get { return m_preCompNeg; }
            set { this.m_preCompNeg = value; }
        }

        public virtual ECPoint Twice
        {
            get { return m_twice; }
            set { this.m_twice = value; }
        }

        public virtual int Width
        {
            get { return m_width; }
            set { this.m_width = value; }
        }
    }
}