github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/keybase1/upk.go (about) 1 // Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler) 2 // Input file: avdl/keybase1/upk.avdl 3 4 package keybase1 5 6 import ( 7 "errors" 8 "fmt" 9 "github.com/keybase/go-framed-msgpack-rpc/rpc" 10 ) 11 12 type KeyType int 13 14 const ( 15 KeyType_NONE KeyType = 0 16 KeyType_NACL KeyType = 1 17 KeyType_PGP KeyType = 2 18 ) 19 20 func (o KeyType) DeepCopy() KeyType { return o } 21 22 var KeyTypeMap = map[string]KeyType{ 23 "NONE": 0, 24 "NACL": 1, 25 "PGP": 2, 26 } 27 28 var KeyTypeRevMap = map[KeyType]string{ 29 0: "NONE", 30 1: "NACL", 31 2: "PGP", 32 } 33 34 func (e KeyType) String() string { 35 if v, ok := KeyTypeRevMap[e]; ok { 36 return v 37 } 38 return fmt.Sprintf("%v", int(e)) 39 } 40 41 type UPK2MinorVersion int 42 43 const ( 44 UPK2MinorVersion_V0 UPK2MinorVersion = 0 45 UPK2MinorVersion_V1 UPK2MinorVersion = 1 46 UPK2MinorVersion_V2 UPK2MinorVersion = 2 47 UPK2MinorVersion_V3 UPK2MinorVersion = 3 48 UPK2MinorVersion_V4 UPK2MinorVersion = 4 49 UPK2MinorVersion_V5 UPK2MinorVersion = 5 50 UPK2MinorVersion_V6 UPK2MinorVersion = 6 51 ) 52 53 func (o UPK2MinorVersion) DeepCopy() UPK2MinorVersion { return o } 54 55 var UPK2MinorVersionMap = map[string]UPK2MinorVersion{ 56 "V0": 0, 57 "V1": 1, 58 "V2": 2, 59 "V3": 3, 60 "V4": 4, 61 "V5": 5, 62 "V6": 6, 63 } 64 65 var UPK2MinorVersionRevMap = map[UPK2MinorVersion]string{ 66 0: "V0", 67 1: "V1", 68 2: "V2", 69 3: "V3", 70 4: "V4", 71 5: "V5", 72 6: "V6", 73 } 74 75 func (e UPK2MinorVersion) String() string { 76 if v, ok := UPK2MinorVersionRevMap[e]; ok { 77 return v 78 } 79 return fmt.Sprintf("%v", int(e)) 80 } 81 82 type MerkleRootV2 struct { 83 Seqno Seqno `codec:"seqno" json:"seqno"` 84 HashMeta HashMeta `codec:"hashMeta" json:"hashMeta"` 85 } 86 87 func (o MerkleRootV2) DeepCopy() MerkleRootV2 { 88 return MerkleRootV2{ 89 Seqno: o.Seqno.DeepCopy(), 90 HashMeta: o.HashMeta.DeepCopy(), 91 } 92 } 93 94 type SigChainLocation struct { 95 Seqno Seqno `codec:"seqno" json:"seqno"` 96 SeqType SeqType `codec:"seqType" json:"seqType"` 97 } 98 99 func (o SigChainLocation) DeepCopy() SigChainLocation { 100 return SigChainLocation{ 101 Seqno: o.Seqno.DeepCopy(), 102 SeqType: o.SeqType.DeepCopy(), 103 } 104 } 105 106 type MerkleTreeLocation struct { 107 Leaf UserOrTeamID `codec:"leaf" json:"leaf"` 108 Loc SigChainLocation `codec:"loc" json:"loc"` 109 } 110 111 func (o MerkleTreeLocation) DeepCopy() MerkleTreeLocation { 112 return MerkleTreeLocation{ 113 Leaf: o.Leaf.DeepCopy(), 114 Loc: o.Loc.DeepCopy(), 115 } 116 } 117 118 type SignatureMetadata struct { 119 SigningKID KID `codec:"signingKID" json:"signingKID"` 120 PrevMerkleRootSigned MerkleRootV2 `codec:"prevMerkleRootSigned" json:"prevMerkleRootSigned"` 121 FirstAppearedUnverified Seqno `codec:"firstAppearedUnverified" json:"firstAppearedUnverified"` 122 Time Time `codec:"time" json:"time"` 123 SigChainLocation SigChainLocation `codec:"sigChainLocation" json:"sigChainLocation"` 124 } 125 126 func (o SignatureMetadata) DeepCopy() SignatureMetadata { 127 return SignatureMetadata{ 128 SigningKID: o.SigningKID.DeepCopy(), 129 PrevMerkleRootSigned: o.PrevMerkleRootSigned.DeepCopy(), 130 FirstAppearedUnverified: o.FirstAppearedUnverified.DeepCopy(), 131 Time: o.Time.DeepCopy(), 132 SigChainLocation: o.SigChainLocation.DeepCopy(), 133 } 134 } 135 136 type PublicKeyV2Base struct { 137 Kid KID `codec:"kid" json:"kid"` 138 IsSibkey bool `codec:"isSibkey" json:"isSibkey"` 139 IsEldest bool `codec:"isEldest" json:"isEldest"` 140 CTime Time `codec:"cTime" json:"cTime"` 141 ETime Time `codec:"eTime" json:"eTime"` 142 Provisioning SignatureMetadata `codec:"provisioning" json:"provisioning"` 143 Revocation *SignatureMetadata `codec:"revocation,omitempty" json:"revocation,omitempty"` 144 } 145 146 func (o PublicKeyV2Base) DeepCopy() PublicKeyV2Base { 147 return PublicKeyV2Base{ 148 Kid: o.Kid.DeepCopy(), 149 IsSibkey: o.IsSibkey, 150 IsEldest: o.IsEldest, 151 CTime: o.CTime.DeepCopy(), 152 ETime: o.ETime.DeepCopy(), 153 Provisioning: o.Provisioning.DeepCopy(), 154 Revocation: (func(x *SignatureMetadata) *SignatureMetadata { 155 if x == nil { 156 return nil 157 } 158 tmp := (*x).DeepCopy() 159 return &tmp 160 })(o.Revocation), 161 } 162 } 163 164 type PublicKeyV2NaCl struct { 165 Base PublicKeyV2Base `codec:"base" json:"base"` 166 Parent *KID `codec:"parent,omitempty" json:"parent,omitempty"` 167 DeviceID DeviceID `codec:"deviceID" json:"deviceID"` 168 DeviceDescription string `codec:"deviceDescription" json:"deviceDescription"` 169 DeviceType DeviceTypeV2 `codec:"deviceType" json:"deviceType"` 170 } 171 172 func (o PublicKeyV2NaCl) DeepCopy() PublicKeyV2NaCl { 173 return PublicKeyV2NaCl{ 174 Base: o.Base.DeepCopy(), 175 Parent: (func(x *KID) *KID { 176 if x == nil { 177 return nil 178 } 179 tmp := (*x).DeepCopy() 180 return &tmp 181 })(o.Parent), 182 DeviceID: o.DeviceID.DeepCopy(), 183 DeviceDescription: o.DeviceDescription, 184 DeviceType: o.DeviceType.DeepCopy(), 185 } 186 } 187 188 type PGPFingerprint [20]byte 189 190 func (o PGPFingerprint) DeepCopy() PGPFingerprint { 191 var ret PGPFingerprint 192 copy(ret[:], o[:]) 193 return ret 194 } 195 196 type PublicKeyV2PGPSummary struct { 197 Base PublicKeyV2Base `codec:"base" json:"base"` 198 Fingerprint PGPFingerprint `codec:"fingerprint" json:"fingerprint"` 199 Identities []PGPIdentity `codec:"identities" json:"identities"` 200 } 201 202 func (o PublicKeyV2PGPSummary) DeepCopy() PublicKeyV2PGPSummary { 203 return PublicKeyV2PGPSummary{ 204 Base: o.Base.DeepCopy(), 205 Fingerprint: o.Fingerprint.DeepCopy(), 206 Identities: (func(x []PGPIdentity) []PGPIdentity { 207 if x == nil { 208 return nil 209 } 210 ret := make([]PGPIdentity, len(x)) 211 for i, v := range x { 212 vCopy := v.DeepCopy() 213 ret[i] = vCopy 214 } 215 return ret 216 })(o.Identities), 217 } 218 } 219 220 type PublicKeyV2 struct { 221 KeyType__ KeyType `codec:"keyType" json:"keyType"` 222 Nacl__ *PublicKeyV2NaCl `codec:"nacl,omitempty" json:"nacl,omitempty"` 223 PGP__ *PublicKeyV2PGPSummary `codec:"pgp,omitempty" json:"pgp,omitempty"` 224 } 225 226 func (o *PublicKeyV2) KeyType() (ret KeyType, err error) { 227 switch o.KeyType__ { 228 case KeyType_NACL: 229 if o.Nacl__ == nil { 230 err = errors.New("unexpected nil value for Nacl__") 231 return ret, err 232 } 233 case KeyType_PGP: 234 if o.PGP__ == nil { 235 err = errors.New("unexpected nil value for PGP__") 236 return ret, err 237 } 238 } 239 return o.KeyType__, nil 240 } 241 242 func (o PublicKeyV2) Nacl() (res PublicKeyV2NaCl) { 243 if o.KeyType__ != KeyType_NACL { 244 panic("wrong case accessed") 245 } 246 if o.Nacl__ == nil { 247 return 248 } 249 return *o.Nacl__ 250 } 251 252 func (o PublicKeyV2) Pgp() (res PublicKeyV2PGPSummary) { 253 if o.KeyType__ != KeyType_PGP { 254 panic("wrong case accessed") 255 } 256 if o.PGP__ == nil { 257 return 258 } 259 return *o.PGP__ 260 } 261 262 func NewPublicKeyV2WithNacl(v PublicKeyV2NaCl) PublicKeyV2 { 263 return PublicKeyV2{ 264 KeyType__: KeyType_NACL, 265 Nacl__: &v, 266 } 267 } 268 269 func NewPublicKeyV2WithPgp(v PublicKeyV2PGPSummary) PublicKeyV2 { 270 return PublicKeyV2{ 271 KeyType__: KeyType_PGP, 272 PGP__: &v, 273 } 274 } 275 276 func NewPublicKeyV2Default(keyType KeyType) PublicKeyV2 { 277 return PublicKeyV2{ 278 KeyType__: keyType, 279 } 280 } 281 282 func (o PublicKeyV2) DeepCopy() PublicKeyV2 { 283 return PublicKeyV2{ 284 KeyType__: o.KeyType__.DeepCopy(), 285 Nacl__: (func(x *PublicKeyV2NaCl) *PublicKeyV2NaCl { 286 if x == nil { 287 return nil 288 } 289 tmp := (*x).DeepCopy() 290 return &tmp 291 })(o.Nacl__), 292 PGP__: (func(x *PublicKeyV2PGPSummary) *PublicKeyV2PGPSummary { 293 if x == nil { 294 return nil 295 } 296 tmp := (*x).DeepCopy() 297 return &tmp 298 })(o.PGP__), 299 } 300 } 301 302 type UserPlusKeysV2 struct { 303 Uid UID `codec:"uid" json:"uid"` 304 Username string `codec:"username" json:"username"` 305 EldestSeqno Seqno `codec:"eldestSeqno" json:"eldestSeqno"` 306 Status StatusCode `codec:"status" json:"status"` 307 PerUserKeys []PerUserKey `codec:"perUserKeys" json:"perUserKeys"` 308 DeviceKeys map[KID]PublicKeyV2NaCl `codec:"deviceKeys" json:"deviceKeys"` 309 PGPKeys map[KID]PublicKeyV2PGPSummary `codec:"pgpKeys" json:"pgpKeys"` 310 StellarAccountID *string `codec:"stellarAccountID,omitempty" json:"stellarAccountID,omitempty"` 311 RemoteTracks map[UID]RemoteTrack `codec:"remoteTracks" json:"remoteTracks"` 312 Reset *ResetSummary `codec:"reset,omitempty" json:"reset,omitempty"` 313 Unstubbed bool `codec:"unstubbed" json:"unstubbed"` 314 } 315 316 func (o UserPlusKeysV2) DeepCopy() UserPlusKeysV2 { 317 return UserPlusKeysV2{ 318 Uid: o.Uid.DeepCopy(), 319 Username: o.Username, 320 EldestSeqno: o.EldestSeqno.DeepCopy(), 321 Status: o.Status.DeepCopy(), 322 PerUserKeys: (func(x []PerUserKey) []PerUserKey { 323 if x == nil { 324 return nil 325 } 326 ret := make([]PerUserKey, len(x)) 327 for i, v := range x { 328 vCopy := v.DeepCopy() 329 ret[i] = vCopy 330 } 331 return ret 332 })(o.PerUserKeys), 333 DeviceKeys: (func(x map[KID]PublicKeyV2NaCl) map[KID]PublicKeyV2NaCl { 334 if x == nil { 335 return nil 336 } 337 ret := make(map[KID]PublicKeyV2NaCl, len(x)) 338 for k, v := range x { 339 kCopy := k.DeepCopy() 340 vCopy := v.DeepCopy() 341 ret[kCopy] = vCopy 342 } 343 return ret 344 })(o.DeviceKeys), 345 PGPKeys: (func(x map[KID]PublicKeyV2PGPSummary) map[KID]PublicKeyV2PGPSummary { 346 if x == nil { 347 return nil 348 } 349 ret := make(map[KID]PublicKeyV2PGPSummary, len(x)) 350 for k, v := range x { 351 kCopy := k.DeepCopy() 352 vCopy := v.DeepCopy() 353 ret[kCopy] = vCopy 354 } 355 return ret 356 })(o.PGPKeys), 357 StellarAccountID: (func(x *string) *string { 358 if x == nil { 359 return nil 360 } 361 tmp := (*x) 362 return &tmp 363 })(o.StellarAccountID), 364 RemoteTracks: (func(x map[UID]RemoteTrack) map[UID]RemoteTrack { 365 if x == nil { 366 return nil 367 } 368 ret := make(map[UID]RemoteTrack, len(x)) 369 for k, v := range x { 370 kCopy := k.DeepCopy() 371 vCopy := v.DeepCopy() 372 ret[kCopy] = vCopy 373 } 374 return ret 375 })(o.RemoteTracks), 376 Reset: (func(x *ResetSummary) *ResetSummary { 377 if x == nil { 378 return nil 379 } 380 tmp := (*x).DeepCopy() 381 return &tmp 382 })(o.Reset), 383 Unstubbed: o.Unstubbed, 384 } 385 } 386 387 type UserPlusKeysV2AllIncarnations struct { 388 Current UserPlusKeysV2 `codec:"current" json:"current"` 389 PastIncarnations []UserPlusKeysV2 `codec:"pastIncarnations" json:"pastIncarnations"` 390 Uvv UserVersionVector `codec:"uvv" json:"uvv"` 391 SeqnoLinkIDs map[Seqno]LinkID `codec:"seqnoLinkIDs" json:"seqnoLinkIDs"` 392 MinorVersion UPK2MinorVersion `codec:"minorVersion" json:"minorVersion"` 393 Stale bool `codec:"stale" json:"stale"` 394 } 395 396 func (o UserPlusKeysV2AllIncarnations) DeepCopy() UserPlusKeysV2AllIncarnations { 397 return UserPlusKeysV2AllIncarnations{ 398 Current: o.Current.DeepCopy(), 399 PastIncarnations: (func(x []UserPlusKeysV2) []UserPlusKeysV2 { 400 if x == nil { 401 return nil 402 } 403 ret := make([]UserPlusKeysV2, len(x)) 404 for i, v := range x { 405 vCopy := v.DeepCopy() 406 ret[i] = vCopy 407 } 408 return ret 409 })(o.PastIncarnations), 410 Uvv: o.Uvv.DeepCopy(), 411 SeqnoLinkIDs: (func(x map[Seqno]LinkID) map[Seqno]LinkID { 412 if x == nil { 413 return nil 414 } 415 ret := make(map[Seqno]LinkID, len(x)) 416 for k, v := range x { 417 kCopy := k.DeepCopy() 418 vCopy := v.DeepCopy() 419 ret[kCopy] = vCopy 420 } 421 return ret 422 })(o.SeqnoLinkIDs), 423 MinorVersion: o.MinorVersion.DeepCopy(), 424 Stale: o.Stale, 425 } 426 } 427 428 type UPAKVersion int 429 430 const ( 431 UPAKVersion_V1 UPAKVersion = 1 432 UPAKVersion_V2 UPAKVersion = 2 433 ) 434 435 func (o UPAKVersion) DeepCopy() UPAKVersion { return o } 436 437 var UPAKVersionMap = map[string]UPAKVersion{ 438 "V1": 1, 439 "V2": 2, 440 } 441 442 var UPAKVersionRevMap = map[UPAKVersion]string{ 443 1: "V1", 444 2: "V2", 445 } 446 447 func (e UPAKVersion) String() string { 448 if v, ok := UPAKVersionRevMap[e]; ok { 449 return v 450 } 451 return fmt.Sprintf("%v", int(e)) 452 } 453 454 // * What we're storing for each user. At first it was UPAKs, as defined 455 // * in common.avdl. But going forward, we're going to use UserPlusKeysV2AllIncarnations. 456 type UPAKVersioned struct { 457 V__ UPAKVersion `codec:"v" json:"v"` 458 V1__ *UserPlusAllKeys `codec:"v1,omitempty" json:"v1,omitempty"` 459 V2__ *UserPlusKeysV2AllIncarnations `codec:"v2,omitempty" json:"v2,omitempty"` 460 } 461 462 func (o *UPAKVersioned) V() (ret UPAKVersion, err error) { 463 switch o.V__ { 464 case UPAKVersion_V1: 465 if o.V1__ == nil { 466 err = errors.New("unexpected nil value for V1__") 467 return ret, err 468 } 469 case UPAKVersion_V2: 470 if o.V2__ == nil { 471 err = errors.New("unexpected nil value for V2__") 472 return ret, err 473 } 474 } 475 return o.V__, nil 476 } 477 478 func (o UPAKVersioned) V1() (res UserPlusAllKeys) { 479 if o.V__ != UPAKVersion_V1 { 480 panic("wrong case accessed") 481 } 482 if o.V1__ == nil { 483 return 484 } 485 return *o.V1__ 486 } 487 488 func (o UPAKVersioned) V2() (res UserPlusKeysV2AllIncarnations) { 489 if o.V__ != UPAKVersion_V2 { 490 panic("wrong case accessed") 491 } 492 if o.V2__ == nil { 493 return 494 } 495 return *o.V2__ 496 } 497 498 func NewUPAKVersionedWithV1(v UserPlusAllKeys) UPAKVersioned { 499 return UPAKVersioned{ 500 V__: UPAKVersion_V1, 501 V1__: &v, 502 } 503 } 504 505 func NewUPAKVersionedWithV2(v UserPlusKeysV2AllIncarnations) UPAKVersioned { 506 return UPAKVersioned{ 507 V__: UPAKVersion_V2, 508 V2__: &v, 509 } 510 } 511 512 func (o UPAKVersioned) DeepCopy() UPAKVersioned { 513 return UPAKVersioned{ 514 V__: o.V__.DeepCopy(), 515 V1__: (func(x *UserPlusAllKeys) *UserPlusAllKeys { 516 if x == nil { 517 return nil 518 } 519 tmp := (*x).DeepCopy() 520 return &tmp 521 })(o.V1__), 522 V2__: (func(x *UserPlusKeysV2AllIncarnations) *UserPlusKeysV2AllIncarnations { 523 if x == nil { 524 return nil 525 } 526 tmp := (*x).DeepCopy() 527 return &tmp 528 })(o.V2__), 529 } 530 } 531 532 type UPKLiteMinorVersion int 533 534 const ( 535 UPKLiteMinorVersion_V0 UPKLiteMinorVersion = 0 536 ) 537 538 func (o UPKLiteMinorVersion) DeepCopy() UPKLiteMinorVersion { return o } 539 540 var UPKLiteMinorVersionMap = map[string]UPKLiteMinorVersion{ 541 "V0": 0, 542 } 543 544 var UPKLiteMinorVersionRevMap = map[UPKLiteMinorVersion]string{ 545 0: "V0", 546 } 547 548 func (e UPKLiteMinorVersion) String() string { 549 if v, ok := UPKLiteMinorVersionRevMap[e]; ok { 550 return v 551 } 552 return fmt.Sprintf("%v", int(e)) 553 } 554 555 type UPKLiteV1 struct { 556 Uid UID `codec:"uid" json:"uid"` 557 Username string `codec:"username" json:"username"` 558 EldestSeqno Seqno `codec:"eldestSeqno" json:"eldestSeqno"` 559 Status StatusCode `codec:"status" json:"status"` 560 DeviceKeys map[KID]PublicKeyV2NaCl `codec:"deviceKeys" json:"deviceKeys"` 561 Reset *ResetSummary `codec:"reset,omitempty" json:"reset,omitempty"` 562 } 563 564 func (o UPKLiteV1) DeepCopy() UPKLiteV1 { 565 return UPKLiteV1{ 566 Uid: o.Uid.DeepCopy(), 567 Username: o.Username, 568 EldestSeqno: o.EldestSeqno.DeepCopy(), 569 Status: o.Status.DeepCopy(), 570 DeviceKeys: (func(x map[KID]PublicKeyV2NaCl) map[KID]PublicKeyV2NaCl { 571 if x == nil { 572 return nil 573 } 574 ret := make(map[KID]PublicKeyV2NaCl, len(x)) 575 for k, v := range x { 576 kCopy := k.DeepCopy() 577 vCopy := v.DeepCopy() 578 ret[kCopy] = vCopy 579 } 580 return ret 581 })(o.DeviceKeys), 582 Reset: (func(x *ResetSummary) *ResetSummary { 583 if x == nil { 584 return nil 585 } 586 tmp := (*x).DeepCopy() 587 return &tmp 588 })(o.Reset), 589 } 590 } 591 592 type UPKLiteV1AllIncarnations struct { 593 Current UPKLiteV1 `codec:"current" json:"current"` 594 PastIncarnations []UPKLiteV1 `codec:"pastIncarnations" json:"pastIncarnations"` 595 SeqnoLinkIDs map[Seqno]LinkID `codec:"seqnoLinkIDs" json:"seqnoLinkIDs"` 596 MinorVersion UPKLiteMinorVersion `codec:"minorVersion" json:"minorVersion"` 597 } 598 599 func (o UPKLiteV1AllIncarnations) DeepCopy() UPKLiteV1AllIncarnations { 600 return UPKLiteV1AllIncarnations{ 601 Current: o.Current.DeepCopy(), 602 PastIncarnations: (func(x []UPKLiteV1) []UPKLiteV1 { 603 if x == nil { 604 return nil 605 } 606 ret := make([]UPKLiteV1, len(x)) 607 for i, v := range x { 608 vCopy := v.DeepCopy() 609 ret[i] = vCopy 610 } 611 return ret 612 })(o.PastIncarnations), 613 SeqnoLinkIDs: (func(x map[Seqno]LinkID) map[Seqno]LinkID { 614 if x == nil { 615 return nil 616 } 617 ret := make(map[Seqno]LinkID, len(x)) 618 for k, v := range x { 619 kCopy := k.DeepCopy() 620 vCopy := v.DeepCopy() 621 ret[kCopy] = vCopy 622 } 623 return ret 624 })(o.SeqnoLinkIDs), 625 MinorVersion: o.MinorVersion.DeepCopy(), 626 } 627 } 628 629 type UPKInterface interface { 630 } 631 632 func UPKProtocol(i UPKInterface) rpc.Protocol { 633 return rpc.Protocol{ 634 Name: "keybase.1.UPK", 635 Methods: map[string]rpc.ServeHandlerDescription{}, 636 } 637 } 638 639 type UPKClient struct { 640 Cli rpc.GenericClient 641 }