forked from keybase/go-keybase-chat-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rekey.go
169 lines (151 loc) · 3.58 KB
/
rekey.go
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// Auto-generated to Go types using avdl-compiler v1.4.6 (https://github.com/malware-unicorn/node-avdl-compiler)
// Input file: ../client/protocol/avdl/keybase1/rekey.avdl
package keybase1
import (
"fmt"
)
type TLF struct {
Id TLFID `codec:"id" json:"id"`
Name string `codec:"name" json:"name"`
Writers []string `codec:"writers" json:"writers"`
Readers []string `codec:"readers" json:"readers"`
IsPrivate bool `codec:"isPrivate" json:"isPrivate"`
}
func (o TLF) DeepCopy() TLF {
return TLF{
Id: o.Id.DeepCopy(),
Name: o.Name,
Writers: (func(x []string) []string {
if x == nil {
return nil
}
ret := make([]string, len(x))
for i, v := range x {
vCopy := v
ret[i] = vCopy
}
return ret
})(o.Writers),
Readers: (func(x []string) []string {
if x == nil {
return nil
}
ret := make([]string, len(x))
for i, v := range x {
vCopy := v
ret[i] = vCopy
}
return ret
})(o.Readers),
IsPrivate: o.IsPrivate,
}
}
type ProblemTLF struct {
Tlf TLF `codec:"tlf" json:"tlf"`
Score int `codec:"score" json:"score"`
Solution_kids []KID `codec:"solution_kids" json:"solution_kids"`
}
func (o ProblemTLF) DeepCopy() ProblemTLF {
return ProblemTLF{
Tlf: o.Tlf.DeepCopy(),
Score: o.Score,
Solution_kids: (func(x []KID) []KID {
if x == nil {
return nil
}
ret := make([]KID, len(x))
for i, v := range x {
vCopy := v.DeepCopy()
ret[i] = vCopy
}
return ret
})(o.Solution_kids),
}
}
// ProblemSet is for a particular (user,kid) that initiated a rekey problem.
// This problem consists of one or more problem TLFs, which are individually scored
// and have attendant solutions --- devices that if they came online can rekey and
// solve the ProblemTLF.
type ProblemSet struct {
User User `codec:"user" json:"user"`
Kid KID `codec:"kid" json:"kid"`
Tlfs []ProblemTLF `codec:"tlfs" json:"tlfs"`
}
func (o ProblemSet) DeepCopy() ProblemSet {
return ProblemSet{
User: o.User.DeepCopy(),
Kid: o.Kid.DeepCopy(),
Tlfs: (func(x []ProblemTLF) []ProblemTLF {
if x == nil {
return nil
}
ret := make([]ProblemTLF, len(x))
for i, v := range x {
vCopy := v.DeepCopy()
ret[i] = vCopy
}
return ret
})(o.Tlfs),
}
}
type ProblemSetDevices struct {
ProblemSet ProblemSet `codec:"problemSet" json:"problemSet"`
Devices []Device `codec:"devices" json:"devices"`
}
func (o ProblemSetDevices) DeepCopy() ProblemSetDevices {
return ProblemSetDevices{
ProblemSet: o.ProblemSet.DeepCopy(),
Devices: (func(x []Device) []Device {
if x == nil {
return nil
}
ret := make([]Device, len(x))
for i, v := range x {
vCopy := v.DeepCopy()
ret[i] = vCopy
}
return ret
})(o.Devices),
}
}
type Outcome int
const (
Outcome_NONE Outcome = 0
Outcome_FIXED Outcome = 1
Outcome_IGNORED Outcome = 2
)
func (o Outcome) DeepCopy() Outcome { return o }
var OutcomeMap = map[string]Outcome{
"NONE": 0,
"FIXED": 1,
"IGNORED": 2,
}
var OutcomeRevMap = map[Outcome]string{
0: "NONE",
1: "FIXED",
2: "IGNORED",
}
func (e Outcome) String() string {
if v, ok := OutcomeRevMap[e]; ok {
return v
}
return fmt.Sprintf("%v", int(e))
}
type RevokeWarning struct {
EndangeredTLFs []TLF `codec:"endangeredTLFs" json:"endangeredTLFs"`
}
func (o RevokeWarning) DeepCopy() RevokeWarning {
return RevokeWarning{
EndangeredTLFs: (func(x []TLF) []TLF {
if x == nil {
return nil
}
ret := make([]TLF, len(x))
for i, v := range x {
vCopy := v.DeepCopy()
ret[i] = vCopy
}
return ret
})(o.EndangeredTLFs),
}
}