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


Java ECKey.fromPrivate方法代码示例

本文整理汇总了Java中org.bitcoinj.core.ECKey.fromPrivate方法的典型用法代码示例。如果您正苦于以下问题:Java ECKey.fromPrivate方法的具体用法?Java ECKey.fromPrivate怎么用?Java ECKey.fromPrivate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bitcoinj.core.ECKey的用法示例。


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

示例1: getToken

import org.bitcoinj.core.ECKey; //导入方法依赖的package包/类
public Optional<String> getToken() {
        final ListenableFuture<String> masterPassword = encyptionKeyProvider.getMasterPassword();
        if (!masterPassword.isDone()) {
            return Optional.empty();
        }
        final String key = encyptionKeyProvider.getImmediatePassword();
        final String s = key + " meta";
        final ECKey privKey = ECKey.fromPrivate(Sha256Hash.twiceOf(s.getBytes(Charsets.UTF_8)).getBytes());

/*
        @POST
        @Path("/token")
        @Produces(MediaType.APPLICATION_OCTET_STREAM)
        public Response createToken(@QueryParam("timestamp") Long nonce, @QueryParam("signature") String signature) {
*/

//        }
        final long timeStamp = Instant.now().toEpochMilli();
        try {
            final String url = rootPath + "auth/token";
            final HttpResponse<String> token = Unirest.post(url)
                    .queryString("timestamp", timeStamp)
                    .queryString("signature", privKey.signMessage(String.valueOf(timeStamp)))
                    .asString();
            if (token.getStatus() != 200) {
                return Optional.empty();
            }
            return Optional.of(token.getBody());
        } catch (UnirestException e) {
            LOGGER.error("exception from remote service when trying to get token", e);
            return Optional.empty();
        }

    }
 
开发者ID:MineboxOS,项目名称:minebox,代码行数:35,代码来源:RemoteTokenService.java

示例2: get

import org.bitcoinj.core.ECKey; //导入方法依赖的package包/类
@Override
public String get() {
    synchronized (lock) {
        ECKey ecKey = ECKey.fromPrivate(startPrivateKey);
        String privateKeyToCheck = ecKey.getPrivateKeyAsWiF(Constants.NETWORK_PARAMS);
        startPrivateKey = startPrivateKey.add(BigInteger.ONE);
        keyCount = keyCount.add(BigInteger.ONE);
        logKeyRate();
        return privateKeyToCheck;
    }
}
 
开发者ID:eztam-,项目名称:bitcoin-bruteforce,代码行数:12,代码来源:InputKeySupplier.java

示例3: Address

import org.bitcoinj.core.ECKey; //导入方法依赖的package包/类
/**
     * Constructor an HD address.
     *
     * @param NetworkParameters params
     * @param DeterministicKey cKey deterministic key for this address
     * @param int child index of this address in its chain
     *
     */
    public Address(NetworkParameters params, DeterministicKey cKey, int child) {

        this.params = params;
        childNum = child;

        DeterministicKey dk = HDKeyDerivation.deriveChildKey(cKey, new ChildNumber(childNum, false));
        // compressed WIF private key format
        if(dk.hasPrivKey()) {
//            byte[] prepended0Byte = ArrayUtils.addAll(new byte[1], dk.getPrivKeyBytes());
        	byte[] getPrivKeyBytes = dk.getPrivKeyBytes();
        	byte[] prepended0Byte = new byte[1 + getPrivKeyBytes.length];
        	prepended0Byte[0] = 0;
            System.arraycopy(getPrivKeyBytes, 0, prepended0Byte, 1, getPrivKeyBytes.length);
            
            ecKey = ECKey.fromPrivate(new BigInteger(prepended0Byte), true);
        }
        else {
            ecKey = ECKey.fromPublicOnly(dk.getPubKey());
        }

        long now = Utils.now().getTime() / 1000;    // use Unix time (in seconds)
        ecKey.setCreationTimeSeconds(now);

        pubKey = ecKey.getPubKey();
        pubKeyHash = ecKey.getPubKeyHash();

        strPath = dk.getPathAsString();
    }
 
开发者ID:matthiaszimmermann,项目名称:bitcoin-paper-wallet,代码行数:37,代码来源:Address.java


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