本文整理汇总了C++中OTPseudonym::GetPublicSignKey方法的典型用法代码示例。如果您正苦于以下问题:C++ OTPseudonym::GetPublicSignKey方法的具体用法?C++ OTPseudonym::GetPublicSignKey怎么用?C++ OTPseudonym::GetPublicSignKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OTPseudonym
的用法示例。
在下文中一共展示了OTPseudonym::GetPublicSignKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddDenomination
// The mint has a different key pair for each denomination.
// Pass the actual denomination such as 5, 10, 20, 50, 100...
bool OTMint_Lucre::AddDenomination(OTPseudonym & theNotary, int64_t lDenomination, int32_t nPrimeLength/*=1024*/)
{
OT_ASSERT(NULL != m_pKeyPublic);
bool bReturnValue = false;
// Let's make sure it doesn't already exist
OTASCIIArmor theArmor;
if (GetPublic(theArmor, lDenomination))
{
// it already exists.
OTLog::Error("Error: Denomination public already exists in OTMint::AddDenomination\n");
return false;
}
if (GetPrivate(theArmor, lDenomination))
{
// it already exists.
OTLog::Error("Error: Denomination private already exists in OTMint::AddDenomination\n");
return false;
}
// OTLog::Error("%s <size of bank prime in bits> <bank data file> <bank public data file>\n",
if ((nPrimeLength/8) < (MIN_COIN_LENGTH+DIGEST_LENGTH))
{
OTLog::vError("Prime must be at least %d bits\n",
(MIN_COIN_LENGTH+DIGEST_LENGTH)*8);
return false;
}
if (nPrimeLength%8)
{
OTLog::Error("Prime length must be a multiple of 8\n");
return false;
}
#ifdef _WIN32
SetMonitor("openssl.dump");
#else
SetMonitor(stderr);
#endif
OpenSSL_BIO bio = BIO_new(BIO_s_mem());
OpenSSL_BIO bioPublic = BIO_new(BIO_s_mem());
// Generate the mint private key information
Bank bank(nPrimeLength/8);
bank.WriteBIO(bio);
// Generate the mint public key information
PublicBank pbank(bank);
pbank.WriteBIO(bioPublic);
// Copy from BIO back to a normal OTString or Ascii-Armor
char privateBankBuffer[4096], publicBankBuffer[4096]; // todo stop hardcoding these string lengths
int32_t privatebankLen = BIO_read(bio, privateBankBuffer, 4000); // cutting it a little short on purpose, with the buffer.
int32_t publicbankLen = BIO_read(bioPublic, publicBankBuffer, 4000); // Just makes me feel more comfortable for some reason.
if (privatebankLen && publicbankLen)
{
// With this, we have the Lucre public and private bank info converted to OTStrings
OTString strPublicBank; strPublicBank.Set(publicBankBuffer, publicbankLen);
OTString strPrivateBank; strPrivateBank.Set(privateBankBuffer, privatebankLen);
OTASCIIArmor * pPublic = new OTASCIIArmor();
OTASCIIArmor * pPrivate = new OTASCIIArmor();
OT_ASSERT(NULL != pPublic);
OT_ASSERT(NULL != pPrivate);
// Set the public bank info onto pPublic
pPublic->SetString(strPublicBank, true); // linebreaks = true
// Seal the private bank info up into an encrypted Envelope
// and set it onto pPrivate
OTEnvelope theEnvelope;
theEnvelope.Seal(theNotary, strPrivateBank); // Todo check the return values on these two functions
theEnvelope.GetAsciiArmoredData(*pPrivate);
// Add the new key pair to the maps, using denomination as the key
m_mapPublic[lDenomination] = pPublic;
m_mapPrivate[lDenomination] = pPrivate;
// Grab the Server Nym ID and save it with this Mint
theNotary.GetIdentifier(m_ServerNymID);
// ---------------------------
// Grab the Server's public key and save it with this Mint
//
const OTAsymmetricKey & theNotaryPubKey = theNotary.GetPublicSignKey();
delete m_pKeyPublic;
m_pKeyPublic = theNotaryPubKey.ClonePubKey();
// ---------------------------
m_nDenominationCount++;
// ---------------------------
// Success!
bReturnValue = true;
OTLog::vOutput(1, "Successfully added denomination: %lld\n", lDenomination);
}
//.........这里部分代码省略.........