~yujiri/libsufec

a533899727e0c631fd2a1f0969120635042459ad — Evin Yulo 1 year, 11 months ago 9104cfc
protocol update: addresses are preceded by 1 byte length, not 4 bytes
2 files changed, 4 insertions(+), 4 deletions(-)

M src/crypto.rs
M src/message.rs
M src/crypto.rs => src/crypto.rs +1 -1
@@ 15,7 15,7 @@ pub fn encrypt_message(
	let ciphertext = seal_precomputed(&message.to_bytes(), &nonce, &shared_key);
	let addr_bytes = account.addr.to_bytes();
	let concat = [
		(addr_bytes.len() as u32).to_be_bytes().as_ref(),
		[addr_bytes.len() as u8].as_slice(),
		&addr_bytes,
		eph_pub.0.as_ref(),
		&nonce.0,

M src/message.rs => src/message.rs +3 -3
@@ 42,7 42,7 @@ impl Message {
		let mut result = vec![self.other_recipients.len() as u8];
		for addr in &self.other_recipients {
			let addr_bytes = addr.to_bytes();
			result.extend((addr_bytes.len() as u32).to_be_bytes());
			result.push(addr_bytes.len() as u8);
			result.extend(addr_bytes);
		}
		result.extend(self.timestamp.to_be_bytes());


@@ 59,8 59,8 @@ impl Message {
		bytes = &bytes[1..];
		let mut other_recipients = Vec::new();
		for _ in 0..num_other_recipients {
			let len = u32::from_be_bytes(bytes.get(..4)?.try_into().unwrap()) as usize;
			bytes = &bytes[4..];
			let len = bytes[0] as usize;
			bytes = &bytes[1..];
			let addr = SufecAddr::from_bytes(&bytes[..len])?;
			bytes = &bytes[len..];
			other_recipients.push(addr);