Skip to content

Commit d3239c7

Browse files
committed
Merge branch 'bright_boson_2.1RC' into mainnet
2 parents 38a0015 + 16f9e82 commit d3239c7

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

core/block_crypt.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,15 @@ namespace beam
159159

160160
void SwitchCommitment::CreateInternal(ECC::Scalar::Native& sk, ECC::Point::Native& comm, bool bComm, Key::IKdf& kdf, const Key::IDV& kidv) const
161161
{
162-
kdf.DeriveKey(sk, kidv);
162+
uint32_t iScheme = kidv.m_SubIdx >> 24;
163+
if (2 == iScheme)
164+
{
165+
Key::IDV kidv2 = kidv;
166+
kidv2.m_SubIdx &= ((1U << 24) - 1);
167+
kdf.DeriveKey(sk, kidv2);
168+
}
169+
else
170+
kdf.DeriveKey(sk, kidv);
163171

164172
comm = ECC::Context::get().G * sk;
165173
AddValue(comm, kidv.m_Value);

wallet/wallet.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,10 @@ namespace beam
615615

616616
void Wallet::OnRequestComplete(MyRequestUtxoEvents& r)
617617
{
618-
const std::vector<proto::UtxoEvent>& v = r.m_Res.m_Events;
618+
std::vector<proto::UtxoEvent>& v = r.m_Res.m_Events;
619619
for (size_t i = 0; i < v.size(); i++)
620620
{
621-
const proto::UtxoEvent& evt = v[i];
621+
proto::UtxoEvent& evt = v[i];
622622

623623
// filter-out false positives
624624
Scalar::Native sk;
@@ -627,6 +627,20 @@ namespace beam
627627

628628
if (comm == evt.m_Commitment)
629629
ProcessUtxoEvent(evt);
630+
else
631+
{
632+
uint32_t iScheme = evt.m_Kidv.m_SubIdx >> 24;
633+
if (!iScheme && evt.m_Kidv.m_SubIdx)
634+
{
635+
// Is it BB2.1?
636+
evt.m_Kidv.m_SubIdx |= (2U << 24);
637+
638+
m_WalletDB->calcCommitment(sk, comm, evt.m_Kidv);
639+
640+
if (comm == evt.m_Commitment)
641+
ProcessUtxoEvent(evt);
642+
}
643+
}
630644
}
631645

632646
if (r.m_Res.m_Events.size() < proto::UtxoEvent::s_Max)

wallet/wallet_db.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,9 +1357,13 @@ namespace beam
13571357
Key::IKdf::Ptr IWalletDB::get_ChildKdf(Key::Index iKdf) const
13581358
{
13591359
Key::IKdf::Ptr pMaster = get_MasterKdf();
1360-
if (!iKdf || pMaster)
1360+
if (!iKdf)
13611361
return pMaster; // by convention 0 is not a childd
13621362

1363+
uint32_t iScheme = iKdf >> 24;
1364+
if (2 == iScheme)
1365+
return pMaster; // workaround!
1366+
13631367
Key::IKdf::Ptr pRet;
13641368
ECC::HKdf::CreateChild(pRet, *pMaster, iKdf);
13651369
return pRet;

0 commit comments

Comments
 (0)