2 using System.Collections.Generic;
5 using System.Threading.Tasks;
10 /// Representation of ECDSA public key
17 private List<byte> pubKeyBytes;
20 /// Initializes a new instance of CPubKey class as the copy of another instance
22 /// <param name="pubKey">Another CPubKey instance</param>
23 public CPubKey(CPubKey pubKey)
25 pubKeyBytes = pubKey.pubKeyBytes;
29 /// Initializes a new instance of CPubKey class using supplied sequence of bytes
31 /// <param name="bytesList"></param>
32 public CPubKey(IEnumerable<byte> bytesList)
34 pubKeyBytes = new List<byte>(bytesList);
38 /// Quick validity test
40 /// <returns>Validation result</returns>
43 return pubKeyBytes.Count == 33 || pubKeyBytes.Count == 65;
47 /// Is this a compressed public key?
49 /// <returns></returns>
50 public bool IsCompressed()
52 // Compressed public keys are 33 bytes long
53 return pubKeyBytes.Count == 33;
57 /// Calculate Hash160 and create new CKeyID instance.
59 /// <returns>New key ID</returns>
60 public CKeyID GetKeyID()
62 return new CKeyID(Hash160.Compute160(this.Raw));
66 /// Accessor for internal representation
68 public IList<byte> Raw
70 get { return pubKeyBytes; }