func decodeCaveat(key *KeyPair, caveat []byte) (*ThirdPartyCaveatInfo, error) {
	if len(caveat) == 0 {
		return nil, errgo.New("empty third party caveat")
	}
	switch caveat[0] {
	case byte(Version2):
		return decodeCaveatV2V3(Version2, key, caveat)
	case byte(Version3):
		if len(caveat) < version3CaveatMinLen {
			// If it has the version 3 caveat tag and it's too short, it's
			// almost certainly an id, not an encrypted payload.
			return nil, errgo.Newf("caveat id payload not provided for caveat id %q", caveat)
		}
		return decodeCaveatV2V3(Version3, key, caveat)
	case 'e':
		// 'e' will be the first byte if the caveatid is a base64 encoded JSON object.
		return decodeCaveatV1(key, caveat)
	default:
		return nil, errgo.Newf("caveat has unsupported version %d", caveat[0])
	}
}
// decodeCaveat attempts to decode caveat by decrypting the encrypted part
// using key.
decodeCaveat attempts to decode caveat by decrypting the encrypted part
using key.
// decodeCaveat attempts to decode caveat by decrypting the encrypted part // using key .
func decodeCaveat(key *KeyPair, caveat []byte) (*ThirdPartyCaveatInfo, error) {
	if len(caveat) == 0 {
		return nil, errgo.New("empty third party caveat")
	}
	switch caveat[0] {
	case byte(Version2):
		return decodeCaveatV2V3(Version2, key, caveat)
	case byte(Version3):
		if len(caveat) < version3CaveatMinLen {
			return nil, errgo.Newf("caveat id payload not provided for caveat id %q", caveat)
		}
		return decodeCaveatV2V3(Version3, key, caveat)
	case 'e':
		return decodeCaveatV1(key, caveat)
	default:
		return nil, errgo.Newf("caveat has unsupported version %d", caveat[0])
	}
}
func decodeCaveat ( key * KeyPair , caveat [ ] byte ) ( * ThirdPartyCaveatInfo , error ) { if len ( caveat ) == 0 { return nil , errgo . New ( " " ) } switch caveat [ 0 ] { case byte ( Version2 ) : return decodeCaveatV2V3 ( Version2 , key , caveat ) case byte ( Version3 ) : if len ( caveat ) < version3CaveatMinLen { return nil , errgo . Newf ( " " , caveat ) } return decodeCaveatV2V3 ( Version3 , key , caveat ) case 'e' : return decodeCaveatV1 ( key , caveat ) default : return nil , errgo . Newf ( " " , caveat [ 0 ] ) } }
decodeCaveat attempts to decode caveat by decrypting the encrypted part
using key.
decodeCaveat attempts to decode caveat by decrypting the encrypted part using key .
// If it has the version 3 caveat tag and it's too short, it's // almost certainly an id, not an encrypted payload. // 'e' will be the first byte if the caveatid is a base64 encoded JSON object.