Package org.bitcoinj.crypto
Class ChildNumber
- java.lang.Object
-
- org.bitcoinj.crypto.ChildNumber
-
- All Implemented Interfaces:
java.lang.Comparable<ChildNumber>
public class ChildNumber extends java.lang.Object implements java.lang.Comparable<ChildNumber>
This is just a wrapper for the i (child number) as per BIP 32 with a boolean getter for the most significant bit and a getter for the actual 0-based child number. A
Listof these forms a path through aDeterministicHierarchy. This class is immutable.
-
-
Field Summary
Fields Modifier and Type Field Description static ChildNumberCHANGE_CHANGEstatic ChildNumberCHANGE_RECEIVINGstatic ChildNumberCOINTYPE_BTCstatic ChildNumberCOINTYPE_TBTCstatic intHARDENED_BITThe bit that's set in the child number to indicate whether this key is "hardened".static ChildNumberONEstatic ChildNumberONE_HARDENEDstatic ChildNumberPURPOSE_BIP44static ChildNumberPURPOSE_BIP49static ChildNumberPURPOSE_BIP84static ChildNumberPURPOSE_BIP86static ChildNumberZEROstatic ChildNumberZERO_HARDENED
-
Constructor Summary
Constructors Constructor Description ChildNumber(int i)ChildNumber(int childNumber, boolean isHardened)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(ChildNumber other)booleanequals(java.lang.Object o)intgetI()Returns the uint32 encoded form of the path element, including the most significant bit.inthashCode()inti()Returns the uint32 encoded form of the path element, including the most significant bit.booleanisHardened()intnum()Returns the child number without the hardening bit set (i.e.java.lang.StringtoString()
-
-
-
Field Detail
-
HARDENED_BIT
public static final int HARDENED_BIT
The bit that's set in the child number to indicate whether this key is "hardened". Given a hardened key, it is not possible to derive a child public key if you know only the hardened public key. With a non-hardened key this is possible, so you can derive trees of public keys given only a public parent, but the downside is that it's possible to leak private keys if you disclose a parent public key and a child private key (elliptic curve maths allows you to work upwards).- See Also:
- Constant Field Values
-
ZERO
public static final ChildNumber ZERO
-
ZERO_HARDENED
public static final ChildNumber ZERO_HARDENED
-
ONE
public static final ChildNumber ONE
-
ONE_HARDENED
public static final ChildNumber ONE_HARDENED
-
PURPOSE_BIP44
public static final ChildNumber PURPOSE_BIP44
-
PURPOSE_BIP49
public static final ChildNumber PURPOSE_BIP49
-
PURPOSE_BIP84
public static final ChildNumber PURPOSE_BIP84
-
PURPOSE_BIP86
public static final ChildNumber PURPOSE_BIP86
-
COINTYPE_BTC
public static final ChildNumber COINTYPE_BTC
-
COINTYPE_TBTC
public static final ChildNumber COINTYPE_TBTC
-
CHANGE_RECEIVING
public static final ChildNumber CHANGE_RECEIVING
-
CHANGE_CHANGE
public static final ChildNumber CHANGE_CHANGE
-
-
Method Detail
-
getI
public int getI()
Returns the uint32 encoded form of the path element, including the most significant bit.
-
i
public int i()
Returns the uint32 encoded form of the path element, including the most significant bit.
-
isHardened
public boolean isHardened()
-
num
public int num()
Returns the child number without the hardening bit set (i.e. index in that part of the tree).
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
compareTo
public int compareTo(ChildNumber other)
- Specified by:
compareToin interfacejava.lang.Comparable<ChildNumber>
-
-