本文整理汇总了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();
}
}
示例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;
}
}
示例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();
}