keychain_did Class

namespace keychainclass keychain_did

Overview

The keychain_did class represents a DID for a specific keychain (encryption or signature). Each keychain has its own DID that identifies the sequence of public keys used over the device’s lifetime for a particular cryptographic operation type.

Class Hierarchy

namespace keychain {
    class keychain_did : public did {
        // DID for a specific keychain (encryption or signature)
    };
}

Constructor

keychain_did();
keychain_did(const std::string& did_string);
keychain_did(keychain_type type, const std::string& identifier);
keychain_did(const keychain_did& other);

Properties

Keychain Type

keychain_type get_keychain_type() const;
bool is_encryption_keychain() const;
bool is_signature_keychain() const;

Identifies whether this DID represents an encryption or signature keychain.

DID Components

std::string get_keychain_identifier() const;
std::string to_string() const override;

Returns the keychain-specific identifier and full DID string representation.

Methods

Validation

bool is_valid() const override;
bool matches_keychain(const keychain& kc) const;

Validates the keychain DID format and checks if it matches a given keychain.

Comparison

bool operator==(const keychain_did& other) const;
bool operator!=(const keychain_did& other) const;

Static Methods

static keychain_did from_keychain(const keychain& kc);
static bool is_keychain_did_string(const std::string& did_string);

Factory method to create a keychain DID from a keychain object and validation helper.

Example Usage

#include <keychain/keychain.hpp>

// Create encryption keychain DID
keychain::keychain_did encr_did(keychain::keychain_type::encryption, "abc123...");

// Parse from string
keychain::keychain_did parsed_did("did:kc:encr:abc123...");

// Check type
if (parsed_did.is_encryption_keychain()) {
    std::cout << "This is an encryption keychain DID" << std::endl;
}

// Create from existing keychain
keychain::keychain my_keychain;
auto keychain_did = keychain::keychain_did::from_keychain(my_keychain);

See Also