Skip to content

Commit

Permalink
chore(transfer): make discord_name decryption backward compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi authored and joshuef committed Jun 4, 2024
1 parent 07e1538 commit de54d86
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sn_transfers/src/cashnotes/spend_reason.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,14 @@ impl DiscordName {
let nonce = DerivationIndex(nonce_bytes.to_owned());

let mut checksum = [0; CHECK_SUM_SIZE];
checksum.copy_from_slice(&bytes[CONTENT_SIZE..LIMIT_SIZE]);
if checksum != CHECK_SUM {
return Err(TransferError::InvalidDecryptionKey);
if bytes.len() < LIMIT_SIZE {
// Backward compatible, which will allow invalid key generate a random hash result
checksum = CHECK_SUM;
} else {
checksum.copy_from_slice(&bytes[CONTENT_SIZE..LIMIT_SIZE]);
if checksum != CHECK_SUM {
return Err(TransferError::InvalidDecryptionKey);
}
}

Ok(Self {
Expand Down

0 comments on commit de54d86

Please sign in to comment.