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


C++ CryptoContext类代码示例

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


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

示例1: dto

void WalletSerializerV1::loadTransfers(Common::IInputStream& source, CryptoContext& cryptoContext, uint32_t version) {
  uint64_t count = 0;
  deserializeEncrypted(count, "transfers_count", cryptoContext, source);
  cryptoContext.incIv();

  m_transfers.reserve(count);

  for (uint64_t i = 0; i < count; ++i) {
    uint64_t txId = 0;
    deserializeEncrypted(txId, "transaction_id", cryptoContext, source);
    cryptoContext.incIv();

    WalletTransferDto dto(version);
    deserializeEncrypted(dto, "transfer", cryptoContext, source);
    cryptoContext.incIv();

    WalletTransfer tr;
    tr.address = dto.address;
    tr.amount = dto.amount;

    if (version > 2) {
      tr.type = static_cast<WalletTransferType>(dto.type);
    } else {
      tr.type = WalletTransferType::USUAL;
    }

    m_transfers.push_back(std::make_pair(txId, tr));
  }
}
开发者ID:blockchain-research-foundation,项目名称:worktipscoin,代码行数:29,代码来源:WalletSerializationV1.cpp

示例2: saveUnlockTransactionsJobs

void WalletSerializer::saveUnlockTransactionsJobs(Common::IOutputStream& destination, CryptoContext& cryptoContext) {
  auto& index = m_unlockTransactions.get<TransactionHashIndex>();
  auto& wallets = m_walletsContainer.get<TransfersContainerIndex>();

  uint64_t jobsCount = index.size();
  serializeEncrypted(jobsCount, "unlock_transactions_jobs_count", cryptoContext, destination);
  cryptoContext.incIv();

  for (const auto& j: index) {
    auto containerIt = wallets.find(j.container);
    assert(containerIt != wallets.end());

    auto rndIt = m_walletsContainer.project<RandomAccessIndex>(containerIt);
    assert(rndIt != m_walletsContainer.get<RandomAccessIndex>().end());

    uint64_t walletIndex = std::distance(m_walletsContainer.get<RandomAccessIndex>().begin(), rndIt);

    UnlockTransactionJobDto dto;
    dto.blockHeight = j.blockHeight;
    dto.transactionHash = j.transactionHash;
    dto.walletIndex = walletIndex;

    serializeEncrypted(dto, "", cryptoContext, destination);
    cryptoContext.incIv();
  }
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:26,代码来源:WalletSerialization.cpp

示例3: main

int main ()
{
  printf ("Results of aes_context_test:\n");
  
  try
  {  
    CryptoContext context ("aes.encrypt", key, KEY_BITS);

    memset (dst_encrypt_buffer, 0, sizeof dst_decrypt_buffer);        
    
    printf ("source:             '%s'\n", src_buffer);
    printf ("encrypt update:      %u\n",  context.Update (BUFFER_SIZE, src_buffer, dst_encrypt_buffer));
    printf ("dst_encrypt_buffer:  ");
    
    for (size_t i=0; i<BUFFER_SIZE; i++)
      printf ("%02x", (unsigned char)dst_encrypt_buffer [i]);
      
    printf ("\n");

    CryptoContext ("aes.decrypt", key, KEY_BITS).Swap (context);
    
    memset (dst_decrypt_buffer, 0, sizeof dst_decrypt_buffer);

    printf ("decrypt update:      %u\n",  context.Update (BUFFER_SIZE, dst_encrypt_buffer, dst_decrypt_buffer));  
    printf ("dst_decrypt_buffer: '%s'\n", dst_decrypt_buffer);
  }
  catch (std::exception& exception)
  {
    printf ("exception: %s\n", exception.what ());
  }

  return 0;
}
开发者ID:untgames,项目名称:funner,代码行数:33,代码来源:aes_context.cpp

示例4: deserializeEncrypted

void WalletSerializerV1::loadFlags(bool& details, bool& cache, Common::IInputStream& source, CryptoContext& cryptoContext) {
  deserializeEncrypted(details, "details", cryptoContext, source);
  cryptoContext.incIv();

  deserializeEncrypted(cache, "cache", cryptoContext, source);
  cryptoContext.incIv();
}
开发者ID:blockchain-research-foundation,项目名称:worktipscoin,代码行数:7,代码来源:WalletSerializationV1.cpp

示例5: saveFlags

void WalletSerializer::saveFlags(bool saveDetails, bool saveCache, Common::IOutputStream& destination, CryptoContext& cryptoContext) {
  serializeEncrypted(saveDetails, "details", cryptoContext, destination);
  cryptoContext.incIv();

  serializeEncrypted(saveCache, "cache", cryptoContext, destination);
  cryptoContext.incIv();
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:7,代码来源:WalletSerialization.cpp

示例6: loadSpentOutputs

void WalletSerializer::loadSpentOutputs(Common::IInputStream& source, CryptoContext& cryptoContext) {
  auto& index = m_spentOutputs.get<WalletIndex>();
  auto& walletsIndex = m_walletsContainer.get<RandomAccessIndex>();
  const uint64_t walletsSize = walletsIndex.size();

  uint64_t count = 0;
  deserializeEncrypted(count, "spent_outputs_count", cryptoContext, source);
  cryptoContext.incIv();

  for (uint64_t i = 0; i < count; ++i) {
    SpentOutputDto dto;
    deserializeEncrypted(dto, "", cryptoContext, source);
    cryptoContext.incIv();

    assert(dto.walletIndex < walletsSize);

    SpentOutput output;
    output.amount = dto.amount;
    output.transactionHash = dto.transactionHash;
    output.outputInTransaction = dto.outputInTransaction;
    output.spendingTransactionHash = dto.spendingTransactionHash;
    output.wallet = &walletsIndex[dto.walletIndex];

    index.insert(std::move(output));
  }
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:26,代码来源:WalletSerialization.cpp

示例7: while

void
OutgoingDataQueue::putData(uint32 stamp, const unsigned char *data, size_t datalen)
{
    if ( !data || !datalen )
        return;

    size_t step = 0, offset = 0;
    while ( offset < datalen ) {
        // remainder and step take care of segmentation
        // according to getMaxSendSegmentSize()
        size_t remainder = datalen - offset;
        step = ( remainder > getMaxSendSegmentSize() ) ?
            getMaxSendSegmentSize() : remainder;

                CryptoContext* pcc = getOutQueueCryptoContext(getLocalSSRC());
                if (pcc == NULL) {
                    pcc = getOutQueueCryptoContext(0);
                    if (pcc != NULL) {
                        pcc = pcc->newCryptoContextForSSRC(getLocalSSRC(), 0, 0L);
                        if (pcc != NULL) {
                            pcc->deriveSrtpKeys(0);
                            setOutQueueCryptoContext(pcc);
                        }
                    }
                }
                OutgoingRTPPkt* packet;
        if ( sendInfo.sendCC )
            packet = new OutgoingRTPPkt(sendInfo.sendSources,15,data + offset,step, sendInfo.paddinglen, pcc);
        else
            packet = new OutgoingRTPPkt(data + offset,step,sendInfo.paddinglen, pcc);

        packet->setPayloadType(getCurrentPayloadType());
        packet->setSeqNum(sendInfo.sendSeq++);
        packet->setTimestamp(stamp + getInitialTimestamp());

        packet->setSSRCNetwork(getLocalSSRCNetwork());
        if ( (0 == offset) && getMark() ) {
            packet->setMarker(true);
            setMark(false);
        } else {
            packet->setMarker(false);
        }
        if (pcc != NULL) {
            packet->protect(getLocalSSRC(), pcc);
        }
        // insert the packet into the "tail" of the sending queue
        sendLock.writeLock();
        OutgoingRTPPktLink *link =
            new OutgoingRTPPktLink(packet,sendLast,NULL);
        if (sendLast)
            sendLast->setNext(link);
        else
            sendFirst = link;
        sendLast = link;
        sendLock.unlock();

        offset += step;
    }
}
开发者ID:dreamsxin,项目名称:ccrtp,代码行数:59,代码来源:outqueue.cpp

示例8: saveBalances

void WalletSerializer::saveBalances(Common::IOutputStream& destination, bool saveCache, CryptoContext& cryptoContext) {
  uint64_t actual = saveCache ? m_actualBalance : 0;
  uint64_t pending = saveCache ? m_pendingBalance : 0;

  serializeEncrypted(actual, "actual_balance", cryptoContext, destination);
  cryptoContext.incIv();

  serializeEncrypted(pending, "pending_balance", cryptoContext, destination);
  cryptoContext.incIv();
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:10,代码来源:WalletSerialization.cpp

示例9: saveTransactions

void WalletSerializer::saveTransactions(Common::IOutputStream& destination, CryptoContext& cryptoContext) {
  uint64_t count = m_transactions.size();
  serializeEncrypted(count, "transactions_count", cryptoContext, destination);
  cryptoContext.incIv();

  for (const auto& tx: m_transactions) {
    WalletTransactionDto dto(tx);
    serializeEncrypted(dto, "", cryptoContext, destination);
    cryptoContext.incIv();
  }
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:11,代码来源:WalletSerialization.cpp

示例10: loadChange

void WalletSerializer::loadChange(Common::IInputStream& source, CryptoContext& cryptoContext) {
  uint64_t count = 0;
  deserializeEncrypted(count, "changes_count", cryptoContext, source);
  cryptoContext.incIv();

  for (uint64_t i = 0; i < count; i++) {
    ChangeDto dto;
    deserializeEncrypted(dto, "", cryptoContext, source);
    cryptoContext.incIv();

    m_change[dto.txHash] = dto.amount;
  }
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:13,代码来源:WalletSerialization.cpp

示例11: saveChange

void WalletSerializer::saveChange(Common::IOutputStream& destination, CryptoContext& cryptoContext) {
  uint64_t count = m_change.size();
  serializeEncrypted(count, "changes_count", cryptoContext, destination);
  cryptoContext.incIv();

  for (const auto& kv: m_change) {
    ChangeDto dto;
    dto.txHash = kv.first;
    dto.amount = kv.second;

    serializeEncrypted(dto, "", cryptoContext, destination);
    cryptoContext.incIv();
  }
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:14,代码来源:WalletSerialization.cpp

示例12: saveTransfers

void WalletSerializer::saveTransfers(Common::IOutputStream& destination, CryptoContext& cryptoContext) {
  uint64_t count = m_transfers.size();
  serializeEncrypted(count, "transfers_count", cryptoContext, destination);
  cryptoContext.incIv();

  for (const auto& kv: m_transfers) {
    uint64_t txId = kv.first;
    WalletTransferDto tr(kv.second);

    serializeEncrypted(txId, "transaction_id", cryptoContext, destination);
    cryptoContext.incIv();

    serializeEncrypted(tr, "transfer", cryptoContext, destination);
    cryptoContext.incIv();
  }
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:16,代码来源:WalletSerialization.cpp

示例13: scytale_key_derivate

const char * scytale_key_derivate(RedCryptoKeyHandle * handle, const uint8_t * derivator, size_t len)
{
    SCOPED_TRACE;
    CHECK_HANDLE_R(handle, "");

    std::unique_ptr<uint8_t[]> normalized_derivator_gc;
    auto const new_derivator = CryptoContext::get_normalized_derivator(
        normalized_derivator_gc, {derivator, len});

    CryptoContext cctx;
    cctx.old_encryption_scheme = false;
    cctx.one_shot_encryption_scheme = false;
    cctx.set_master_key(handle->master);
    cctx.get_derived_key(handle->derivated, new_derivator);
    hash_to_hashhex(handle->derivated, handle->derivatedhex);
    return handle->derivatedhex;
}
开发者ID:pykoder,项目名称:redemption,代码行数:17,代码来源:scytale.cpp

示例14: saveTransfersSynchronizer

void WalletSerializer::saveTransfersSynchronizer(Common::IOutputStream& destination, CryptoContext& cryptoContext) {
  std::stringstream stream;
  m_synchronizer.save(stream);
  stream.flush();

  std::string plain = stream.str();
  serializeEncrypted(plain, "transfers_synchronizer", cryptoContext, destination);
  cryptoContext.incIv();
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:9,代码来源:WalletSerialization.cpp

示例15: loadWallets

void WalletSerializer::loadWallets(Common::IInputStream& source, CryptoContext& cryptoContext) {
  auto& index = m_walletsContainer.get<RandomAccessIndex>();

  uint64_t count = 0;
  deserializeEncrypted(count, "wallets_count", cryptoContext, source);
  cryptoContext.incIv();

  bool isTrackingMode;

  for (uint64_t i = 0; i < count; ++i) {
    WalletRecordDto dto;
    deserializeEncrypted(dto, "", cryptoContext, source);
    cryptoContext.incIv();

    if (i == 0) {
      isTrackingMode = dto.spendSecretKey == NULL_SECRET_KEY;
    } else if ((isTrackingMode && dto.spendSecretKey != NULL_SECRET_KEY) || (!isTrackingMode && dto.spendSecretKey == NULL_SECRET_KEY)) {
      throw std::system_error(make_error_code(error::BAD_ADDRESS), "All addresses must be whether tracking or not");
    }

    if (dto.spendSecretKey != NULL_SECRET_KEY) {
      Crypto::PublicKey restoredPublicKey;
      bool r = Crypto::secret_key_to_public_key(dto.spendSecretKey, restoredPublicKey);

      if (!r || dto.spendPublicKey != restoredPublicKey) {
        throw std::system_error(make_error_code(error::WRONG_PASSWORD), "Restored spend public key doesn't correspond to secret key");
      }
    } else {
      if (!Crypto::check_key(dto.spendPublicKey)) {
        throw std::system_error(make_error_code(error::WRONG_PASSWORD), "Public spend key is incorrect");
      }
    }

    WalletRecord wallet;
    wallet.spendPublicKey = dto.spendPublicKey;
    wallet.spendSecretKey = dto.spendSecretKey;
    wallet.actualBalance = dto.actualBalance;
    wallet.pendingBalance = dto.pendingBalance;
    wallet.creationTimestamp = static_cast<time_t>(dto.creationTimestamp);
    wallet.container = reinterpret_cast<CryptoNote::ITransfersContainer*>(i); //dirty hack. container field must be unique

    index.push_back(wallet);
  }
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:44,代码来源:WalletSerialization.cpp


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