Function deepkey_csr::key_registration::update_key

source ·
pub fn update_key(
    input: UpdateKeyInput,
) -> ExternResult<(ActionHash, KeyRegistration, KeyMeta)>
Expand description

Register a key update for an existing app/key pair and create associated private entries

§Example usage
let prior_key_registration = ActionHash::try_from("uhCkkzhwfnkYh7CWji2KpS2wO6YaKOKPQ4-kr4XGRBRRx9hitvOw9").unwrap();

// Assuming the default change rules are still in place
let revocation_authorization = vec![
    (
        0, // The index of the FDA authority
        sign_raw( // Sign prior registration using FDA
            agent_info()?.agent_initial_pubkey,
            prior_key_registration.clone().into_inner()
        )?
    ),
];

let key_revocation = KeyRevocation {
    prior_key_registration,
    revocation_authorization,
};

// Generates a new key in Lair
let new_key = AgentPubKey::from_raw_32( create_x25519_keypair()?.as_ref().to_vec() );
// Sign this cell's agent with using the new key
let new_key_signing_of_author = sign_raw(
    new_key.clone(),
    agent_info()?.agent_initial_pubkey.into_inner()
)?;

let key_generation = KeyGeneration {
    new_key,
    new_key_signing_of_author,
};

// Here is an example of submitting the derivation details; however, in this case it should
// be set to `None` because we did not derive this key.
let derivation_details = Some(DerivationDetailsInput {
    app_index: 1,
    key_index: 1, // Next key index
    derivation_seed: vec![],
    derivation_bytes: vec![],
});

let result = deepkey_csr::key_registration::update_key(UpdateKeyInput {
    key_revocation,
    key_generation,
    derivation_details,
});