Beispiel #1
0
        /**
         * Multiplies a {@link org.bouncycastle.math.ec.AbstractF2mPoint AbstractF2mPoint}
         * by an element <code>&#955;</code> of <code><b>Z</b>[&#964;]</code> using
         * the <code>&#964;</code>-adic NAF (TNAF) method.
         * @param p The AbstractF2mPoint to multiply.
         * @param lambda The element <code>&#955;</code> of
         * <code><b>Z</b>[&#964;]</code> of which to compute the
         * <code>[&#964;]</code>-adic NAF.
         * @return <code>p</code> multiplied by <code>&#955;</code>.
         */
        private AbstractF2mPoint MultiplyWTnaf(AbstractF2mPoint p, ZTauElement lambda,
                                               PreCompInfo preCompInfo, sbyte a, sbyte mu)
        {
            ZTauElement[] alpha = (a == 0) ? Tnaf.Alpha0 : Tnaf.Alpha1;

            BigInteger tw = Tnaf.GetTw(mu, Tnaf.Width);

            sbyte[] u = Tnaf.TauAdicWNaf(mu, lambda, Tnaf.Width,
                                         BigInteger.ValueOf(Tnaf.Pow2Width), tw, alpha);

            return(MultiplyFromWTnaf(p, u, preCompInfo));
        }
Beispiel #2
0
        /**
         * Multiplies a {@link Al.Security.math.ec.F2mPoint F2mPoint}
         * by an element <code>&#955;</code> of <code><b>Z</b>[&#964;]</code> using
         * the <code>&#964;</code>-adic NAF (TNAF) method.
         * @param p The F2mPoint to multiply.
         * @param lambda The element <code>&#955;</code> of
         * <code><b>Z</b>[&#964;]</code> of which to compute the
         * <code>[&#964;]</code>-adic NAF.
         * @return <code>p</code> multiplied by <code>&#955;</code>.
         */
        private F2mPoint MultiplyWTnaf(F2mPoint p, ZTauElement lambda,
                                       PreCompInfo preCompInfo, sbyte a, sbyte mu)
        {
            ZTauElement[] alpha;
            if (a == 0)
            {
                alpha = Tnaf.Alpha0;
            }
            else
            {
                // a == 1
                alpha = Tnaf.Alpha1;
            }

            BigInteger tw = Tnaf.GetTw(mu, Tnaf.Width);

            sbyte[] u = Tnaf.TauAdicWNaf(mu, lambda, Tnaf.Width,
                                         BigInteger.ValueOf(Tnaf.Pow2Width), tw, alpha);

            return(MultiplyFromWTnaf(p, u, preCompInfo));
        }