-
Notifications
You must be signed in to change notification settings - Fork 252
/
BTCEncryptedBackup.h
46 lines (33 loc) · 1.78 KB
/
BTCEncryptedBackup.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
41
42
43
44
45
46
// CoreBitcoin by Oleg Andreev <oleganza@gmail.com>, WTFPL.
// Implementation of [Automatic Encrypted Wallet Backups](https://github.com/oleganza/bitcoin-papers/blob/master/AutomaticEncryptedWalletBackups.md) scheme.
// For test vectors, see unit tests (BTCEncryptedBackup+Tests.m).
#import <Foundation/Foundation.h>
typedef NS_ENUM(unsigned char, BTCEncryptedBackupVersion) {
BTCEncryptedBackupVersion1 = 0x01,
};
@class BTCNetwork;
@class BTCKey;
@interface BTCEncryptedBackup : NSObject
// Default version is BTCEncryptedBackupVersion1.
@property(nonatomic, readonly) BTCEncryptedBackupVersion version;
// Timestamp of the backup. If not specified, during encryption set to current time.
@property(nonatomic, readonly) NSTimeInterval timestamp;
@property(nonatomic, readonly) NSDate* date;
@property(nonatomic, readonly) NSData* decryptedData;
@property(nonatomic, readonly) NSData* encryptedData;
@property(nonatomic, readonly) NSString* walletID;
@property(nonatomic, readonly) BTCKey* authenticationKey;
+ (instancetype) encrypt:(NSData*)data backupKey:(NSData*)backupKey;
+ (instancetype) encrypt:(NSData*)data backupKey:(NSData*)backupKey timestamp:(NSTimeInterval)timestamp;
+ (instancetype) decrypt:(NSData*)data backupKey:(NSData*)backupKey;
+ (NSData*) backupKeyForNetwork:(BTCNetwork*)network masterKey:(NSData*)masterKey;
+ (BTCKey*) authenticationKeyWithBackupKey:(NSData*)backupKey;
+ (NSString*) walletIDWithAuthenticationKey:(NSData*)authPubkey;
// For testing/audit purposes only:
@property(nonatomic, readonly) NSData* encryptionKey;
@property(nonatomic, readonly) NSData* iv;
@property(nonatomic, readonly) NSData* merkleRoot;
@property(nonatomic, readonly) NSData* ciphertext;
@property(nonatomic, readonly) NSData* dataForSigning;
@property(nonatomic, readonly) NSData* signature;
@end