3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 07:12:17 +00:00

Clarify javadoc comments regarding whether HD derivations are hardened.

This commit is contained in:
Adam Mackler 2014-11-14 10:37:17 -05:00 committed by Mike Hearn
parent 17fae952a7
commit e2b00e4cda
2 changed files with 9 additions and 3 deletions

View File

@ -293,7 +293,9 @@ public class DeterministicKey extends ECKey {
} }
/** /**
* Derives a child at the given index (note: not the "i" value). * Derives a child at the given index using hardened derivation. Note: <code>index</code> is
* not the "i" value. If you want the softened derivation, then use instead
* <code>HDKeyDerivation.deriveChildKey(this, new ChildNumber(child, false))</code>.
*/ */
public DeterministicKey derive(int child) { public DeterministicKey derive(int child) {
return HDKeyDerivation.deriveChildKey(this, new ChildNumber(child, true)); return HDKeyDerivation.deriveChildKey(this, new ChildNumber(child, true));

View File

@ -90,8 +90,12 @@ public final class HDKeyDerivation {
} }
/** /**
* Derives a key given the "extended" child number, ie. with the 0x80000000 bit specifying whether to use hardened * Derives a key given the "extended" child number, ie. the 0x80000000 bit of the value that you
* derivation or not. * pass for <code>childNumber</code> will determine whether to use hardened derivation or not.
* Consider whether your code would benefit from the clarity of the equivalent, but explicit, form
* of this method that takes a <code>ChildNumber</code> rather than an <code>int</code>, for example:
* <code>deriveChildKey(parent, new ChildNumber(childNumber, true))</code>
* where the value of the hardened bit of <code>childNumber</code> is zero.
*/ */
public static DeterministicKey deriveChildKey(DeterministicKey parent, int childNumber) { public static DeterministicKey deriveChildKey(DeterministicKey parent, int childNumber) {
return deriveChildKey(parent, new ChildNumber(childNumber)); return deriveChildKey(parent, new ChildNumber(childNumber));