Function deepkey_csr::key_registration::create_key
source · pub fn create_key(
input: CreateKeyInput,
) -> ExternResult<(ActionHash, KeyRegistration, KeyMeta)>Expand description
Register a new app/key pair and create associated private entries
§Example usage
// 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,
};
// Mock app info
let app_binding = AppBindingInput {
app_name: "Example App".to_string(),
installed_app_id: "example-app".to_string(),
dna_hashes: vec![
DnaHash::try_from("uhC0khcxkMswniVr_dwGJAo2spTGC-hafG0lCEvzS_PJughwa4_6d").unwrap(),
],
metadata: Default::default(),
};
// 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, // 0 is already used by the deepkey app
key_index: 0,
derivation_seed: vec![],
derivation_bytes: vec![],
});
let result = deepkey_csr::key_registration::create_key(CreateKeyInput {
key_generation,
app_binding,
derivation_details,
create_only: false,
});