wip messages handling

This commit is contained in:
2025-12-23 17:05:29 +01:00
parent 1844037488
commit ced0c992e7
5 changed files with 240 additions and 26 deletions

View File

@@ -45,7 +45,7 @@ pub fn formatPubKey(crypto_pair: CryptographicSignature) -> String {
///
/// takes a serialized message and adds the signature using the private key
///
pub fn sign_message(crypto_pair: CryptographicSignature, message: Vec<u8>) -> Vec<u8> {
pub fn sign_message(crypto_pair: &CryptographicSignature, message: &Vec<u8>) -> Vec<u8> {
let length_bytes: [u8; 2] = message[5..7]
.try_into()
.expect("slice with incorrect length");
@@ -105,7 +105,7 @@ mod tests {
let crypto_pair = CryptographicSignature::new(username.clone());
let handshake = HandshakeMessage::hello(0, 12, username);
let ser = handshake.serialize();
let signed_message = sign_message(crypto_pair, ser.clone());
let signed_message = sign_message(&crypto_pair, &ser);
println!("unsigned_message: {:?}", ser);
println!("signed_message: {:?}", signed_message);
}