Esempio n. 1
0
 public static void secp256k1_ecmult_odd_multiples_table_storage_var(int n, GeStorage[] pre, GeJ a, EventHandler <Callback> cb)
 {
     GeJ[] geJArray = new GeJ[n];
     Ge[]  r        = new Ge[n];
     Fe[]  zr       = new Fe[n];
     for (int index = 0; index < n; ++index)
     {
         geJArray[index] = new GeJ();
         r[index]        = new Ge();
         zr[index]       = new Fe();
     }
     EcMult.secp256k1_ecmult_odd_multiples_table(n, geJArray, zr, a);
     Group.secp256k1_ge_set_table_gej_var(r, geJArray, zr, n);
     for (int index = 0; index < n; ++index)
     {
         Group.ToStorage(pre[index], r[index]);
     }
 }
Esempio n. 2
0
        ///** Fill a table 'pre' with precomputed odd multiples of a.
        // *
        // *  There are two versions of this function:
        // *  - secp256k1_ecmult_odd_multiples_table_globalz_windowa which brings its
        // *    resulting point set to a single constant Z denominator, stores the X and Y
        // *    coordinates as ge_storage points in pre, and stores the global Z in rz.
        // *    It only operates on tables sized for WINDOW_A wnaf multiples.
        // *  - secp256k1_ecmult_odd_multiples_table_storage_var, which converts its
        // *    resulting point set to actually affine points, and stores those in pre.
        // *    It operates on tables of any size, but uses heap-allocated temporaries.
        // *
        // *  To compute a*P + b*G, we compute a table for P using the first function,
        // *  and for G using the second (which requires an inverse, but it only needs to
        // *  happen once).
        // */
        //static void secp256k1_ecmult_odd_multiples_table_globalz_windowa(secp256k1_ge* pre, secp256k1_fe* globalz, const secp256k1_gej* a)
        //{
        //    secp256k1_gej prej[ECMULT_TABLE_SIZE(WINDOW_A)];
        //    secp256k1_fe zr[ECMULT_TABLE_SIZE(WINDOW_A)];

        //    /* Compute the odd multiples in Jacobian form. */
        //    secp256k1_ecmult_odd_multiples_table(ECMULT_TABLE_SIZE(WINDOW_A), prej, zr, a);
        //    /* Bring them to the same Z denominator. */
        //    secp256k1_ge_globalz_set_table_gej(ECMULT_TABLE_SIZE(WINDOW_A), pre, globalz, prej, zr);
        //}

        public static void secp256k1_ecmult_odd_multiples_table_storage_var(int n, GeStorage[] pre, GeJ a, EventHandler <Callback> cb)
        {
            GeJ[] prej = new GeJ[n];
            Ge[]  prea = new Ge[n];
            Fe[]  zr   = new Fe[n];
            for (int i = 0; i < n; i++)
            {
                prej[i] = new GeJ();
                prea[i] = new Ge();
                zr[i]   = new Fe();
            }

            /* Compute the odd multiples in Jacobian form. */
            secp256k1_ecmult_odd_multiples_table(n, prej, zr, a);
            /* Convert them in batch to affine coordinates. */
            Group.secp256k1_ge_set_table_gej_var(prea, prej, zr, n);
            /* Convert them to compact storage form. */
            for (var i = 0; i < n; i++)
            {
                Group.ToStorage(pre[i], prea[i]);
            }
        }