hot fixes to utc-6
This commit is contained in:
@@ -181,6 +181,42 @@ pub fn did_document_from_pubkey_hex(pubkey_hex: &str) -> Result<serde_json::Valu
|
||||
}))
|
||||
}
|
||||
|
||||
/// Generate a DID Document that includes both the Ed25519 key and a Nostr secp256k1 key.
|
||||
/// The Nostr key is added as an additional verification method, formally pairing
|
||||
/// the two identities so a user can use either protocol.
|
||||
pub fn did_document_with_nostr(
|
||||
pubkey_hex: &str,
|
||||
nostr_pubkey_hex: &str,
|
||||
) -> Result<serde_json::Value> {
|
||||
let mut doc = did_document_from_pubkey_hex(pubkey_hex)?;
|
||||
let did = did_key_from_pubkey_hex(pubkey_hex)?;
|
||||
let nostr_key_id = format!("{}#key-nostr-1", did);
|
||||
|
||||
// Add EcdsaSecp256k1VerificationKey2019 context
|
||||
if let Some(contexts) = doc["@context"].as_array_mut() {
|
||||
contexts.push(serde_json::json!(
|
||||
"https://w3id.org/security/suites/secp256k1-2019/v1"
|
||||
));
|
||||
}
|
||||
|
||||
// Add Nostr secp256k1 key to verificationMethod array
|
||||
if let Some(vms) = doc["verificationMethod"].as_array_mut() {
|
||||
vms.push(serde_json::json!({
|
||||
"id": nostr_key_id,
|
||||
"type": "EcdsaSecp256k1VerificationKey2019",
|
||||
"controller": did,
|
||||
"publicKeyHex": nostr_pubkey_hex
|
||||
}));
|
||||
}
|
||||
|
||||
// Add to authentication (Nostr key can also authenticate)
|
||||
if let Some(auth) = doc["authentication"].as_array_mut() {
|
||||
auth.push(serde_json::json!(nostr_key_id));
|
||||
}
|
||||
|
||||
Ok(doc)
|
||||
}
|
||||
|
||||
/// Extract the raw 32-byte Ed25519 public key from a did:key string.
|
||||
pub fn pubkey_bytes_from_did_key(did: &str) -> Result<[u8; 32]> {
|
||||
let multibase_str = did
|
||||
|
||||
Reference in New Issue
Block a user