From 1a036a0b5fd4860491ee134f27ea35e34379c4bc Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 3 May 2024 22:41:38 -0400 Subject: [PATCH] keyfork-shard: clean up documentation for encrypted shard padding --- crates/keyfork-shard/src/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/keyfork-shard/src/lib.rs b/crates/keyfork-shard/src/lib.rs index f2f9388..d05fa3d 100644 --- a/crates/keyfork-shard/src/lib.rs +++ b/crates/keyfork-shard/src/lib.rs @@ -25,9 +25,11 @@ use sha2::Sha256; use sharks::{Share, Sharks}; use x25519_dalek::{EphemeralSecret, PublicKey}; -// 32-byte share, 1-byte index, 1-byte threshold, 1-byte version == 36 bytes -// Encrypted, is 52 bytes -const PLAINTEXT_LENGTH: u8 = 36; +const PLAINTEXT_LENGTH: u8 = 32 // shard + + 1 // index + + 1 // threshold + + 1 // version + + 1; // length; const ENCRYPTED_LENGTH: u8 = PLAINTEXT_LENGTH + 16; #[cfg(feature = "openpgp")] @@ -271,7 +273,7 @@ pub trait Format { payload.insert(1, threshold); assert!( payload.len() < PLAINTEXT_LENGTH as usize, - "invalid share length (too long, max {PLAINTEXT_LENGTH} bytes)" + "invalid share length (too long, must be less than {PLAINTEXT_LENGTH} bytes)" ); // convert plaintext to static-size payload