public void EncryptedSecretECmultiplyLotSequence() { var tests = new[] { new { Passphrase = "ΜΟΛΩΝ ΛΑΒΕ", PassphraseCode = "passphrased3z9rQJHSyBkNBwTRPkUGNVEVrUAcfAXDyRU1V28ie6hNFbqDwbFBvsTK7yWVK", Encrypted = "6PgGWtx25kUg8QWvwuJAgorN6k9FbE25rv5dMRwu5SKMnfpfVe5mar2ngH", Address = "1Lurmih3KruL4xDB5FmHof38yawNtP9oGf", Unencrypted = "5KMKKuUmAkiNbA3DazMQiLfDq47qs8MAEThm4yL8R2PhV1ov33D", ConfirmationCode = "cfrm38V8G4qq2ywYEFfWLD5Cc6msj9UwsG2Mj4Z6QdGJAFQpdatZLavkgRd1i4iBMdRngDqDs51", LotSequence = new LotSequence(806938, 1), Compressed = false } , new { Passphrase = "MOLON LABE", PassphraseCode = "passphraseaB8feaLQDENqCgr4gKZpmf4VoaT6qdjJNJiv7fsKvjqavcJxvuR1hy25aTu5sX", Encrypted = "6PgNBNNzDkKdhkT6uJntUXwwzQV8Rr2tZcbkDcuC9DZRsS6AtHts4Ypo1j", Address = "1Jscj8ALrYu2y9TD8NrpvDBugPedmbj4Yh", Unencrypted = "5JLdxTtcTHcfYcmJsNVy1v2PMDx432JPoYcBTVVRHpPaxUrdtf8", ConfirmationCode = "cfrm38V8aXBn7JWA1ESmFMUn6erxeBGZGAxJPY4e36S9QWkzZKtaVqLNMgnifETYw7BPwWC9aPD", LotSequence = new LotSequence(263183, 1), Compressed = false } }; foreach (var test in tests) { //Can generate unencrypted key with password and encrypted key var encryptedKey = new BitcoinEncryptedSecretEC(test.Encrypted, Network.Main); AssertSequenceEquals(test.LotSequence, encryptedKey.LotSequence); Key actualKey = encryptedKey.GetKey(test.Passphrase); Assert.Equal(test.Unencrypted, actualKey.GetBitcoinSecret(Network.Main).ToString()); Assert.Equal(test.Address, actualKey.PubKey.GetAddress(Network.Main).ToString()); Assert.Equal(test.Compressed, actualKey.IsCompressed); //Can generate same BitcoinPassphraseCode with by using same ownerentropy var passCode = new BitcoinPassphraseCode(test.PassphraseCode, Network.Main); AssertSequenceEquals(test.LotSequence, passCode.LotSequence); var actualPassCode = new BitcoinPassphraseCode(test.Passphrase, Network.Main, test.LotSequence, passCode.OwnerEntropy); Assert.Equal(passCode.ToString(), actualPassCode.ToString()); //Can verify confirmation var confirmation = new BitcoinConfirmationCode(test.ConfirmationCode, Network.Main); AssertSequenceEquals(confirmation.LotSequence, test.LotSequence); Assert.True(confirmation.Check(test.Passphrase, new BitcoinPubKeyAddress(test.Address, Network.Main))); //Can generate encrypted key from passcode BitcoinEncryptedSecretEC generatedEncryptedKey = passCode.GenerateEncryptedSecret(test.Compressed).EncryptedKey; AssertEx.CollectionEquals(passCode.OwnerEntropy, generatedEncryptedKey.OwnerEntropy); Assert.Equal(test.Compressed, generatedEncryptedKey.IsCompressed); } }
public void EncryptedSecretECmultiplyNoLot() { var tests = new[] { new { Passphrase = "TestingOneTwoThree", PassphraseCode = "passphrasepxFy57B9v8HtUsszJYKReoNDV6VHjUSGt8EVJmux9n1J3Ltf1gRxyDGXqnf9qm", Encrypted = "6PfQu77ygVyJLZjfvMLyhLMQbYnu5uguoJJ4kMCLqWwPEdfpwANVS76gTX", Address = "1PE6TQi6HTVNz5DLwB1LcpMBALubfuN2z2", Unencrypted = "5K4caxezwjGCGfnoPTZ8tMcJBLB7Jvyjv4xxeacadhq8nLisLR2", Compressed = false }, new { Passphrase = "Satoshi", PassphraseCode = "passphraseoRDGAXTWzbp72eVbtUDdn1rwpgPUGjNZEc6CGBo8i5EC1FPW8wcnLdq4ThKzAS", Encrypted = "6PfLGnQs6VZnrNpmVKfjotbnQuaJK4KZoPFrAjx1JMJUa1Ft8gnf5WxfKd", Address = "1CqzrtZC6mXSAhoxtFwVjz8LtwLJjDYU3V", Unencrypted = "5KJ51SgxWaAYR13zd9ReMhJpwrcX47xTJh2D3fGPG9CM8vkv5sH", Compressed = false } }; foreach (var test in tests) { //Can generate unencrypted key with password and encrypted key var encryptedKey = new BitcoinEncryptedSecretEC(test.Encrypted, Network.Main); Assert.Null(encryptedKey.LotSequence); Key actualKey = encryptedKey.GetKey(test.Passphrase); Assert.Equal(test.Unencrypted, actualKey.GetBitcoinSecret(Network.Main).ToString()); Assert.Equal(test.Address, actualKey.PubKey.GetAddress(Network.Main).ToString()); Assert.Equal(test.Compressed, actualKey.IsCompressed); //Can generate same BitcoinPassphraseCode with by using same ownerentropy var passCode = new BitcoinPassphraseCode(test.PassphraseCode, Network.Main); Assert.Null(passCode.LotSequence); var actualPassCode = new BitcoinPassphraseCode(test.Passphrase, Network.Main, null, passCode.OwnerEntropy); Assert.Equal(passCode.ToString(), actualPassCode.ToString()); //Can generate encrypted key from passcode BitcoinEncryptedSecretEC generatedEncryptedKey = passCode.GenerateEncryptedSecret(test.Compressed).EncryptedKey; AssertEx.CollectionEquals(passCode.OwnerEntropy, generatedEncryptedKey.OwnerEntropy); Assert.Equal(test.Compressed, generatedEncryptedKey.IsCompressed); } }
public void EncryptedSecretECmultiplyNoLot() { var tests = new[] { new { Passphrase= "TestingOneTwoThree", PassphraseCode= "passphrasepxFy57B9v8HtUsszJYKReoNDV6VHjUSGt8EVJmux9n1J3Ltf1gRxyDGXqnf9qm", Encrypted = "6PfQu77ygVyJLZjfvMLyhLMQbYnu5uguoJJ4kMCLqWwPEdfpwANVS76gTX", Address = "1PE6TQi6HTVNz5DLwB1LcpMBALubfuN2z2", Unencrypted = "5K4caxezwjGCGfnoPTZ8tMcJBLB7Jvyjv4xxeacadhq8nLisLR2", Compressed = false }, new { Passphrase= "Satoshi", PassphraseCode= "passphraseoRDGAXTWzbp72eVbtUDdn1rwpgPUGjNZEc6CGBo8i5EC1FPW8wcnLdq4ThKzAS", Encrypted = "6PfLGnQs6VZnrNpmVKfjotbnQuaJK4KZoPFrAjx1JMJUa1Ft8gnf5WxfKd", Address = "1CqzrtZC6mXSAhoxtFwVjz8LtwLJjDYU3V", Unencrypted = "5KJ51SgxWaAYR13zd9ReMhJpwrcX47xTJh2D3fGPG9CM8vkv5sH", Compressed = false } }; foreach(var test in tests) { //Can generate unencrypted key with password and encrypted key var encryptedKey = new BitcoinEncryptedSecretEC(test.Encrypted, Network.Main); Assert.Null(encryptedKey.LotSequence); var actualKey = encryptedKey.GetKey(test.Passphrase); Assert.Equal(test.Unencrypted, actualKey.GetBitcoinSecret(Network.Main).ToString()); Assert.Equal(test.Address, actualKey.PubKey.GetAddress(Network.Main).ToString()); Assert.Equal(test.Compressed, actualKey.IsCompressed); //Can generate same BitcoinPassphraseCode with by using same ownerentropy var passCode = new BitcoinPassphraseCode(test.PassphraseCode, Network.Main); Assert.Null(passCode.LotSequence); var actualPassCode = new BitcoinPassphraseCode(test.Passphrase, Network.Main, null, passCode.OwnerEntropy); Assert.Equal(passCode.ToString(), actualPassCode.ToString()); //Can generate encrypted key from passcode var generatedEncryptedKey = passCode.GenerateEncryptedSecret(test.Compressed).EncryptedKey; AssertEx.CollectionEquals(passCode.OwnerEntropy, generatedEncryptedKey.OwnerEntropy); Assert.Equal(test.Compressed, generatedEncryptedKey.IsCompressed); } }
public void EncryptedSecretECmultiplyLotSequence() { var tests = new[] { new { Passphrase= "ΜΟΛΩΝ ΛΑΒΕ", PassphraseCode= "passphrased3z9rQJHSyBkNBwTRPkUGNVEVrUAcfAXDyRU1V28ie6hNFbqDwbFBvsTK7yWVK", Encrypted = "6PgGWtx25kUg8QWvwuJAgorN6k9FbE25rv5dMRwu5SKMnfpfVe5mar2ngH", Address = "1Lurmih3KruL4xDB5FmHof38yawNtP9oGf", Unencrypted = "5KMKKuUmAkiNbA3DazMQiLfDq47qs8MAEThm4yL8R2PhV1ov33D", ConfirmationCode = "cfrm38V8G4qq2ywYEFfWLD5Cc6msj9UwsG2Mj4Z6QdGJAFQpdatZLavkgRd1i4iBMdRngDqDs51", LotSequence = new LotSequence(806938,1), Compressed = false } ,new { Passphrase= "MOLON LABE", PassphraseCode= "passphraseaB8feaLQDENqCgr4gKZpmf4VoaT6qdjJNJiv7fsKvjqavcJxvuR1hy25aTu5sX", Encrypted = "6PgNBNNzDkKdhkT6uJntUXwwzQV8Rr2tZcbkDcuC9DZRsS6AtHts4Ypo1j", Address = "1Jscj8ALrYu2y9TD8NrpvDBugPedmbj4Yh", Unencrypted = "5JLdxTtcTHcfYcmJsNVy1v2PMDx432JPoYcBTVVRHpPaxUrdtf8", ConfirmationCode = "cfrm38V8aXBn7JWA1ESmFMUn6erxeBGZGAxJPY4e36S9QWkzZKtaVqLNMgnifETYw7BPwWC9aPD", LotSequence = new LotSequence(263183,1), Compressed = false } }; foreach(var test in tests) { //Can generate unencrypted key with password and encrypted key var encryptedKey = new BitcoinEncryptedSecretEC(test.Encrypted, Network.Main); AssertSequenceEquals(test.LotSequence, encryptedKey.LotSequence); var actualKey = encryptedKey.GetKey(test.Passphrase); Assert.Equal(test.Unencrypted, actualKey.GetBitcoinSecret(Network.Main).ToString()); Assert.Equal(test.Address, actualKey.PubKey.GetAddress(Network.Main).ToString()); Assert.Equal(test.Compressed, actualKey.IsCompressed); //Can generate same BitcoinPassphraseCode with by using same ownerentropy var passCode = new BitcoinPassphraseCode(test.PassphraseCode, Network.Main); AssertSequenceEquals(test.LotSequence, passCode.LotSequence); var actualPassCode = new BitcoinPassphraseCode(test.Passphrase, Network.Main, test.LotSequence, passCode.OwnerEntropy); Assert.Equal(passCode.ToString(), actualPassCode.ToString()); //Can verify confirmation var confirmation = new BitcoinConfirmationCode(test.ConfirmationCode, Network.Main); AssertSequenceEquals(confirmation.LotSequence, test.LotSequence); Assert.True(confirmation.Check(test.Passphrase, new BitcoinAddress(test.Address, Network.Main))); //Can generate encrypted key from passcode var generatedEncryptedKey = passCode.GenerateEncryptedSecret(test.Compressed).EncryptedKey; AssertEx.CollectionEquals(passCode.OwnerEntropy, generatedEncryptedKey.OwnerEntropy); Assert.Equal(test.Compressed, generatedEncryptedKey.IsCompressed); } }