Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions pkgs/id/src/hosted_binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3011,6 +3011,36 @@ mod tests {
.unwrap();
}

#[test]
fn key_signature_verifies_for_a_rebound_binding() {
let mut service = service();
let binding = bind(&mut service, SUB, 21);
let new_key = root_key(22);
let (challenge_id, proof) = signed_challenge(&mut service, SUB, &new_key);
let (request, _) = service
.request_delayed_rebind(SUB, &challenge_id, &proof)
.unwrap();
let counter = countersign(
&binding.binding_id,
&binding.iroh_id,
&new_key,
REBIND_VIA_DELAYED,
);
service.set_now_override(Some(T0 + REBIND_WAITING_PERIOD_SECS));
let (updated, _) = service
.effect_due_rebind(&request.rebind_id, &counter)
.unwrap();
// The transcript still names the ceremony key, now superseded
// into history: the signature verifies, linked to the current
// key by the attested history and the rebind records.
assert_eq!(updated.challenge_transcript.iroh_id, binding.iroh_id);
assert!(HostedBindingService::verify_key_signature(&updated));
// A transcript naming a key outside the chain still fails.
let mut foreign = updated.clone();
foreign.challenge_transcript.iroh_id = hex_encode(&root_key(77).verifying_key().to_bytes());
assert!(!HostedBindingService::verify_key_signature(&foreign));
}

#[test]
fn delayed_rebind_effect_refuses_a_target_bound_elsewhere_without_mutation() {
let mut service = service();
Expand Down
Loading