Changeset View
Changeset View
Standalone View
Standalone View
src/key.cpp
Show First 20 Lines • Show All 333 Lines • ▼ Show 20 Lines | |||||
bool CExtKey::Derive(CExtKey &out, unsigned int _nChild) const { | bool CExtKey::Derive(CExtKey &out, unsigned int _nChild) const { | ||||
out.nDepth = nDepth + 1; | out.nDepth = nDepth + 1; | ||||
CKeyID id = key.GetPubKey().GetID(); | CKeyID id = key.GetPubKey().GetID(); | ||||
memcpy(&out.vchFingerprint[0], &id, 4); | memcpy(&out.vchFingerprint[0], &id, 4); | ||||
out.nChild = _nChild; | out.nChild = _nChild; | ||||
return key.Derive(out.key, out.chaincode, _nChild, chaincode); | return key.Derive(out.key, out.chaincode, _nChild, chaincode); | ||||
} | } | ||||
void CExtKey::SetMaster(const uint8_t *seed, unsigned int nSeedLen) { | void CExtKey::SetSeed(const uint8_t *seed, unsigned int nSeedLen) { | ||||
static const uint8_t hashkey[] = {'B', 'i', 't', 'c', 'o', 'i', | static const uint8_t hashkey[] = {'B', 'i', 't', 'c', 'o', 'i', | ||||
'n', ' ', 's', 'e', 'e', 'd'}; | 'n', ' ', 's', 'e', 'e', 'd'}; | ||||
std::vector<uint8_t, secure_allocator<uint8_t>> vout(64); | std::vector<uint8_t, secure_allocator<uint8_t>> vout(64); | ||||
CHMAC_SHA512(hashkey, sizeof(hashkey)) | CHMAC_SHA512(hashkey, sizeof(hashkey)) | ||||
.Write(seed, nSeedLen) | .Write(seed, nSeedLen) | ||||
.Finalize(vout.data()); | .Finalize(vout.data()); | ||||
key.Set(vout.data(), vout.data() + 32, true); | key.Set(vout.data(), vout.data() + 32, true); | ||||
memcpy(chaincode.begin(), vout.data() + 32, 32); | memcpy(chaincode.begin(), vout.data() + 32, 32); | ||||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |