Exemple #1
0
        private static Context Secp256K1ContextCreate(Options flags)
        {
            var ret = new Context
            {
                IllegalCallback = IllegalCallback,
                ErrorCallback   = ErrorCallback
            };

            if ((flags & Options.FlagsTypeMask) != Options.FlagsTypeContext)
            {
                ret.IllegalCallback?.Invoke(null, new Callback("Invalid flags"));
                return(null);
            }

            EcMult.secp256k1_ecmult_context_init(ret.EcMultCtx);
            EcMultGen.ContextInit(ret.EcMultGenCtx);

            if (flags.HasFlag(Options.FlagsBitContextSign))
            {
                EcMultGen.ContextBuild(ret.EcMultGenCtx, ret.ErrorCallback);
            }
            if (flags.HasFlag(Options.FlagsBitContextVerify))
            {
                EcMult.secp256k1_ecmult_context_build(ret.EcMultCtx, ret.ErrorCallback);
            }

            return(ret);
        }
        private static Context Secp256K1ContextCreate(Options flags)
        {
            Context context1 = new Context();

            // ISSUE: reference to a compiler-generated field
            context1.IllegalCallback = Secp256K1Manager.IllegalCallback;
            // ISSUE: reference to a compiler-generated field
            context1.ErrorCallback = Secp256K1Manager.ErrorCallback;
            Context context2 = context1;

            if ((flags & Options.FlagsTypeMask) != Options.FlagsTypeContext)
            {
                EventHandler <Callback> illegalCallback = context2.IllegalCallback;
                if (illegalCallback != null)
                {
                    illegalCallback((object)null, new Callback("Invalid flags"));
                }
                return((Context)null);
            }
            EcMult.secp256k1_ecmult_context_init(context2.EcMultCtx);
            EcMultGen.ContextInit(context2.EcMultGenCtx);
            if (flags.HasFlag((Enum)Options.FlagsBitContextSign))
            {
                EcMultGen.ContextBuild(context2.EcMultGenCtx, context2.ErrorCallback);
            }
            if (flags.HasFlag((Enum)Options.FlagsBitContextVerify))
            {
                EcMult.secp256k1_ecmult_context_build(context2.EcMultCtx, context2.ErrorCallback);
            }
            return(context2);
        }