upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/bip32.h
diff options
context:
space:
mode:
authormtg0001 <106211915+mtg0001@users.noreply.github.com>2026-08-01 12:23:28 -0300
committerGitHub <noreply@github.com>2026-08-01 12:23:28 -0300
commit64b9507846846e468ebba7e00fb59971edceca3b (patch)
tree4ddd4d19289c74cc6c75f7e2cdb9910d1640f751 /src/bip32.h
parent6503250913140ca13104f479d9acd4559284bc6e (diff)
Add BIP39 and BIP32 foundation tests (#83)
Co-authored-by: Gilcimar Duarte <ti@gpm.infra>
Diffstat (limited to 'src/bip32.h')
-rw-r--r--src/bip32.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/bip32.h b/src/bip32.h
new file mode 100644
index 0000000..a029444
--- /dev/null
+++ b/src/bip32.h
@@ -0,0 +1,53 @@
1// Copyright (c) 2026 Bitflash developers
2// Distributed under the MIT/X11 software license.
3//
4// BIP39/BIP32 primitives for deterministic wallet work.
5//
6// This module is deliberately independent from wallet.dat and GUI code. It is
7// the auditable foundation: mnemonic generation/validation, seed derivation,
8// and hardened private child derivation over secp256k1.
9
10#ifndef BITFLASH_BIP32_H
11#define BITFLASH_BIP32_H
12
13#include <string>
14#include <vector>
15
16namespace bitflash
17{
18
19struct BIP32PrivateNode
20{
21 std::vector<unsigned char> privateKey; // 32-byte scalar
22 std::vector<unsigned char> chainCode; // 32 bytes
23};
24
25bool BIP39EntropyToMnemonic(const std::vector<unsigned char>& entropy,
26 std::string& mnemonicOut,
27 std::string& errorOut);
28
29bool BIP39GenerateMnemonic(std::string& mnemonicOut,
30 std::string& errorOut,
31 unsigned int entropyBytes = 16);
32
33bool BIP39ValidateMnemonic(const std::string& mnemonic,
34 std::string& normalizedOut,
35 std::string& errorOut);
36
37bool BIP39MnemonicToSeed(const std::string& mnemonic,
38 const std::string& passphrase,
39 std::vector<unsigned char>& seedOut,
40 std::string& errorOut);
41
42bool BIP32MasterFromSeed(const std::vector<unsigned char>& seed,
43 BIP32PrivateNode& nodeOut,
44 std::string& errorOut);
45
46bool BIP32DeriveHardenedChild(const BIP32PrivateNode& parent,
47 unsigned int childIndex,
48 BIP32PrivateNode& childOut,
49 std::string& errorOut);
50
51} // namespace bitflash
52
53#endif