I would need to feed the IR hash as chain code into another HMAC-512 with data=0x00 (representing 0 from derivation path) and again take first 32 bytes and feed it to StellarSdk.Keypair.fromRawSeed
I think this may be where things are going wrong, that first
0x00 is not related to the derivation path (I believe it's padding).
Here's some pseudo code for deriving a child node (
m/44' from the master node):
$index = 44 + 0x80000000; // all keys are hardened
// this comes from the node being used to derive `44'` (aka the master node)
$chainCodeBytes = '05294fe2430e60a3be665f5c6c44ad100d21d09ebcde853befaba92bdb788937';
// Private key of the current node
$privateKeyBytes = '5daf42e856561166e7788d292d5af4c0e3856a0e5dd815cf1f7146e64f87e775';
// index should be encoded as a 4-byte big-endian unsigned long
$indexBytes = toUint32($index);
$hmacInputBytes = 0x00;
$hmacInputBytes.append($indexBytes) // <--- I think this is what you're missing
$hmac = hmac_init('sha512', $chainCodeBytes);
$hashedBytes = hmac_final($hmac);
At this point,
$hashedBytes will be a new 64-byte blob that you can create the child HDNode (
m/44') from (first 32 bytes of it for the private key, second 32 bytes for the chain code).
m/44'/148' you'll repeat the above process.
I think you're really close, you were just missing the 4 bytes of the index!
Here's a link to my PHP code if it helps: https://github.com/zulucrypto/stellar-api/blob/master/src/Derivation/HdNode.php#L64