Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace Luhn checksum with DammSum #4639

Merged
merged 5 commits into from
Sep 12, 2022

Conversation

AaronFeickert
Copy link
Collaborator

@AaronFeickert AaronFeickert commented Sep 8, 2022

Description

This replaces the generalized Luhn checksum algorithm for emoji ID encoding with DammSum, and refactors EmojiId to be cleaner and easier to understand.

Fixes issue 4638.

Motivation and Context

Emoji IDs are encoded with a checksum that is intended to detect simple errors; these include single character substitutions and single transpositions of adjacent characters. The generalized Luhn checksum algorithm cannot detect all transpositions, though it has the benefit of being a single character.

While checksums of longer length and greater complexity can provide more comprehensive error detection, this comes at the cost of a longer overall emoji ID encoding and (often) additional structures like lookup tables.

DammSum is a simple single-character checksum algorithm based on the Damm algorithm that provably detects the two desired error types in their entirety. It requires no lookup tables and uses only a small number of bitwise operations.

Other options based on Reed-Solomon or CRC designs may be considered as well as alternatives.

How Has This Been Tested?

Existing tests should pass. New randomized tests are added that comprehensively check failure modes and error detection.

@AaronFeickert AaronFeickert changed the title Replace Luhn checksum with DammSum fix: replace Luhn checksum with DammSum Sep 8, 2022
@jorgeantonio21
Copy link
Contributor

Great ! LGTM

sdbondi
sdbondi previously approved these changes Sep 9, 2022
Copy link
Member

@sdbondi sdbondi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, agree with the changes to EmojiId

@stringhandler stringhandler merged commit c01471a into tari-project:development Sep 12, 2022
@AaronFeickert AaronFeickert deleted the checksum branch September 12, 2022 14:08
sdbondi added a commit to sdbondi/tari that referenced this pull request Sep 16, 2022
* development: (72 commits)
  fix: reinsert transactions from failed block (tari-project#4675)
  fix: stray clippy error (tari-project#4685)
  fix(wallet): mark mined_height as null when pending outputs are cancelled (tari-project#4686)
  chore: updated dependancies (tari-project#4684)
  fix(p2p): remove DETACH flag usage (tari-project#4682)
  fix(comms): simplify and remove possibility of deadlock from pipelines and substream close (tari-project#4676)
  feat(ci): add default CI and FFI testing with custom dispatch (tari-project#4672)
  chore: remove broken test (tari-project#4678)
  fix: fix potential race condition between add_block and sync (tari-project#4677)
  fix deadlock (tari-project#4674)
  fix: add burn funds command to console wallet (see issue tari-project#4547) (tari-project#4655)
  v0.38.3
  fix: fee estimate (tari-project#4656)
  fix(comms/messaging): fix possible deadlock in outbound pipeline (tari-project#4657)
  fix: replace Luhn checksum with DammSum (tari-project#4639)
  fix(core/sync): handle deadline timeouts by changing peer (tari-project#4649)
  fix(ci): libtor build on Ubuntu (tari-project#4644)
  chore: fix log (tari-project#4634)
  v0.38.2
  fix(comms/rpc): detect early close in all cases (tari-project#4647)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emoji ID checksum is somewhat weak
4 participants