public void ShouldEncodeAddress() { var privateKey = Encoders.Hex.DecodeData("08089C24EC3BAEB34254DDF5297CF8FBB8E031496FF67B4EFACA738FF9EBD455"); NBitcoin.Secp256k1.ECPrivKey privKey = Context.Instance.CreateECPrivKey(new Scalar(privateKey)); ECPubKey pubKey = privKey.CreatePubKey(); var x = pubKey.Q.x.ToBytes(); var y = pubKey.Q.y.ToBytes(); var pubKeyUncomp = Helper.Concat(x, y); Assert.AreEqual( "ee63599802b5d31a29c95cc7df04f427e8f0a124bed9333f3a80404acfc3127659c540d0162dedb81ac5f74b2deb4962656efe112b252e54ac3ba1207cd1fb10", Encoders.Hex.EncodeData(pubKeyUncomp) ); var pubKeyHash = new Sha3Keccack().CalculateHash(pubKeyUncomp); Assert.AreEqual("0837725ba59e30e8e52ba5ab95679f3aaf5211991781d49b30525dddfe9a18de", pubKeyHash.ToHexString()); var sha3HashBytes = new byte[20]; Array.Copy(pubKeyHash, pubKeyHash.Length - 20, sha3HashBytes, 0, 20); byte[] PKHWithVersionBytes = Helper.Concat(new byte[] { 65 }, sha3HashBytes); var hexAddress = PKHWithVersionBytes.ToHexString(); Assert.AreEqual("4195679F3AAF5211991781D49B30525DDDFE9A18DE".ToLower(), hexAddress); var result = Encoders.Base58Check.EncodeData(PKHWithVersionBytes); Assert.AreEqual( "TPbBpRXnt6ztse8XkCLiJstZyqQZvxW2sx", result ); }