Esempio n. 1
0
        public static bool EcPubKeyCreate(Context ctx, PubKey pubkey, byte[] seckey)
        {
            GeJ    r      = new GeJ();
            Ge     ge     = new Ge();
            Scalar scalar = new Scalar();
            int    num    = !Scalar.SetB32(scalar, seckey) & !Scalar.IsZero(scalar) ? 1 : 0;

            if (num != 0)
            {
                EcMultGen.secp256k1_ecmult_gen(ctx.EcMultGenCtx, out r, scalar);
                Group.SetGeJ(ge, r);
                Secp256K1T.SavePubKey(pubkey, ge);
            }
            Scalar.Clear(scalar);
            return(num != 0);
        }
Esempio n. 2
0
        public static bool EcPubkeySerialize(byte[] output, ref int outputlen, PubKey pubkey, Options flags)
        {
            Ge   ge   = new Ge();
            bool flag = false;
            int  size = outputlen;

            outputlen = 0;
            if (Secp256K1T.LoadPubKey(ge, pubkey))
            {
                flag = ECKey.PubkeySerialize(ge, output, ref size, flags.HasFlag((Enum)Options.FlagsBitContextVerify));
                if (flag)
                {
                    outputlen = size;
                }
            }
            return(flag);
        }