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


Java Crypto.getPublicKey方法代码示例

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


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

示例1: processRequest

import nxt.crypto.Crypto; //导入方法依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) {

    long accountId;
    String secretPhrase = Convert.emptyToNull(req.getParameter("secretPhrase"));
    String publicKeyString = Convert.emptyToNull(req.getParameter("publicKey"));
    if (secretPhrase != null) {
        byte[] publicKey = Crypto.getPublicKey(secretPhrase);
        accountId = Account.getId(publicKey);
        publicKeyString = Convert.toHexString(publicKey);
    } else if (publicKeyString != null) {
        accountId = Account.getId(Convert.parseHexString(publicKeyString));
    } else {
        return MISSING_SECRET_PHRASE_OR_PUBLIC_KEY;
    }

    JSONObject response = new JSONObject();
    JSONData.putAccount(response, "account", accountId);
    response.put("publicKey", publicKeyString);

    return response;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:23,代码来源:GetAccountId.java

示例2: manualForgingTest

import nxt.crypto.Crypto; //导入方法依赖的package包/类
@Test
public void manualForgingTest() {
    Properties properties = ManualForgingTest.newTestProperties();
    properties.setProperty("nxt.enableFakeForging", "true");
    properties.setProperty("nxt.timeMultiplier", "1");
    AbstractForgingTest.init(properties);
    Assert.assertTrue("nxt.fakeForgingAccount must be defined in nxt.properties", Nxt.getStringProperty("nxt.fakeForgingAccount") != null);
    final byte[] testPublicKey = Crypto.getPublicKey(testForgingSecretPhrase);
    Nxt.setTime(new Time.CounterTime(Nxt.getEpochTime()));
    try {
        for (int i = 0; i < 10; i++) {
            blockchainProcessor.generateBlock(testForgingSecretPhrase, Nxt.getEpochTime());
            Assert.assertArrayEquals(testPublicKey, blockchain.getLastBlock().getGeneratorPublicKey());
        }
    } catch (BlockchainProcessor.BlockNotAcceptedException e) {
        throw new RuntimeException(e.toString(), e);
    }
    Assert.assertEquals(startHeight + 10, blockchain.getHeight());
    AbstractForgingTest.shutdown();
}
 
开发者ID:BitcoinFullnode,项目名称:ROKOS-OK-Bitcoin-Fullnode,代码行数:21,代码来源:ManualForgingTest.java

示例3: generateHallmark

import nxt.crypto.Crypto; //导入方法依赖的package包/类
public static String generateHallmark(String secretPhrase, String host, int weight, int date) {

        if (host.length() == 0 || host.length() > 100) {
            throw new IllegalArgumentException("Hostname length should be between 1 and 100");
        }
        if (weight <= 0 || weight > Constants.MAX_BALANCE_NXT) {
            throw new IllegalArgumentException("Weight should be between 1 and " + Constants.MAX_BALANCE_NXT);
        }

        byte[] publicKey = Crypto.getPublicKey(secretPhrase);
        byte[] hostBytes = Convert.toBytes(host);

        ByteBuffer buffer = ByteBuffer.allocate(32 + 2 + hostBytes.length + 4 + 4 + 1);
        buffer.order(ByteOrder.LITTLE_ENDIAN);
        buffer.put(publicKey);
        buffer.putShort((short)hostBytes.length);
        buffer.put(hostBytes);
        buffer.putInt(weight);
        buffer.putInt(date);

        byte[] data = buffer.array();
        data[data.length - 1] = (byte) ThreadLocalRandom.current().nextInt();
        byte[] signature = Crypto.sign(data, secretPhrase);

        return Convert.toHexString(data) + Convert.toHexString(signature);

    }
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:28,代码来源:Hallmark.java

示例4: getNumericFaucetAccountId

import nxt.crypto.Crypto; //导入方法依赖的package包/类
public static String getNumericFaucetAccountId()
{
  if(numericFaucetAccountId == null)
  {
    String passPhrase = getPassPhrase();
    if(passPhrase != null)
    {
      byte[] publicKey = Crypto.getPublicKey(passPhrase);
      byte[] publicKeyHash = Crypto.sha256().digest(publicKey);
      long faucetAccountId = Convert.fullHashToId(publicKeyHash);
      numericFaucetAccountId = Convert.toUnsignedLong(faucetAccountId);
    }
  }
  return numericFaucetAccountId;
}
 
开发者ID:de-luxe,项目名称:burstcoin-faucet,代码行数:16,代码来源:BurstcoinFaucetProperties.java

示例5: GeneratorNXT

import nxt.crypto.Crypto; //导入方法依赖的package包/类
private GeneratorNXT(String secretPhrase) {
    this.secretPhrase = secretPhrase;
    this.publicKey = Crypto.getPublicKey(secretPhrase);
    this.accountId = Account.getId(publicKey);
    if (Nxt.getBlockchain().getHeight() >= Constants.LAST_KNOWN_BLOCK) {
        setLastBlock(Nxt.getBlockchain().getLastBlock());
    }
    sortedForgers = null;
}
 
