forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 719
/
Copy pathbip38.h
40 lines (26 loc) · 1.43 KB
/
bip38.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2017 The PIVX developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_BIP38_H
#define BITCOIN_BIP38_H
#include "pubkey.h"
#include "uint256.h"
#include <string>
/** 39 bytes - 78 characters
* 1) Prefix - 2 bytes - 4 chars - strKey[0..3]
* 2) Flagbyte - 1 byte - 2 chars - strKey[4..5]
* 3) addresshash - 4 bytes - 8 chars - strKey[6..13]
* 4) Owner Entropy - 8 bytes - 16 chars - strKey[14..29]
* 5) Encrypted Part 1 - 8 bytes - 16 chars - strKey[30..45]
* 6) Encrypted Part 2 - 16 bytes - 32 chars - strKey[46..77]
*/
void DecryptAES(uint256 encryptedIn, uint256 decryptionKey, uint256& output);
void ComputePreFactor(std::string strPassphrase, std::string strSalt, uint256& prefactor);
void ComputePassfactor(std::string ownersalt, uint256 prefactor, uint256& passfactor);
bool ComputePasspoint(uint256 passfactor, CPubKey& passpoint);
void ComputeSeedBPass(CPubKey passpoint, std::string strAddressHash, std::string strOwnerSalt, uint512& seedBPass);
void ComputeFactorB(uint256 seedB, uint256& factorB);
std::string BIP38_Encrypt(std::string strAddress, std::string strPassphrase, uint256 privKey, bool fCompressed);
bool BIP38_Decrypt(std::string strPassphrase, std::string strEncryptedKey, uint256& privKey, bool& fCompressed);
std::string AddressToBip38Hash(const std::string& address);
#endif // BIP38_H