private void DecodeContent(byte[] encoded)
        {
            var parser = new Asn1Parser(encoded);

            parser.ReadObject <DerSequenceParser>();
            var version = parser.ReadObject <DerInteger>().Value.IntValue;

            if (1 != version)
            {
                throw new ParsingException($"Expected version 1, got {version}");
            }

            var octetString = (DerOctetString)parser.ReadObject <DerOctetStringParser>().ToAsn1Object();

            privateKey = new BigInteger(1, octetString.GetOctets());

            parser.ReadObject <BerTaggedObjectParser>();
            var oid = parser.ReadObject <DerObjectIdentifier>();

            if (!BrainpoolP320R1.ObjectIdentifier.Equals(oid))
            {
                throw new ParsingException($"Expected BrainpoolP320r1 ({BrainpoolP320R1.ObjectIdentifier}), got {oid}");
            }

            var obj = parser.ReadObject();

            if (obj == null)
            {
                return;
            }

            Asn1Parser.CheckObject <BerTaggedObjectParser>(obj);
            try
            {
                publicKey = BrainpoolP320R1.Curve.DecodePoint(parser.ReadObject <DerBitString>().GetBytes()).Normalize();
            }
            catch (ArgumentException e)
            {
                throw new ParsingException("Could not decode point on curve", e);
            }

            BrainpoolP320R1.G.Multiply(privateKey).Normalize();
            if (!BrainpoolP320R1.G.Multiply(privateKey).Equals(publicKey))
            {
                throw new ParsingException("Public key does not belong to private key");
            }
        }
        private void DecodePayload(Asn1Parser payloadParser, bool isPseudonym)
        {
            schemeVersion    = payloadParser.ReadObject <DerInteger>().Value.IntValue;
            schemeKeyVersion = payloadParser.ReadObject <DerInteger>().Value.IntValue;
            payloadParser.ReadObject <DerIA5String>(); //Creator, not used
            recipient = payloadParser.ReadObject <DerIA5String>().GetString();
            recipientKeySetVersion = payloadParser.ReadObject <DerInteger>().Value.IntValue;

            if (isPseudonym)
            {
                var obj = payloadParser.ReadObject();
                if (obj is DerIA5String derIa5String)
                {
                    derIa5String.GetString();
                    payloadParser.ReadObject <DerInteger>(); //Type, not used
                }
                else
                {
                    Asn1Parser.CheckObject <DerInteger>(obj); //Type, not used
                }
            }

            payloadParser.ReadObject <DerSequenceParser>();

            points = new ECPoint[3];
            for (var i = 0; i < points.Length; i++)
            {
                var octet =
                    (DerOctetString)payloadParser.ReadObject <DerOctetStringParser>().ToAsn1Object();
                try
                {
                    points[i] = BrainpoolP320R1.Curve.DecodePoint(octet.GetOctets());
                }
                catch (ArgumentException e)
                {
                    throw new ParsingException("Could not decode point on curve", e);
                }
            }
        }