示例#1
0
        public static bool EcPubKeyCreate(Context ctx, PubKey pubkey, byte[] seckey)
        {
            var r      = new GeJ();
            var ge     = new Ge();
            var scalar = new Scalar();
            var 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);
        }
示例#2
0
        public static bool EcPubkeySerialize(byte[] output, ref int outputlen, PubKey pubkey, Options flags)
        {
            var ge   = new Ge();
            var flag = false;
            var 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);
        }