-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecute.h
More file actions
94 lines (75 loc) · 1.67 KB
/
execute.h
File metadata and controls
94 lines (75 loc) · 1.67 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
#ifndef __EXECUTE_H__
#define __EXECUTE_H__ 1
#include "assert.h"
#include "number.h"
#include "small.h"
#include "square.h"
#include "elgamal.h"
#include "command.h"
#include "keytie.h"
namespace BankOfEuler {
struct ExecuteRequest {
const static unsigned int magic = 0x3C8873;
const static unsigned int max_acerts = 64;
Command *command;
KeytieCertificate *kcert;
unsigned int n_acerts;
AuthorizeCertificate *acert;
bool _do_free;
ExecuteRequest() {
command = NULL;
acert = NULL;
kcert = NULL;
n_acerts = 0;
_do_free = 0;
}
~ExecuteRequest() {
if (_do_free) {
if (command)
delete command;
if (kcert)
delete kcert;
if (acert)
delete[] acert;
}
}
void generate(
CTX *ctx,
Command *command,
KeytieCertificate *kcert,
AuthorizeCertificate *acert, unsigned int n_acerts
);
bool verify(CTX *ctx) const;
void read(FILE *fp, bool rm = 1);
void write(FILE *fp) const;
};
struct ExecuteCertificate {
const static unsigned int magic = 0x3C99923;
Number cmd_hash;
Number ktc_hash;
Number result;
time_t t;
Number h, sh;
void generate(SCTX *sctx, const Number &cmd_hash, const ExecuteRequest &req, const Number &result);
bool verify(CTX *ctx) const;
void read(FILE *fp, bool rm = 1) {
if (rm) assert(magic == read_int32(fp));
cmd_hash.read(fp);
ktc_hash.read(fp);
result.read(fp);
t = read_int32(fp);
h.read(fp);
sh.read(fp);
}
void write(FILE *fp) const {
write_int32(magic, fp);
cmd_hash.write(fp);
ktc_hash.write(fp);
result.write(fp);
write_int32(t, fp);
h.write(fp);
sh.write(fp);
}
};
}
#endif