Post
Topic
Board Development & Technical Discussion
Merits 2 from 1 user
Re: Unharden Address Path
by
HeRetiK
on 04/10/2018, 23:35:39 UTC
⭐ Merited by DarkStar_ (2)
When a BIP0044 address path is created, the CoinNumber is hardened like this (C#):

HardeningConstant = 0x80000000;

(CoinType | HardeningConstant) >> 0

Is it possible to take the hardened number and get the original unhardened coin number?

For example, if the coin is Bitcoin, the path is 0x80000000, but the coin number I want is 0. If the coin is Bitcoin cash, the path is 0x80000091, but I want 145 (0x91‬). Is there a bitwise operation I can do to get 145 0x91 from 0x80000091?

Is just subtracting safe? I.e. 0x80000091 - 0x80000000 ?

In this case just subtracting is safe. Alternatively you could -- in this case -- also use bitwise XOR, ie. 0x80000091 ^ 0x80000000.

I'm not sure with what else there is to consider when working with hardened derivation, but if all you want is to derive the CoinType that should be it.