• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DeterministicKey类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testVector

import com.google.bitcoin.crypto.DeterministicKey; //导入依赖的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: createMasterPubKeyFromPubB58

import com.google.bitcoin.crypto.DeterministicKey; //导入依赖的package包/类
public static DeterministicKey createMasterPubKeyFromPubB58(String xpubstr)
    throws AddressFormatException
{
    byte[] data = Base58.decodeChecked(xpubstr);
    ByteBuffer ser = ByteBuffer.wrap(data);
    if (ser.getInt() != 0x0488B21E)
        throw new AddressFormatException("bad xpub version");
    ser.get();		// depth
    ser.getInt();	// parent fingerprint
    ser.getInt();	// child number
    byte[] chainCode = new byte[32];
    ser.get(chainCode);
    byte[] pubBytes = new byte[33];
    ser.get(pubBytes);
    return HDKeyDerivation.createMasterPubKeyFromBytes(pubBytes, chainCode);
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:17,代码来源:WalletUtil.java


示例3: doInBackground

import com.google.bitcoin.crypto.DeterministicKey; //导入依赖的package包/类
protected Void doInBackground(DeterministicKey... args)
{
    DeterministicKey accountKey = args[0];

    WalletApplication wallapp =
        (WalletApplication) getApplicationContext();
    NetworkParameters params = MainNetParams.get();
    String filePrefix = "btcreceive";

    HDReceiver hdrecvr = new HDReceiver(getApplicationContext(),
                             params,
                             getApplicationContext().getFilesDir(),
                             filePrefix,
                             accountKey);
    hdrecvr.persist();
    return null;
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:18,代码来源:ScanXPubActivity.java


示例4: HDAccount

import com.google.bitcoin.crypto.DeterministicKey; //导入依赖的package包/类
public HDAccount(NetworkParameters params,
                 DeterministicKey accountKey,
                 JSONObject acctNode) throws JSONException {

    mParams = params;
    mAccountKey = accountKey;

    mAccountName = acctNode.getString("name");

    mReceiveChain = new HDChain(mParams, mAccountKey,
                                acctNode.getJSONObject("receive"));
    mChangeChain = new HDChain(mParams, mAccountKey,
                               acctNode.getJSONObject("change"));

    mLogger.info("deserialized account " + mAccountName);
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:17,代码来源:HDAccount.java


示例5: HDReceiver

import com.google.bitcoin.crypto.DeterministicKey; //导入依赖的package包/类
public HDReceiver(Context ctxt,
                  NetworkParameters params,
                  File dir,
                  String prefix,
                  DeterministicKey accountRootKey) {

    mParams = params;
    mDirectory = dir;
    mFilePrefix = prefix;

    // WORKAROUND - there is a bug that watch-only addresses
    // don't seem to properly scan historically; they use
    // quick catchup.  Create a real key (that we ignore) as a
    // workaround.
    //
    mWorkaroundKey = new ECKey();
    mWorkaroundKey.setCreationTimeSeconds(HDAddress.EPOCH);

    mAccountKey = accountRootKey;
    mAccount = new HDAccount(params, mAccountKey, "Account 0");
    mLogger.info("created HDReceiver");
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:23,代码来源:HDReceiver.java


示例6: HDChain

import com.google.bitcoin.crypto.DeterministicKey; //导入依赖的package包/类
public HDChain(NetworkParameters params,
               DeterministicKey accountKey,
               JSONObject chainNode)
    throws RuntimeException, JSONException {

    mParams = params;

    mChainName = chainNode.getString("name");
    mIsReceive = chainNode.getBoolean("isReceive");

    int chainnum = mIsReceive ? 0 : 1;

    mChainKey = HDKeyDerivation.deriveChildKey(accountKey, chainnum);

    mLogger.info("deserialized HDChain " + mChainName + ": " +
                 mChainKey.getPath());
    
    mAddrs = new ArrayList<HDAddress>();
    JSONArray addrobjs = chainNode.getJSONArray("addrs");
    for (int ii = 0; ii < addrobjs.length(); ++ii) {
        JSONObject addrNode = addrobjs.getJSONObject(ii);
        mAddrs.add(new HDAddress(mParams, mChainKey, addrNode));
    }
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:25,代码来源:HDChain.java


示例7: HDAddress

import com.google.bitcoin.crypto.DeterministicKey; //导入依赖的package包/类
public HDAddress(NetworkParameters params,
                 DeterministicKey chainKey,
                 JSONObject addrNode)
    throws RuntimeException, JSONException {

    mParams = params;

    mAddrNum = addrNode.getInt("addrNum");
    mPath = addrNode.getString("path");

    // Derive ECKey.
    byte[] prvBytes = null;
    try {
        mPubBytes = Base58.decode(addrNode.getString("pubBytes"));
    } catch (AddressFormatException ex) {
        throw new RuntimeException("failed to decode pubBytes");
    }
    
    mECKey = new ECKey(prvBytes, mPubBytes);

    // Set creation time to BTCReceive epoch.
    mECKey.setCreationTimeSeconds(EPOCH);

    // Derive public key, public hash and address.
    mPubKey = mECKey.getPubKey();
    mPubKeyHash = mECKey.getPubKeyHash();
    mAddress = mECKey.toAddress(mParams);

    // Initialize transaction count and balance.  If we don't have
    // a persisted available amount, presume it is all available.
    mNumTrans = addrNode.getInt("numTrans");
    mBalance = addrNode.getLong("balance");
    mAvailable = addrNode.has("available") ?
        addrNode.getLong("available") : mBalance;

    mLogger.info("read address " + mPath + ": " + mAddress.toString());
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:38,代码来源:HDAddress.java


示例8: getKey

import com.google.bitcoin.crypto.DeterministicKey; //导入依赖的package包/类
private DeterministicKey getKey(int... index) throws PinModeLockedException, NoKeyLoadedException {
    ensurePin(PinMode.USER);
    ensureKey();
    List<ChildNumber> path = new ArrayList<ChildNumber>();
    for(int i : index) {
        if((i & 0x80000000) != 0) {
            path.add(new ChildNumber(i & 0x7fffffff, true));
        } else {
            path.add(new ChildNumber(i, false));
        }
    }

    return master.get(path, true, true);
}
 
开发者ID:Yubico,项目名称:yubico-bitcoin-java,代码行数:15,代码来源:YkneoBitcoinSoft.java


示例9: getPublicKey

import com.google.bitcoin.crypto.DeterministicKey; //导入依赖的package包/类
@Override
public byte[] getPublicKey(boolean compress, int... index) throws PinModeLockedException, UnusableIndexException, IOException, NoKeyLoadedException {
    DeterministicKey key = getKey(index);
    X9ECParameters params = SECNamedCurves.getByName("secp256k1");
    ECPoint point = params.getCurve().decodePoint(key.toECKey().getPubKey());
    point = new ECPoint.Fp(point.getCurve(), point.getX(), point.getY(), compress);
    return point.getEncoded();
}
 
开发者ID:Yubico,项目名称:yubico-bitcoin-java,代码行数:9,代码来源:YkneoBitcoinSoft.java


示例10: sign

import com.google.bitcoin.crypto.DeterministicKey; //导入依赖的package包/类
@Override
public byte[] sign(byte[] hash, int... index) throws PinModeLockedException, UnusableIndexException, IOException, NoKeyLoadedException {
    DeterministicKey key = getKey(index);
    ECKey.ECDSASignature signature = key.toECKey().sign(new Sha256Hash(hash));
    return signature.encodeToDER();
}
 
开发者ID:Yubico,项目名称:yubico-bitcoin-java,代码行数:7,代码来源:YkneoBitcoinSoft.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OFMatchWithSwDpid类代码示例发布时间:2022-05-22
下一篇:
Java PINoOpHandlerImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap