MCPcopy Create free account
hub / github.com/bcndev/bytecoin / decrypt_data

Method decrypt_data

src/Core/WalletHDsqlite.cpp:250–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248}
249
250BinaryArray WalletHDsqlite::decrypt_data(const chacha_key &wallet_key, const uint8_t *value_data, size_t value_size) {
251 Hash iv;
252 invariant(value_size >= 4 + sizeof(Hash), "");
253 memcpy(iv.data, value_data, sizeof(Hash));
254 BinaryArray result(value_size - sizeof(Hash));
255 BinaryArray key_data = wallet_key.as_binary_array() | iv.as_binary_array();
256 chacha_key key{cn_fast_hash(key_data)};
257 chacha(20, value_data + sizeof(Hash), result.size(), key, chacha_iv{}, result.data());
258 auto real_size = uint_le_from_bytes<size_t>(result.data(), 4);
259 invariant(real_size <= result.size() - 4, "");
260 return BinaryArray{result.data() + 4, result.data() + 4 + real_size};
261}
262
263void WalletHDsqlite::put_salt(const BinaryArray &salt) {
264 sqlite::Stmt stmt_update;

Callers

nothing calls this directly

Calls 5

cn_fast_hashFunction · 0.85
chachaFunction · 0.85
as_binary_arrayMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected