From 23a06a3faba02f1639c097dc39b1d018d9201228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Blankfors?= Date: Tue, 16 Apr 2024 09:18:27 +0200 Subject: [PATCH] feat: extend margin --- libsigner/src/messages.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libsigner/src/messages.rs b/libsigner/src/messages.rs index 7042213fb..388207a77 100644 --- a/libsigner/src/messages.rs +++ b/libsigner/src/messages.rs @@ -402,10 +402,10 @@ impl StacksMessageCodec for SignerMessage { } } SignerMessageTypePrefix::EncryptedSignerState => { - // Typically the size of the signer state is much smaller, but in the fully degenerate case the size of dkg shares is - // (2800 + 2800) * 32 (threshold * shares * 32). - // The signer state holds some additional information, so we're adding a factor 4 to have some margin - let max_encrypted_state_size = (2800 + 2800) * 32 * 4; + // Typically the size of the signer state is much smaller, but in the fully degenerate case the size of the persisted state is + // 2800 * 32 * 4 + C for some small constant C. + // To have some margin, we're expanding the left term with an additional factor 4 + let max_encrypted_state_size = 2800 * 32 * 4 * 4; let mut bound_reader = BoundReader::from_reader(fd, max_encrypted_state_size); let encrypted_state = read_next::<_, _>(&mut bound_reader)?; SignerMessage::EncryptedSignerState(encrypted_state)