forked from BeamMW/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeykeeper.h
98 lines (73 loc) · 2.78 KB
/
keykeeper.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
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
// Copyright 2018 The Beam Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include "kdf.h"
#include "coinid.h"
#include "sign.h"
typedef struct
{
BeamCrypto_Kdf m_MasterKey;
int m_AllowWeakInputs;
// TODO: state, Slot management, etc.
} BeamCrypto_KeyKeeper;
uint32_t BeamCrypto_KeyKeeper_getNumSlots();
void BeamCrypto_KeyKeeper_ReadSlot(uint32_t, BeamCrypto_UintBig*);
void BeamCrypto_KeyKeeper_RegenerateSlot(uint32_t);
typedef struct
{
BeamCrypto_UintBig m_Secret;
BeamCrypto_CompactPoint m_CoFactorG;
BeamCrypto_CompactPoint m_CoFactorJ;
} BeamCrypto_KdfPub;
void BeamCrypto_KeyKeeper_GetPKdf(const BeamCrypto_KeyKeeper*, BeamCrypto_KdfPub*, const uint32_t* pChild); // if pChild is NULL then the master kdfpub (owner key) is returned
typedef uint64_t BeamCrypto_Height;
typedef uint64_t BeamCrypto_WalletIdentity;
typedef struct
{
BeamCrypto_Amount m_Fee;
BeamCrypto_Height m_hMin;
BeamCrypto_Height m_hMax;
BeamCrypto_CompactPoint m_Commitment;
BeamCrypto_Signature m_Signature;
} BeamCrypto_TxKernel;
void BeamCrypto_TxKernel_getID(const BeamCrypto_TxKernel*, BeamCrypto_UintBig* pMsg);
int BeamCrypto_TxKernel_IsValid(const BeamCrypto_TxKernel*);
typedef struct
{
const BeamCrypto_CoinID* m_pIns;
const BeamCrypto_CoinID* m_pOuts;
unsigned int m_Ins;
unsigned int m_Outs;
BeamCrypto_TxKernel m_Krn;
BeamCrypto_UintBig m_kOffset;
} BeamCrypto_TxCommon;
#define BeamCrypto_KeyKeeper_Status_Ok 0
#define BeamCrypto_KeyKeeper_Status_Unspecified 1
#define BeamCrypto_KeyKeeper_Status_UserAbort 2
#define BeamCrypto_KeyKeeper_Status_NotImpl 3
// Split tx, no value transfer. Only fee is spent (hence the user agreement is required)
int BeamCrypto_KeyKeeper_SignTx_Split(const BeamCrypto_KeyKeeper*, BeamCrypto_TxCommon*);
typedef struct
{
BeamCrypto_UintBig m_Peer;
BeamCrypto_WalletIdentity m_MyIDKey;
BeamCrypto_Signature m_PaymentProofSignature;
} BeamCrypto_TxMutualInfo;
int BeamCrypto_KeyKeeper_SignTx_Receive(const BeamCrypto_KeyKeeper*, BeamCrypto_TxCommon*, BeamCrypto_TxMutualInfo*);
typedef struct
{
uint32_t m_iSlot;
BeamCrypto_UintBig m_UserAgreement; // set to Zero on 1st invocation
} BeamCrypto_TxSenderParams;
int BeamCrypto_KeyKeeper_SignTx_Send(const BeamCrypto_KeyKeeper*, BeamCrypto_TxCommon*, BeamCrypto_TxMutualInfo*, BeamCrypto_TxSenderParams*);