forked from breadwallet/breadwallet-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBRCryptoKey.h
More file actions
103 lines (73 loc) · 2.7 KB
/
BRCryptoKey.h
File metadata and controls
103 lines (73 loc) · 2.7 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//
// BRCryptoKey.h
// BRCore
//
// Created by Ed Gamble on 7/30/19.
// Copyright © 2019 Breadwinner AG. All rights reserved.
//
// See the LICENSE file at the project root for license information.
// See the CONTRIBUTORS file at the project root for a list of contributors.
#ifndef BRCryptoKey_h
#define BRCryptoKey_h
#include "BRCryptoBase.h"
#ifdef __cplusplus
extern "C" {
#endif
/// MARK: - Crypto Secret
typedef struct {
uint8_t data[256/8];
} BRCryptoSecret;
static inline void cryptoSecretClear (BRCryptoSecret *secret) {
memset (secret->data, 0, sizeof (secret->data));
}
/// MARK: Crypto Key
typedef struct BRCryptoKeyRecord *BRCryptoKey;
extern BRCryptoBoolean
cryptoKeyIsProtectedPrivate (const char *privateKey);
extern BRCryptoKey
cryptoKeyCreateFromSecret (BRCryptoSecret secret);
extern BRCryptoKey
cryptoKeyCreateFromPhraseWithWords (const char *phrase, const char *words[]);
extern BRCryptoKey
cryptoKeyCreateFromStringProtectedPrivate (const char *privateKey, const char * passphrase);
extern BRCryptoKey
cryptoKeyCreateFromStringPrivate (const char *string);
extern BRCryptoKey
cryptoKeyCreateFromStringPublic (const char *string);
// extern BRCryptoKey
// cryptoKeyCreateFromSerializationPublic (uint8_t *data, size_t dataCount);
//
// extern BRCryptoKey
// cryptoKeyCreateFromSerializationPrivate (uint8_t *data, size_t dataCount);
//
extern BRCryptoKey
cryptoKeyCreateForPigeon (BRCryptoKey key, uint8_t *nonce, size_t nonceCount);
extern BRCryptoKey
cryptoKeyCreateForBIP32ApiAuth (const char *phrase, const char *words[]);
extern BRCryptoKey
cryptoKeyCreateForBIP32BitID (const char *phrase, int index, const char *uri, const char *words[]);
extern size_t
cryptoKeySerializePublic (BRCryptoKey key, /* ... */ uint8_t *data, size_t dataCount);
extern size_t
cryptoKeySerializePrivate(BRCryptoKey key, /* ... */ uint8_t *data, size_t dataCount);
extern int
cryptoKeyHasSecret (BRCryptoKey key);
extern char *
cryptoKeyEncodePrivate (BRCryptoKey key);
extern char *
cryptoKeyEncodePublic (BRCryptoKey key);
extern BRCryptoSecret
cryptoKeyGetSecret (BRCryptoKey key);
extern int
cryptoKeySecretMatch (BRCryptoKey key1, BRCryptoKey key2);
extern int
cryptoKeyPublicMatch (BRCryptoKey key1, BRCryptoKey key2);
// extern size_t
// cryptoKeySign (BRCryptoKey key, void *sig, size_t sigLen, UInt256 md);
extern void
cryptoKeyProvidePublicKey (BRCryptoKey key, int useCompressed, int compressed);
DECLARE_CRYPTO_GIVE_TAKE (BRCryptoKey, cryptoKey);
#ifdef __cplusplus
}
#endif
#endif /* BRCryptoKey_h */