//! Calls related to agent keys.
//!
//! An agent can update their key. This is helpful in cases where a the private key of their key pair
//! has been leaked or becomes unusable in some other way. The agent key can be updated, which
//! invalidates the current key and generates a new key. Both the invalidated key and the new key
//! belong to the same agent. A sequence of keys belonging to the same agent form a key lineage.

// Tests are located under conductor::conductor::tests::agent_lineage and core::ribosome::host_fn::get_agent_key_lineage::test.

use crate::prelude::*;

/// Queries a complete lineage of agent keys.
///
/// Returns a list of agent keys that are of the same lineage as the provided key, sorted in ascending
/// order by timestamp. A key lineage includes all keys of an agent that have been generated by creating
/// and updating the key.
pub fn get_agent_key_lineage(agent_key: AgentPubKey) -> ExternResult<Vec<AgentPubKey>> {
    HDK.with(|h| h.borrow().get_agent_key_lineage(agent_key))
}
