1// Copyright 2015 Keybase, Inc. All rights reserved. Use of 2// this source code is governed by the included BSD license. 3 4package libkb 5 6import ( 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 12func 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 22func KIDIsDeviceVerify(kid keybase1.KID) bool { 23 return kbcrypto.AlgoType(kid.GetKeyType()) == kbcrypto.KIDNaclEddsa 24} 25 26func KIDIsDeviceEncrypt(kid keybase1.KID) bool { 27 return kbcrypto.AlgoType(kid.GetKeyType()) == kbcrypto.KIDNaclDH 28} 29 30func KIDIsPGP(kid keybase1.KID) bool { 31 return !KIDIsDeviceEncrypt(kid) && !KIDIsDeviceVerify(kid) 32} 33