github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/libkb/kid.go (about) 1 // Copyright 2015 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 package libkb 5 6 import ( 7 "github.com/keybase/client/go/kbcrypto" 8 keybase1 "github.com/keybase/client/go/protocol/keybase1" 9 jsonw "github.com/keybase/go-jsonw" 10 ) 11 12 func GetKID(w *jsonw.Wrapper) (kid keybase1.KID, err error) { 13 var s string 14 s, err = w.GetString() 15 if err != nil { 16 return 17 } 18 kid = keybase1.KIDFromString(s) 19 return 20 } 21 22 func KIDIsDeviceVerify(kid keybase1.KID) bool { 23 return kbcrypto.AlgoType(kid.GetKeyType()) == kbcrypto.KIDNaclEddsa 24 } 25 26 func KIDIsDeviceEncrypt(kid keybase1.KID) bool { 27 return kbcrypto.AlgoType(kid.GetKeyType()) == kbcrypto.KIDNaclDH 28 } 29 30 func KIDIsPGP(kid keybase1.KID) bool { 31 return !KIDIsDeviceEncrypt(kid) && !KIDIsDeviceVerify(kid) 32 }