本文整理汇总了Java中com.google.bitcoin.crypto.HDKeyDerivation.createMasterPrivateKey方法的典型用法代码示例。如果您正苦于以下问题:Java HDKeyDerivation.createMasterPrivateKey方法的具体用法?Java HDKeyDerivation.createMasterPrivateKey怎么用?Java HDKeyDerivation.createMasterPrivateKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.bitcoin.crypto.HDKeyDerivation
的用法示例。
在下文中一共展示了HDKeyDerivation.createMasterPrivateKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testVector
import com.google.bitcoin.crypto.HDKeyDerivation; //导入方法依赖的package包/类
private void testVector(int testCase) throws AddressFormatException {
log.info("======= Test vector {}", testCase);
HDWTestVector tv = tvs[testCase];
DeterministicKey masterPrivateKey = HDKeyDerivation.createMasterPrivateKey(Hex.decode(tv.seed));
Assert.assertEquals(testEncode(tv.priv), testEncode(masterPrivateKey.serializePrivB58()));
Assert.assertEquals(testEncode(tv.pub), testEncode(masterPrivateKey.serializePubB58()));
DeterministicHierarchy dh = new DeterministicHierarchy(masterPrivateKey);
for (int i = 0; i < tv.derived.size(); i++) {
HDWTestVector.DerivedTestCase tc = tv.derived.get(i);
log.info("{}", tc.name);
Assert.assertEquals(tc.name, String.format("Test%d %s", testCase + 1, tc.getPathDescription()));
int depth = tc.path.length - 1;
DeterministicKey ehkey = dh.deriveChild(Arrays.asList(tc.path).subList(0, depth), false, true, tc.path[depth]);
Assert.assertEquals(testEncode(tc.priv), testEncode(ehkey.serializePrivB58()));
Assert.assertEquals(testEncode(tc.pub), testEncode(ehkey.serializePubB58()));
}
}
示例2: generateMasterKeyPair
import com.google.bitcoin.crypto.HDKeyDerivation; //导入方法依赖的package包/类
@Override
public byte[] generateMasterKeyPair(boolean allowExport, boolean returnPrivateKey, boolean testnetKey) throws PinModeLockedException, IOException {
ensurePin(PinMode.ADMIN);
master = new DeterministicHierarchy(HDKeyDerivation.createMasterPrivateKey(random.generateSeed(32)));
this.allowExport = allowExport;
return returnPrivateKey ? master.getRootKey().serializePrivate() : new byte[0];
}