Enum class KeychainType

Package: keychain.constants

Description

Keychain type (encrypt or sign).

This enum specifies the type of cryptographic operations a keychain is designed for. Keychains can be specialized for either encryption operations or signing operations, each with different cryptographic requirements and use cases.

Since: v2.0

Enum Class Summary

Enum Constant Value Description

ENCRYPT

0

Encryption public keys

SIGN

1

Signing public keys

Enum Class Detail

ENCRYPT

Value: 0

Encryption public keys. This keychain type is used for public-key encryption operations, allowing others to encrypt data that only the private key holder can decrypt.

SIGN

Value: 1

Signing public keys. This keychain type is used for digital signature operations, allowing the private key holder to create verifiable signatures that others can validate using the public key.

Usage Example

from keychain.constants import KeychainType

# Create different keychain types
encryption_keychain = KeychainType.ENCRYPT
signing_keychain = KeychainType.SIGN

print(f"Encryption keychain type: {encryption_keychain}")  # Outputs: 0
print(f"Signing keychain type: {signing_keychain}")       # Outputs: 1

# Determine keychain purpose
def get_keychain_purpose(keychain_type):
    if keychain_type == KeychainType.ENCRYPT:
        return "Used for encrypting and decrypting data"
    elif keychain_type == KeychainType.SIGN:
        return "Used for creating and verifying digital signatures"
    else:
        return "Unknown keychain type"

purpose = get_keychain_purpose(encryption_keychain)
print(purpose)  # Outputs: "Used for encrypting and decrypting data"