on master help sign in
keys: consistently derive from revision-1

When deriving from the mnemonic, we use revision-1 for historic reasons. For consistency, we now do this too when deriving from the auth token. Inconsistency here could make future changes more painful/confusing than they need to be.

commita0efefca06dd0432460d347d2250ee88b301d13e authorFang <git@fang.io> dateThu 23 Jul 2020, 23:50 (6 years ago) parent101a2a2
1 file changed+4−1
src/lib/keys.js+4−1
src/lib/keys.js+4−1
@@ -148,7 +148,10 @@ const deriveNetworkSeedFromMnemonic = async (
148148 * @return {Maybe<string>}
149149 */
150150export const deriveNetworkSeedFromAuthToken = (authToken, revision, point) => {
151− const salt = Buffer.from(`revision-${point}-${revision}`);
151+ //NOTE revision is the point's on-chain revision number.
152+ // since deriveNetworkSeedFromMnemonic does this too, we decrement the
153+ // revision number by one before deriving from it.
154+ const salt = Buffer.from(`revision-${point}-${revision - 1}`);
152155 const networkSeed = shas(authToken, salt)
153156 .toString('hex')
154157 .slice(0, 32);