using System.Collections.Generic; using System.Linq; using Org.BouncyCastle.Math.EC; using Org.BouncyCastle.Crypto.Parameters; namespace Novacoin { /// /// Representation of ECDSA public key /// public class CPubKey : CKey { /// /// Initializes a new instance of CPubKey class as the copy of another instance /// /// Another CPubKey instance public CPubKey(CPubKey pubKey) { _Public = pubKey._Public; } /// /// Initializes a new instance of CPubKey class using supplied sequence of bytes /// /// Byte sequence public CPubKey(IEnumerable bytes) { ECPoint pQ = curve.Curve.DecodePoint(bytes.ToArray()); _Public = new ECPublicKeyParameters(pQ, domain); } /// /// Quick validity test /// /// Validation result public bool IsValid { get { return !_Public.Q.IsInfinity; } } /// /// Is this a compressed public key? /// /// public bool IsCompressed { get { return _Public.Q.IsCompressed; } } public override string ToString() { return Interop.ToHex(Public); } } }