The exact steps from Passphrase to Address

How exactly is a passphrase converted to an array of addresses?

I know a way to do it, but it relies on Bitcore. Bitcore is like a black box. It’s difficult to follow even in debugger. It also takes quite a long time, ~0.10 sec on my laptop.

For those interested in code:

function genAddr(passphrase, numOutputs, privkeys) {
//Returns 2d array with addresses and private keys
//For this to work, bitcore must be loaded:
if (typeof numOutputs === ‘undefined’) { numOutputs = 12; }
if (typeof privkeys === ‘undefined’) { privkeys = false; }
var bitcore = require(‘bitcore’);
var adjind = new Uint32Array(4);

var res = “”;
var ppind = [];
var ppWords = passphrase.split(’ ');
for (i=0; i < 12; i++) {
ppind[i] = ppDictionary.indexOf(ppWords[i]);
}
for (i=0; i < 4; i++) {
adjind[i] = ppind[3i] +
1626 * (ppind[3
i+1] - ppind[3i] - Math.floor((ppind[3i+1] - ppind[3i]) / 1626) * 1626) +
2643876 * (ppind[3
i+2] - ppind[3i+1] - Math.floor((ppind[3i+2] - ppind[3*i+1]) / 1626) * 1626);
res += (‘00000000’ + adjind[i].toString(16)).substr(-8);
}

var addr = [];
var HDPrivateKey = bitcore.HDPrivateKey.fromSeed(res, bitcore.Networks.livenet);
for (i = 0; i < numOutputs; i++) {
var derived = HDPrivateKey.derive(“m/0’/0/” + i);
var address = bitcore.Address(derived.publicKey, bitcore.Networks.livenet);
addr[i] = [];
addr[i][0] = address.toString();
if (privkeys == true) {
addr[i][1] = derived.privateKey.toWIF();
}
}

return addr;
}

Edit: This function requires a variable ppDictionary. It’s a string array of all passphrase words. It’s so long I do not want to post it here. You can find it on xcp.pw or elsewhere.