Skip to content

Commit b57f504

Browse files
committed
Merge branch 'mathias-CRP-2060-check-receiver-set-in-oldest-public-key' into 'master'
fix(crypto): CRP-2060: Only check transcripts where current node is a receiver in oldest_public_key In the `retain_active_transcripts` interface of the IDKG protocol we get the `minimum_registry_version` referred by the input transcripts. If a node was recently added to the subnet, it may be that it will not have an iDKG dealing encryption public key in the registry at the version referred to by the oldest transcript (or indeed for any input transcript). To avoid erroneously returning an error when trying to fetch a non-existing key from the registry, filter out active transcripts where the local node is not a recipient. See merge request dfinity-lab/public/ic!12518
2 parents 71e657a + c42226f commit b57f504

File tree

5 files changed

+512
-120
lines changed

5 files changed

+512
-120
lines changed

rs/crypto/src/sign/canister_threshold_sig/idkg/retain_active_keys.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ pub fn retain_keys_for_transcripts<C: CspIDkgProtocol>(
2121
if active_transcripts.is_empty() {
2222
return Ok(());
2323
}
24-
let oldest_public_key = oldest_public_key(csp_client, node_id, registry, active_transcripts)
25-
.expect("at least one public key since there is at least one transcript")?;
24+
let oldest_public_key: MEGaPublicKey =
25+
match oldest_public_key(csp_client, node_id, registry, active_transcripts) {
26+
None => return Ok(()),
27+
Some(oldest_public_key) => oldest_public_key?,
28+
};
2629

2730
let internal_transcripts: Result<BTreeSet<_>, _> = active_transcripts
2831
.iter()
@@ -43,7 +46,7 @@ fn oldest_public_key<C: CspIDkgProtocol>(
4346
registry: &dyn RegistryClient,
4447
transcripts: &HashSet<IDkgTranscript>,
4548
) -> Option<Result<MEGaPublicKey, IDkgRetainKeysError>> {
46-
minimum_registry_version(transcripts).map(|version| {
49+
minimum_registry_version_for_node(transcripts, *node_id).map(|version| {
4750
match get_mega_pubkey(node_id, registry, version) {
4851
Ok(oldest_public_key) => {
4952
csp_client
@@ -69,9 +72,12 @@ fn oldest_public_key<C: CspIDkgProtocol>(
6972
})
7073
}
7174

72-
fn minimum_registry_version(transcripts: &HashSet<IDkgTranscript>) -> Option<RegistryVersion> {
75+
fn minimum_registry_version_for_node(
76+
transcripts: &HashSet<IDkgTranscript>,
77+
node_id: NodeId,
78+
) -> Option<RegistryVersion> {
7379
transcripts
7480
.iter()
75-
.map(|transcript| transcript.registry_version)
81+
.filter_map(|t| t.has_receiver(node_id).then_some(t.registry_version))
7682
.min()
7783
}

0 commit comments

Comments
 (0)