style: cargo fmt for v1.7.99-alpha release gate
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
144c4a2872
commit
83bb589ea6
@@ -28,9 +28,7 @@ pub fn ed25519_pubkey_from_did_key(did: &str) -> Result<VerifyingKey> {
|
||||
if decoded.len() != 34 || decoded[0..2] != ED25519_MULTICODEC {
|
||||
return Err(anyhow!("not an Ed25519 did:key (bad multicodec prefix)"));
|
||||
}
|
||||
let arr: [u8; 32] = decoded[2..]
|
||||
.try_into()
|
||||
.expect("length checked above");
|
||||
let arr: [u8; 32] = decoded[2..].try_into().expect("length checked above");
|
||||
VerifyingKey::from_bytes(&arr).context("invalid Ed25519 public key in did:key")
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,13 @@ pub fn verify_detached(doc: &Value) -> Result<SignatureStatus> {
|
||||
let signed_by = obj
|
||||
.get(SIGNED_BY_FIELD)
|
||||
.and_then(Value::as_str)
|
||||
.ok_or_else(|| anyhow!("signed document has `{}` but no `{}`", SIGNATURE_FIELD, SIGNED_BY_FIELD))?;
|
||||
.ok_or_else(|| {
|
||||
anyhow!(
|
||||
"signed document has `{}` but no `{}`",
|
||||
SIGNATURE_FIELD,
|
||||
SIGNED_BY_FIELD
|
||||
)
|
||||
})?;
|
||||
|
||||
let signer = did::ed25519_pubkey_from_did_key(signed_by)
|
||||
.with_context(|| format!("invalid `{}` did:key", SIGNED_BY_FIELD))?;
|
||||
@@ -174,7 +180,10 @@ mod tests {
|
||||
#[test]
|
||||
fn tampered_payload_is_rejected() {
|
||||
let mut signed = sign_into(&test_key(), json!({"schema": 1, "n": 42}));
|
||||
signed.as_object_mut().unwrap().insert("n".into(), json!(43));
|
||||
signed
|
||||
.as_object_mut()
|
||||
.unwrap()
|
||||
.insert("n".into(), json!(43));
|
||||
assert!(verify_detached(&signed).is_err());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user