Bitcoin Forum
May 09, 2024, 05:18:21 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Unharden Address Path  (Read 193 times)
Kruddler (OP)
Jr. Member
*
Offline Offline

Activity: 51
Merit: 56


View Profile
October 04, 2018, 10:25:22 PM
Merited by DarkStar_ (2)
 #1

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 ?



1715275101
Hero Member
*
Offline Offline

Posts: 1715275101

View Profile Personal Message (Offline)

Ignore
1715275101
Reply with quote  #2

1715275101
Report to moderator
1715275101
Hero Member
*
Offline Offline

Posts: 1715275101

View Profile Personal Message (Offline)

Ignore
1715275101
Reply with quote  #2

1715275101
Report to moderator
1715275101
Hero Member
*
Offline Offline

Posts: 1715275101

View Profile Personal Message (Offline)

Ignore
1715275101
Reply with quote  #2

1715275101
Report to moderator
In order to get the maximum amount of activity points possible, you just need to post once per day on average. Skipping days is OK as long as you maintain the average.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715275101
Hero Member
*
Offline Offline

Posts: 1715275101

View Profile Personal Message (Offline)

Ignore
1715275101
Reply with quote  #2

1715275101
Report to moderator
1715275101
Hero Member
*
Offline Offline

Posts: 1715275101

View Profile Personal Message (Offline)

Ignore
1715275101
Reply with quote  #2

1715275101
Report to moderator
1715275101
Hero Member
*
Offline Offline

Posts: 1715275101

View Profile Personal Message (Offline)

Ignore
1715275101
Reply with quote  #2

1715275101
Report to moderator
HeRetiK
Legendary
*
Offline Offline

Activity: 2926
Merit: 2091


Cashback 15%


View Profile
October 04, 2018, 11:35:39 PM
Merited by DarkStar_ (2)
 #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.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10558



View Profile
October 05, 2018, 03:16:28 AM
 #3

what is it that you are exactly trying to do?

because these "numbers" are simply "indexes" that you use in your derivation steps. you don't convert one to another! you decide what number you need and then pass that in your derivation function (read BIP32). for example you want bitcoin so you pass 0' and if you want bitcoin_testnet you pass 1' and you should not worry about the hardened number you pass them with an indicator like ' or the letter H and the function has to recognize it as hardened and add that index (2^31 or 0x80000000) to it, there is still no subtraction here.

in this case if you want bitcoin_cash then your index in level 2 is 145' and you already know that. you don't get it from something else.
and in order to get the extended keys you do need the parent extended key. because the operations don't work in reverse.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Kruddler (OP)
Jr. Member
*
Offline Offline

Activity: 51
Merit: 56


View Profile
October 05, 2018, 03:24:18 AM
 #4

Some code uses the unhardened number, and some code uses the hardened number. In this case, someone else's code gives me the hardened number. I need the unhardened number - I.e. the index as per Slip0044 of the coin.

I can convert from unhardened to hardened, but my question was how to convert the other way around.
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10558



View Profile
October 05, 2018, 03:55:39 AM
 #5

I can convert from unhardened to hardened, but my question was how to convert the other way around.

yeah, you subtract but it still doesn't make sense in practice. it would be like saying second day of the week is Monday, i want to know what is the first day of the week so i subtract 1 from Monday. it obviously works but you should already know it is Sunday.

if you are coding for example in c# you hard code an enum that contains the names and their values like this:
enum Bip44Indices : uint
{
    BTC = 0x80000000,
    TestNet = 0x80000001,
    LTC = 0x80000002,
    ....
    BCH = 0x80000091,
    ....
}
then you use that wherever in your code you want.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Kruddler (OP)
Jr. Member
*
Offline Offline

Activity: 51
Merit: 56


View Profile
October 05, 2018, 11:10:13 PM
 #6

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.

Bitwise XOR is the answer! Thanks HeRetik!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!