本文整理汇总了C++中OTPseudonym::GenerateNym方法的典型用法代码示例。如果您正苦于以下问题:C++ OTPseudonym::GenerateNym方法的具体用法?C++ OTPseudonym::GenerateNym怎么用?C++ OTPseudonym::GenerateNym使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OTPseudonym
的用法示例。
在下文中一共展示了OTPseudonym::GenerateNym方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateInternalNym
// ----------------------------------------------------
// INTERNAL NYM: For adding a PASSPHRASE to a PURSE.
//
// What if you DON'T want to encrypt the purse to your Nym??
// What if you just want to use a passphrase instead?
// That's what these functions are for. OT just generates
// a dummy Nym and stores it INSIDE THE PURSE. You set the
// passphrase for the dummy nym, and thereafter your
// experience is one of a password-protected purse. (But
// in reality, there is a dummy nym inside that purse.)
//
bool OTPurse::GenerateInternalNym(int nBits/*=1024*/)
{
// -------------------------------------------
if (this->IsUsingATempNym() || (NULL != this->GetInternalNym()))
{
OTLog::Output(0, "OTPurse::GenerateInternalNym: Failed: internal Nym already exists.\n");
return false;
}
// -------------------------------------------
if (!this->IsEmpty())
{
OTLog::Output(0, "OTPurse::GenerateInternalNym: Failed: The purse must be EMPTY before you create a new dummy Nym, internal to that purse. (For the purposes of adding a passphrase to the purse, normally.)\n");
return false;
}
// -------------------------------------------
switch (nBits)
{
case 1024: // todo hardcoding.
case 2048:
case 4096:
case 8192:
break;
default:
OTLog::vError("OTPurse::GenerateInternalNym: Failure: nBits must be one of: "
"1024, 2048, 4096, 8192. (%d was passed...)\n", nBits);
return false;
}
// -------------------------------------------
OTPseudonym * pNym = new OTPseudonym;
OT_ASSERT_MSG(NULL != pNym, "OTPurse::GenerateInternalNym: Assert: NULL != new OTPseudonym \n");
// BELOW THIS point, pNym must either be deleted, or saved. (Or it will leak.)
// --------------------------------------------
if (false == pNym->GenerateNym(nBits, false)) // bCreateFile=true by default, but it's FALSE here.
{
OTLog::vOutput(0, "OTPurse::GenerateInternalNym: Failed while calling pNym->GenerateNym(%d, false).\n",
nBits);
delete pNym;
pNym = NULL;
return false;
}
// ---------------------------------------------------
const bool bSetIdentifier = pNym->SetIdentifierByPubkey();
OT_ASSERT_MSG(bSetIdentifier, "OTPurse::GenerateInternalNym: Assert: pNym->SetIdentifierByPubkey() \n");
// By this point, the Nym has been successfully generated, and he even has an ID!
// Let's attach him to the purse so we don't have to keep worrying about a leak.
//
m_pTempNym = pNym;
// ----------------------------
// Let's make sure the new Nym's ID is also this purse's UserID...
//
pNym->GetIdentifier(m_UserID);
m_bUsingTempNym = true;
m_bIsNymIDIncluded = true;
return true;
}