当前位置: 首页>>代码示例>>Java>>正文


Java DeterministicHierarchy类代码示例

本文整理汇总了Java中com.google.bitcoin.crypto.DeterministicHierarchy的典型用法代码示例。如果您正苦于以下问题:Java DeterministicHierarchy类的具体用法?Java DeterministicHierarchy怎么用?Java DeterministicHierarchy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DeterministicHierarchy类属于com.google.bitcoin.crypto包,在下文中一共展示了DeterministicHierarchy类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testVector

import com.google.bitcoin.crypto.DeterministicHierarchy; //导入依赖的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()));
    }
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:18,代码来源:BIP32Test.java

示例2: generateMasterKeyPair

import com.google.bitcoin.crypto.DeterministicHierarchy; //导入依赖的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];
}
 
开发者ID:Yubico,项目名称:yubico-bitcoin-java,代码行数:8,代码来源:YkneoBitcoinSoft.java

示例3: importExtendedKeyPair

import com.google.bitcoin.crypto.DeterministicHierarchy; //导入依赖的package包/类
@Override
public void importExtendedKeyPair(byte[] extendedPrivateKey, boolean allowExport) throws PinModeLockedException, IOException {
    ensurePin(PinMode.ADMIN);
    byte[] privkey = new byte[33];
    byte[] chaincode = new byte[32];
    System.arraycopy(extendedPrivateKey, 13, chaincode, 0, 32);
    System.arraycopy(extendedPrivateKey, 45, privkey, 0, 33);

    master = new DeterministicHierarchy(HDKeyDerivation.createMasterPrivKeyFromBytes(privkey, chaincode));
    this.allowExport = allowExport;
}
 
开发者ID:Yubico,项目名称:yubico-bitcoin-java,代码行数:12,代码来源:YkneoBitcoinSoft.java


注:本文中的com.google.bitcoin.crypto.DeterministicHierarchy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。