@@ -95,125 +95,121 @@ describe('Offline Admin Tool', function() {
95
95
} ) ;
96
96
97
97
describe ( 'Stellar key derivation' , function ( ) {
98
- process . config . verificationPub = null ;
99
- // from test 3 at https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md#test-cases
100
- const MASTER_SEED = '937ae91f6ab6f12461d9936dfc1375ea5312d097f3f1eb6fed6a82fbe38c85824da8704389831482db0433e5f6c6c9700ff1946aa75ad8cc2654d6e40f567866'
101
-
102
- describe ( 'failure' , function ( ) {
103
- it ( 'should fail with an invalid master seed' , function ( ) {
104
- const BAD_SEED = '-thisisabadseed' ;
105
-
106
- ( function ( ) { utils . deriveChildKey ( BAD_SEED , "m/148'" , 'xlm' ) } ) . should . throw ( Error ) ;
107
- } ) ;
108
-
109
- it ( 'should fail with an invalid derivation path' , function ( ) {
110
- ( function ( ) { utils . deriveChildKey ( MASTER_SEED , 'derivation path' , 'xlm' ) } ) . should . throw ( Error ) ;
111
- } ) ;
112
- } ) ;
113
-
114
- describe ( 'success' , function ( ) {
115
- // test 3 from https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md#test-cases
116
- it ( "should find m/44'/148'/0' of test vector 3" , function ( ) {
117
- const pub = 'GC3MMSXBWHL6CPOAVERSJITX7BH76YU252WGLUOM5CJX3E7UCYZBTPJQ' ;
118
- const priv = 'SAEWIVK3VLNEJ3WEJRZXQGDAS5NVG2BYSYDFRSH4GKVTS5RXNVED5AX7' ;
119
-
120
- const publicKey = utils . deriveChildKey ( MASTER_SEED , "m/44'/148'/0'" , 'xlm' , true ) ;
121
- publicKey . should . equal ( pub ) ;
122
- const secret = utils . deriveChildKey ( MASTER_SEED , "m/44'/148'/0'" , 'xlm' , false ) ;
123
- secret . should . equal ( priv ) ;
124
- } ) ;
125
-
126
- // test 3 from https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md#test-cases
127
- it ( "should find m/44'/148'/6' of test vector 3" , function ( ) {
128
- const pub = 'GCUDW6ZF5SCGCMS3QUTELZ6LSAH6IVVXNRPRLAUNJ2XYLCA7KH7ZCVQS' ;
129
- const priv = 'SBSHUZQNC45IAIRSAHMWJEJ35RY7YNW6SMOEBZHTMMG64NKV7Y52ZEO2' ;
130
-
131
- const publicKey = utils . deriveChildKey ( MASTER_SEED , "m/44'/148'/6'" , 'xlm' , true ) ;
132
- publicKey . should . equal ( pub ) ;
133
- const secret = utils . deriveChildKey ( MASTER_SEED , "m/44'/148'/6'" , 'xlm' , false ) ;
134
- secret . should . equal ( priv ) ;
135
- } ) ;
136
- } )
98
+ process . config . verificationPub = null ;
99
+ // from test 3 at https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md#test-cases
100
+ const MASTER_SEED = '937ae91f6ab6f12461d9936dfc1375ea5312d097f3f1eb6fed6a82fbe38c85824da8704389831482db0433e5f6c6c9700ff1946aa75ad8cc2654d6e40f567866'
101
+
102
+ describe ( 'failure' , function ( ) {
103
+ it ( 'should fail with an invalid master seed' , function ( ) {
104
+ const BAD_SEED = '-thisisabadseed' ;
105
+ ( function ( ) { utils . deriveChildKey ( BAD_SEED , "m/148'" , 'xlm' ) } ) . should . throw ( Error ) ;
106
+ } ) ;
107
+
108
+ it ( 'should fail with an invalid derivation path' , function ( ) {
109
+ ( function ( ) { utils . deriveChildKey ( MASTER_SEED , 'derivation path' , 'xlm' ) } ) . should . throw ( Error ) ;
110
+ } ) ;
111
+ } ) ;
112
+ describe ( 'success' , function ( ) {
113
+ // test 3 from https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md#test-cases
114
+ it ( "should find m/44'/148'/0' of test vector 3" , function ( ) {
115
+ const pub = 'GC3MMSXBWHL6CPOAVERSJITX7BH76YU252WGLUOM5CJX3E7UCYZBTPJQ' ;
116
+ const priv = 'SAEWIVK3VLNEJ3WEJRZXQGDAS5NVG2BYSYDFRSH4GKVTS5RXNVED5AX7' ;
117
+
118
+ const publicKey = utils . deriveChildKey ( MASTER_SEED , "m/44'/148'/0'" , 'xlm' , true ) ;
119
+ publicKey . should . equal ( pub ) ;
120
+ const secret = utils . deriveChildKey ( MASTER_SEED , "m/44'/148'/0'" , 'xlm' , false ) ;
121
+ secret . should . equal ( priv ) ;
122
+ } ) ;
123
+
124
+ // test 3 from https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md#test-cases
125
+ it ( "should find m/44'/148'/6' of test vector 3" , function ( ) {
126
+ const pub = 'GCUDW6ZF5SCGCMS3QUTELZ6LSAH6IVVXNRPRLAUNJ2XYLCA7KH7ZCVQS' ;
127
+ const priv = 'SBSHUZQNC45IAIRSAHMWJEJ35RY7YNW6SMOEBZHTMMG64NKV7Y52ZEO2' ;
128
+ const publicKey = utils . deriveChildKey ( MASTER_SEED , "m/44'/148'/6'" , 'xlm' , true ) ;
129
+ publicKey . should . equal ( pub ) ;
130
+ const secret = utils . deriveChildKey ( MASTER_SEED , "m/44'/148'/6'" , 'xlm' , false ) ;
131
+ secret . should . equal ( priv ) ;
132
+ } ) ;
133
+ } )
137
134
} ) ;
138
135
139
136
describe ( 'Key signature verification' , function ( ) {
137
+ describe ( 'failure' , function ( ) {
138
+ it ( 'should fail xpub validation with a bad signature' , function ( ) {
139
+ process . config . verificationPub = testVerificationPub ;
140
+ const key = {
141
+ pub : xpub ,
142
+ signature : badSig
143
+ } ;
144
+ const valid = admin . validateKey ( key , 'xpub' ) ;
145
+ valid . should . equal ( false ) ;
146
+ } ) ;
147
+
148
+ it ( 'should fail xlm validation with a bad signature' , function ( ) {
149
+ process . config . verificationPub = testVerificationPub ;
150
+ const key = {
151
+ pub : xlmPub ,
152
+ signature : badSig
153
+ } ;
154
+ const valid = admin . validateKey ( key , 'xlm' ) ;
155
+ valid . should . equal ( false ) ;
156
+ } ) ;
140
157
141
- describe ( 'failure' , function ( ) {
142
- it ( 'should fail xpub validation with a bad signature' , function ( ) {
143
- process . config . verificationPub = testVerificationPub ;
144
- const key = {
145
- pub : xpub ,
146
- signature : badSig
147
- } ;
148
- const valid = admin . validateKey ( key , 'xpub' ) ;
149
- valid . should . equal ( false ) ;
150
- } ) ;
151
-
152
- it ( 'should fail xlm validation with a bad signature' , function ( ) {
153
- process . config . verificationPub = testVerificationPub ;
154
- const key = {
155
- pub : xlmPub ,
156
- signature : badSig
157
- } ;
158
- const valid = admin . validateKey ( key , 'xlm' ) ;
159
- valid . should . equal ( false ) ;
160
- } ) ;
161
-
162
- it ( 'should fail xpub validation with no signature' , function ( ) {
163
- process . config . verificationPub = testVerificationPub ;
164
- const key = {
165
- pub : xpub
166
- } ;
167
- const valid = admin . validateKey ( key , 'xpub' ) ;
168
- valid . should . equal ( false ) ;
169
- } ) ;
170
-
171
- it ( 'should fail xlm validation with no signature' , function ( ) {
172
- process . config . verificationPub = testVerificationPub ;
173
- const key = {
174
- pub : xlmPub
175
- } ;
176
- const valid = admin . validateKey ( key , 'xlm' ) ;
177
- valid . should . equal ( false ) ;
178
- } ) ;
179
- } ) ;
180
-
181
- describe ( 'success' , function ( ) {
182
- it ( 'should validate xpub with a good signature' , function ( ) {
183
- process . config . verificationPub = testVerificationPub ;
184
- const key = {
185
- pub : xpub ,
186
- signature : xpubSig
187
- } ;
188
- const valid = admin . validateKey ( key , 'xpub' ) ;
189
- valid . should . equal ( true ) ;
190
- } ) ;
191
-
192
- it ( 'should validate xlm with a good signature' , function ( ) {
193
- process . config . verificationPub = testVerificationPub ;
194
- const key = {
195
- pub : xlmPub ,
196
- signature : xlmSig
197
- } ;
198
- const valid = admin . validateKey ( key , 'xlm' ) ;
199
- valid . should . equal ( true ) ;
200
- } ) ;
201
- } ) ;
158
+ it ( 'should fail xpub validation with no signature' , function ( ) {
159
+ process . config . verificationPub = testVerificationPub ;
160
+ const key = {
161
+ pub : xpub
162
+ } ;
163
+ const valid = admin . validateKey ( key , 'xpub' ) ;
164
+ valid . should . equal ( false ) ;
165
+ } ) ;
166
+
167
+ it ( 'should fail xlm validation with no signature' , function ( ) {
168
+ process . config . verificationPub = testVerificationPub ;
169
+ const key = {
170
+ pub : xlmPub
171
+ } ;
172
+ const valid = admin . validateKey ( key , 'xlm' ) ;
173
+ valid . should . equal ( false ) ;
174
+ } ) ;
175
+ } ) ;
176
+
177
+ describe ( 'success' , function ( ) {
178
+ it ( 'should validate xpub with a good signature' , function ( ) {
179
+ process . config . verificationPub = testVerificationPub ;
180
+ const key = {
181
+ pub : xpub ,
182
+ signature : xpubSig
183
+ } ;
184
+ const valid = admin . validateKey ( key , 'xpub' ) ;
185
+ valid . should . equal ( true ) ;
186
+ } ) ;
187
+
188
+ it ( 'should validate xlm with a good signature' , function ( ) {
189
+ process . config . verificationPub = testVerificationPub ;
190
+ const key = {
191
+ pub : xlmPub ,
192
+ signature : xlmSig
193
+ } ;
194
+ const valid = admin . validateKey ( key , 'xlm' ) ;
195
+ valid . should . equal ( true ) ;
196
+ } ) ;
197
+ } ) ;
202
198
} ) ;
203
199
204
200
describe ( 'Save a key with a signature' , co ( function * ( ) {
205
- it ( 'should successfully save a key with a signature to the database' , co ( function * ( ) {
206
- process . config . verificationPub = testVerificationPub ;
207
- const key = {
208
- pub : xpub ,
209
- signature : xpubSig ,
210
- path : '0'
211
- } ;
212
- const keyList = [ key ] ;
213
- yield admin . saveKeys ( keyList , 'xpub' ) ;
214
- const foundKey = yield MasterKey . findOne ( { pub : xpub } ) ;
215
- foundKey . should . have . property ( 'signature' ) ;
216
- } ) ) ;
201
+ it ( 'should successfully save a key with a signature to the database' , co ( function * ( ) {
202
+ process . config . verificationPub = testVerificationPub ;
203
+ const key = {
204
+ pub : xpub ,
205
+ signature : xpubSig ,
206
+ path : '0'
207
+ } ;
208
+ const keyList = [ key ] ;
209
+ yield admin . saveKeys ( keyList , 'xpub' ) ;
210
+ const foundKey = yield MasterKey . findOne ( { pub : xpub } ) ;
211
+ foundKey . should . have . property ( 'signature' ) ;
212
+ } ) ) ;
217
213
} ) ) ;
218
214
219
215
describe ( 'Verification' , function ( ) {
0 commit comments