133 #include "../core/stdafx.hpp"
139 #include "../core/crypto/OTAsymmetricKey.hpp"
140 #include "../core/crypto/OTEnvelope.hpp"
142 #if defined(OT_CASH_USING_LUCRE)
143 #include "../core/crypto/OpenSSL_BIO.hpp"
146 #include "../core/OTLog.hpp"
147 #include "../core/OTPseudonym.hpp"
152 #if defined(OT_CASH_USING_LUCRE)
161 :
ot_super(strServerID, strAssetTypeID)
168 :
ot_super(strServerID, strServerNymID, strAssetTypeID)
178 #if defined(OT_CASH_USING_LUCRE)
185 BIO* out = BIO_new_file(filepathexact,
"w");
193 int32_t nPrimeLength)
197 bool bReturnValue =
false;
201 if (
GetPublic(theArmor, lDenomination)) {
203 otErr <<
"Error: Denomination public already exists in "
204 "OTMint::AddDenomination\n";
209 otErr <<
"Error: Denomination private already exists in "
210 "OTMint::AddDenomination\n";
218 otErr <<
"Prime must be at least "
223 if (nPrimeLength % 8) {
224 otErr <<
"Prime length must be a multiple of 8\n";
238 Bank bank(nPrimeLength / 8);
246 char privateBankBuffer[4096],
247 publicBankBuffer[4096];
248 int32_t privatebankLen =
249 BIO_read(bio, privateBankBuffer, 4000);
251 int32_t publicbankLen =
252 BIO_read(bioPublic, publicBankBuffer,
255 if (privatebankLen && publicbankLen) {
259 strPublicBank.
Set(publicBankBuffer, publicbankLen);
261 strPrivateBank.
Set(privateBankBuffer, privatebankLen);
275 theEnvelope.
Seal(theNotary, strPrivateBank);
297 otWarn <<
"Successfully added denomination: " << lDenomination <<
"\n";
303 #endif // defined (OT_CASH_USING_LUCRE)
339 #if defined(OT_CASH_USING_LUCRE) && defined(OT_CRYPTO_USING_OPENSSL)
344 OTString& theOutput, int32_t nTokenIndex)
346 bool bReturnValue =
false;
369 if (!theEnvelope.Open(theNotary, strContents))
return false;
372 BIO_puts(bioBank, strContents.
Get());
383 bool bFoundToken = theToken.
GetPrototoken(ascPrototoken, nTokenIndex);
387 OTString strPrototoken(ascPrototoken);
395 BIO_puts(bioRequest, strPrototoken.
Get());
404 BIGNUM* bnSignature = bank.SignRequest(req);
406 if (
nullptr == bnSignature) {
407 otErr <<
"MAJOR ERROR!: Bank.SignRequest failed in "
408 "MintLucre::SignToken\n";
416 req.WriteBIO(bioSignature);
419 BN_free(bnSignature);
427 int32_t sig_len = BIO_read(bioSignature, sig_buf,
434 sig_buf[sig_len] =
'\0';
468 theOutput.
Set(sig_buf, sig_len);
488 int64_t lDenomination)
490 bool bReturnValue =
false;
498 BIO_puts(bioCoin, theCleartextToken.
Get());
508 if (theEnvelope.
Open(theNotary, strContents)) {
510 BIO_puts(bioBank, strContents.
Get());
517 if (bank.Verify(coin))
550 #endif // defined(OT_CASH_USING_LUCRE) && defined(OT_CRYPTO_USING_OPENSSL)
virtual EXPORT bool VerifyToken(OTPseudonym &theNotary, OTString &theCleartextToken, int64_t lDenomination)
virtual OTAsymmetricKey * ClonePubKey() const
virtual bool AddDenomination(OTPseudonym &theNotary, int64_t lDenomination, int32_t nPrimeLength=1024)
EXPORT bool GetPrototoken(OTASCIIArmor &ascPrototoken, int32_t nTokenIndex)
bool GetPrivate(OTASCIIArmor &theArmor, int64_t lDenomination)
EXPORT void GetIdentifier(OTIdentifier &theIdentifier) const
void DumpNumber(BIO *out, const char *szTitle, const BIGNUM *bn, const char *szTrailer=_NL)
OTIdentifier m_ServerNymID
EXPORT bool Open(const OTPseudonym &theRecipient, OTString &theOutput, const OTPasswordData *pPWData=nullptr)
EXPORT bool Seal(const OTPseudonym &theRecipient, const OTString &theInput)
EXPORT bool SetString(const OTString &theData, bool bLineBreaks=true)
bool GetPublic(OTASCIIArmor &theArmor, int64_t lDenomination)
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
void SetMonitor(const char *filepathexact)
EXPORT bool GetAsciiArmoredData(OTASCIIArmor &theArmoredText, bool bLineBreaks=true) const
int64_t GetDenomination() const
virtual EXPORT ~MintLucre()
void SetSeriesAndExpiration(int32_t nSeries, time64_t VALID_FROM, time64_t VALID_TO)
virtual EXPORT bool SignToken(OTPseudonym &theNotary, Token &theToken, OTString &theOutput, int32_t nTokenIndex)
OTAsymmetricKey * m_pKeyPublic
EXPORT const OTAsymmetricKey & GetPublicSignKey() const
OTLOG_IMPORT OTLogStream otWarn
EXPORT const char * Get() const
int32_t m_nDenominationCount
OTLOG_IMPORT OTLogStream otErr
void SetSpendable(const OTASCIIArmor &theArmor)