开发者ID:giannisKonst,项目名称:blockchain,代码行数:10,代码来源:GeneratorNXT.java

示例6: Generator

import nxt.crypto.Crypto; //导入方法依赖的package包/类
private Generator(String secretPhrase) {
    this.secretPhrase = secretPhrase;
    this.publicKey = Crypto.getPublicKey(secretPhrase);
    this.accountId = Account.getId(publicKey);
    if (Nxt.getBlockchain().getHeight() >= Constants.LAST_KNOWN_BLOCK) {
        setLastBlock(Nxt.getBlockchain().getLastBlock());
    }
    sortedForgers = null;
}
 
开发者ID:BitcoinFullnode,项目名称:ROKOS-OK-Bitcoin-Fullnode,代码行数:10,代码来源:Generator.java

示例7: publicKeyAnnouncement

import nxt.crypto.Crypto; //导入方法依赖的package包/类
@Test
public void publicKeyAnnouncement() {
    byte[] publicKey = Crypto.getPublicKey("NonExistentAccount.jkgdkjgdjkfgfkjgfjkdfgkjjdk");
    String publicKeyStr = Convert.toHexString(publicKey);
    long id = Account.getId(publicKey);
    String rsAccount = Convert.rsAccount(id);

    JSONObject response = new APICall.Builder("getAccount").
            param("account", rsAccount).
            build().invoke();
    Logger.logDebugMessage("getAccount: " + response);
    Assert.assertEquals((long) 5, response.get("errorCode"));

    response = new APICall.Builder("sendMessage").
            param("secretPhrase", ALICE.getSecretPhrase()).
            param("recipient", rsAccount).
            param("recipientPublicKey", publicKeyStr).
            param("feeNQT", Constants.ONE_NXT).
            build().invoke();
    Logger.logDebugMessage("sendMessage: " + response);
    generateBlock();

    response = new APICall.Builder("getAccount").
            param("account", rsAccount).
            build().invoke();
    Logger.logDebugMessage("getAccount: " + response);
    Assert.assertEquals(publicKeyStr, response.get("publicKey"));
}
 
开发者ID:BitcoinFullnode,项目名称:ROKOS-OK-Bitcoin-Fullnode,代码行数:29,代码来源:SendMessageTest.java

示例8: Tester

import nxt.crypto.Crypto; //导入方法依赖的package包/类
Tester(String secretPhrase) {
    this.secretPhrase = secretPhrase;
    this.privateKey = Crypto.getPrivateKey(secretPhrase);
    this.publicKey = Crypto.getPublicKey(secretPhrase);
    this.publicKeyStr = Convert.toHexString(publicKey);
    this.id = Account.getId(publicKey);
    this.strId = Long.toUnsignedString(id);
    this.rsAccount = Convert.rsAccount(id);
    Account account = Account.getAccount(publicKey);
    if (account != null) {
        this.initialBalance = account.getBalanceNQT();
        this.initialUnconfirmedBalance = account.getUnconfirmedBalanceNQT();
        this.initialEffectiveBalance = account.getEffectiveBalanceNXT();
        DbIterator<Account.AccountAsset> assets = account.getAssets(0, -1);
        for (Account.AccountAsset accountAsset : assets) {
            initialAssetQuantity.put(accountAsset.getAssetId(), accountAsset.getQuantityQNT());
            initialUnconfirmedAssetQuantity.put(accountAsset.getAssetId(), accountAsset.getUnconfirmedQuantityQNT());
        }
        DbIterator<Account.AccountCurrency> currencies = account.getCurrencies(0, -1);
        for (Account.AccountCurrency accountCurrency : currencies) {
            initialCurrencyUnits.put(accountCurrency.getCurrencyId(), accountCurrency.getUnits());
            initialUnconfirmedCurrencyUnits.put(accountCurrency.getCurrencyId(), accountCurrency.getUnconfirmedUnits());
        }
    } else {
        initialBalance = 0;
        initialUnconfirmedBalance = 0;
        initialEffectiveBalance = 0;
    }
}
 
开发者ID:BitcoinFullnode,项目名称:ROKOS-OK-Bitcoin-Fullnode,代码行数:30,代码来源:Tester.java

示例9: unlockAccount

