Beispiel #1
0
        public static void secp256k1_ecmult_context_build(EcMultContext ctx, EventHandler <Callback> cb)
        {
            if (ctx.PreG != null)
            {
                return;
            }


            GeJ gj = new GeJ();

            /* get the generator */
            Group.secp256k1_gej_set_ge(gj, Group.Secp256K1GeConstG);

#if USE_ENDOMORPHISM
            var WINDOW_G = 15;
#else
            var WINDOW_G = 16;
#endif
            var tblsize = (1 << ((WINDOW_G)-2));
            ctx.PreG = new GeStorage[tblsize];
            for (int i = 0; i < tblsize; i++)
            {
                ctx.PreG[i] = new GeStorage();
            }
            /* precompute the tables with odd multiples */
            secp256k1_ecmult_odd_multiples_table_storage_var(tblsize, ctx.PreG, gj, cb);

#if USE_ENDOMORPHISM
            {
                secp256k1_gej g_128j;
                int           i;

                ctx.pre_g_128 = (secp256k1_ge_storage(*)[])checked_malloc(cb, sizeof((*ctx.pre_g_128)[0]) * ECMULT_TABLE_SIZE(WINDOW_G));
Beispiel #2
0
        ///** The following two macro retrieves a particular odd multiple from a table
        // *  of precomputed multiples. */
        //#define ECMULT_TABLE_GET_GE(r,pre,n,w) do { \
        //    Debug.Assert(((n) & 1) == 1); \
        //    Debug.Assert((n) >= -((1 << ((w)-1)) - 1)); \
        //    Debug.Assert((n) <=  ((1 << ((w)-1)) - 1)); \
        //    if ((n) > 0) { \
        //        * (r) = (pre)[((n) - 1) / 2]; \
        //    } else { \
        //        secp256k1_ge_neg((r), (pre)[(-(n) - 1) / 2]); \
        //    } \
        //} while(0)

        //#define ECMULT_TABLE_GET_GE_STORAGE(r,pre,n,w) do { \
        //    Debug.Assert(((n) & 1) == 1); \
        //    Debug.Assert((n) >= -((1 << ((w)-1)) - 1)); \
        //    Debug.Assert((n) <=  ((1 << ((w)-1)) - 1)); \
        //    if ((n) > 0) { \
        //        FromStorage((r), (pre)[((n) - 1) / 2]); \
        //    } else { \
        //        FromStorage((r), (pre)[(-(n) - 1) / 2]); \
        //        secp256k1_ge_neg((r), (r)); \
        //    } \
        //} while(0)

        public static void secp256k1_ecmult_context_init(EcMultContext ctx)
        {
            ctx.PreG = null;
#if USE_ENDOMORPHISM
            ctx.pre_g_128 = null;
#endif
        }
        public static void secp256k1_ecmult_context_build(EcMultContext ctx, EventHandler <Callback> cb)
        {
            if (ctx.PreG != null)
            {
                return;
            }
            GeJ geJ = new GeJ();

            Group.secp256k1_gej_set_ge(geJ, Group.Secp256K1GeConstG);
            int n = 1 << 16 - 2;

            ctx.PreG = new GeStorage[n];
            for (int index = 0; index < n; ++index)
            {
                ctx.PreG[index] = new GeStorage();
            }
            EcMult.secp256k1_ecmult_odd_multiples_table_storage_var(n, ctx.PreG, geJ, cb);
        }
 public static void secp256k1_ecmult_context_init(EcMultContext ctx)
 {
     ctx.PreG = (GeStorage[])null;
 }
Beispiel #5
0
 public ContextStruct()
 {
     EcMultCtx    = new EcMultContext();
     EcMultGenCtx = new EcmultGenContext();
 }
 public ContextStruct()
 {
     this.EcMultCtx    = new EcMultContext();
     this.EcMultGenCtx = new EcmultGenContext();
 }