@@ -110,3 +110,59 @@ test("Classes", function () {
110
110
ok ( Bitcoin . Paillier . PublicKey , "Bitcoin.Paillier.PublicKey" ) ;
111
111
ok ( Bitcoin . Paillier . PrivateKey , "Bitcoin.Paillier.PrivateKey" ) ;
112
112
} ) ;
113
+
114
+ //
115
+ // Testing BIP38 Key Encryption/Decryption
116
+ // -----------------------------------------------------------------------------
117
+ module ( "bip38" ) ;
118
+
119
+ test ( "Classes" , function ( ) {
120
+ expect ( 1 ) ;
121
+ ok ( Bitcoin . BIP38 , "Bitcoin.BIP38" ) ;
122
+ } ) ;
123
+
124
+ test ( "No compression, no EC multiply #1" , function ( ) {
125
+ expect ( 2 ) ;
126
+
127
+ var wif = "5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR" ;
128
+ var pw = "TestingOneTwoThree" ;
129
+ var encrypted = "6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg" ;
130
+
131
+ equal ( new Bitcoin . ECKey ( wif ) . getEncryptedFormat ( pw ) , encrypted , "Key encrypted successfully." ) ;
132
+ equal ( Bitcoin . ECKey . decodeEncryptedFormat ( encrypted , pw ) . getWalletImportFormat ( ) , wif , "Key decrypted successfully." ) ;
133
+ } ) ;
134
+
135
+ test ( "No compression, no EC multiply #2" , function ( ) {
136
+ expect ( 2 ) ;
137
+
138
+ var wif = "5HtasZ6ofTHP6HCwTqTkLDuLQisYPah7aUnSKfC7h4hMUVw2gi5" ;
139
+ var pw = "Satoshi" ;
140
+ var encrypted = "6PRNFFkZc2NZ6dJqFfhRoFNMR9Lnyj7dYGrzdgXXVMXcxoKTePPX1dWByq" ;
141
+
142
+ equal ( new Bitcoin . ECKey ( wif ) . getEncryptedFormat ( pw ) , encrypted , "Key encrypted successfully." ) ;
143
+ equal ( Bitcoin . ECKey . decodeEncryptedFormat ( encrypted , pw ) . getWalletImportFormat ( ) , wif , "Key decrypted successfully." ) ;
144
+ } ) ;
145
+
146
+
147
+ test ( "Compression, no EC multiply #1" , function ( ) {
148
+ expect ( 2 ) ;
149
+
150
+ var wif = "L44B5gGEpqEDRS9vVPz7QT35jcBG2r3CZwSwQ4fCewXAhAhqGVpP" ;
151
+ var pw = "TestingOneTwoThree" ;
152
+ var encrypted = "6PYNKZ1EAgYgmQfmNVamxyXVWHzK5s6DGhwP4J5o44cvXdoY7sRzhtpUeo" ;
153
+
154
+ equal ( new Bitcoin . ECKey ( wif ) . getEncryptedFormat ( pw ) , encrypted , "Key encrypted successfully." ) ;
155
+ equal ( Bitcoin . ECKey . decodeEncryptedFormat ( encrypted , pw ) . getWalletImportFormat ( ) , wif , "Key decrypted successfully." ) ;
156
+ } ) ;
157
+
158
+ test ( "Compression, no EC multiply #2" , function ( ) {
159
+ expect ( 2 ) ;
160
+
161
+ var wif = "KwYgW8gcxj1JWJXhPSu4Fqwzfhp5Yfi42mdYmMa4XqK7NJxXUSK7" ;
162
+ var pw = "Satoshi" ;
163
+ var encrypted = "6PYLtMnXvfG3oJde97zRyLYFZCYizPU5T3LwgdYJz1fRhh16bU7u6PPmY7" ;
164
+
165
+ equal ( new Bitcoin . ECKey ( wif ) . getEncryptedFormat ( pw ) , encrypted , "Key encrypted successfully." ) ;
166
+ equal ( Bitcoin . ECKey . decodeEncryptedFormat ( encrypted , pw ) . getWalletImportFormat ( ) , wif , "Key decrypted successfully." ) ;
167
+ } ) ;
168
+
0 commit comments