import nxt.crypto.Crypto; //导入方法依赖的package包/类
long unlockAccount(String secretPhrase) {
    this.publicKey = Crypto.getPublicKey(secretPhrase);
    this.secretPhrase = secretPhrase;
    //return Generator.startForging(secretPhrase).getAccountId();
    return 0L;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:7,代码来源:User.java

示例10: addNonce

import nxt.crypto.Crypto; //导入方法依赖的package包/类
@Override
public GeneratorState addNonce(String secretPhrase, Long nonce) {
	byte[] publicKey = Crypto.getPublicKey(secretPhrase);
	return addNonce(secretPhrase, nonce, publicKey);
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:6,代码来源:GeneratorImpl.java

示例11: postConstruct

import nxt.crypto.Crypto; //导入方法依赖的package包/类
/**
 * Post construct.
 */
@PostConstruct
protected void postConstruct()
{
  Boolean poolMining = CoreProperties.isPoolMining();

  String numericAccountId;
  if(poolMining)
  {
    numericAccountId = CoreProperties.getNumericAccountId();
  }
  else
  {
    // calculate numericAccountId
    byte[] publicKey = Crypto.getPublicKey(CoreProperties.getPassPhrase());
    byte[] publicKeyHash = Crypto.sha256().digest(publicKey);
    long accountId = Convert.fullHashToId(publicKeyHash);
    numericAccountId = Convert.toUnsignedLong(accountId);
  }

  if(!StringUtils.isEmpty(numericAccountId))
  {
    this.numericAccountId = numericAccountId;
  }
  else
  {
    LOG.error("init reader failed!");
  }

  directories = CoreProperties.getPlotPaths();
  chunkPartNonces = CoreProperties.getChunkPartNonces();
  scanPathsEveryRound = CoreProperties.isScanPathsEveryRound();
  readerThreads = CoreProperties.getReaderThreads();
  capacityLookup = new HashMap<>();

  if(CoreProperties.isListPlotFiles())
  {
    // find winner of lastBlock on new round, if server available
    String server = !poolMining ? CoreProperties.getSoloServer() : CoreProperties.getWalletServer() != null ? CoreProperties.getWalletServer() : null;
    if(!StringUtils.isEmpty(server))
    {
      NetworkRequestAccountBlocksTask networkRequestAccountBlocksTask = context.getBean(NetworkRequestAccountBlocksTask.class);
      networkRequestAccountBlocksTask.init(numericAccountId, server);
      networkPool.execute(networkRequestAccountBlocksTask);
    }
    else
    {
      getPlots().printPlotFiles();
    }
  }
}
 
开发者ID:de-luxe,项目名称:burstcoin-jminer,代码行数:54,代码来源:Reader.java

示例12: unlockAccount

import nxt.crypto.Crypto; //导入方法依赖的package包/类
long unlockAccount(String secretPhrase) {
    this.publicKey = Crypto.getPublicKey(secretPhrase);
    this.secretPhrase = secretPhrase;
    return GeneratorNXT.startForging(secretPhrase).getAccountId();
}
 
开发者ID:giannisKonst,项目名称:blockchain,代码行数:6,代码来源:User.java

示例13: generateBlock

import nxt.crypto.Crypto; //导入方法依赖的package包/类
private void generateBlock(Block previousBlock, String secretPhrase, int blockTimestamp) throws BlockNotAcceptedException {

        TransactionProcessorImpl transactionProcessor = TransactionProcessorImpl.getInstance();

	SortedSet<UnconfirmedTransaction> sortedTransactions = transactionProcessor.assembleBlockTransactions();

        List<TransactionImpl> blockTransactions = new ArrayList<>();
        for (UnconfirmedTransaction unconfirmedTransaction : sortedTransactions) {
            blockTransactions.add(unconfirmedTransaction.getTransaction());
        }

        final byte[] publicKey = Crypto.getPublicKey(secretPhrase);

	BlockNXTImpl block;

        try {
            /* block = new BlockImpl(getBlockVersion(previousBlock.getHeight()), blockTimestamp, previousBlock.getId(), totalAmountNQT, totalFeeNQT, payloadLength,
                    payloadHash, publicKey, generationSignature, null, previousBlockHash, blockTransactions);
		*/

            block = new BlockNXTImpl(blockTimestamp, previousBlock, publicKey, blockTransactions);

        } catch (NxtException.ValidationException e) {
            // shouldn't happen because all transactions are already validated
            Logger.logMessage("Error generating block", e);
            return;
        }

        block.sign(secretPhrase);

        newBlockListener.notify(block);
        /*
        try {
            //BlockchainProcessorImpl.getInstance().pushBlock(block);
            //blockListeners.notify(block, Event.BLOCK_GENERATED);
            Logger.logDebugMessage("Account " + Convert.toUnsignedLong(block.getGeneratorId()) + " generated block " + block.getStringId()
                    + " at height " + block.getHeight());
        } catch (TransactionNotAcceptedException e) {
            Logger.logDebugMessage("Generate block failed: " + e.getMessage());
            Transaction transaction = e.getTransaction();
            Logger.logDebugMessage("Removing invalid transaction: " + transaction.getStringId());
            transactionProcessor.removeUnconfirmedTransaction((TransactionImpl) transaction);
            throw e;
        } catch (BlockNotAcceptedException e) {
            Logger.logDebugMessage("Generate block failed: " + e.getMessage());
            throw e;
        }
        */
    }
 
开发者ID:giannisKonst,项目名称:blockchain,代码行数:50,代码来源:GeneratorNXT.java

示例14: unlockAccount

import nxt.crypto.Crypto; //导入方法依赖的package包/类
long unlockAccount(String secretPhrase) {
    this.publicKey = Crypto.getPublicKey(secretPhrase);
    this.secretPhrase = secretPhrase;
    return Generator.startForging(secretPhrase).getAccountId();
}
 
开发者ID:BitcoinFullnode,项目名称:ROKOS-OK-Bitcoin-Fullnode,代码行数:6,代码来源:User.java


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