Damm algorithmIn error detection, the Damm algorithm is a check digit algorithm that detects all single-digit errors and all adjacent transposition errors. It was presented by H. Michael Damm in 2004,[1] as a part of his PhD dissertation entitled Totally Antisymmetric Quasigroups. Strengths and weaknessesStrengthsThe Damm algorithm is similar to the Verhoeff algorithm. It too will detect all occurrences of the two most frequently appearing types of transcription errors, namely altering a single digit or transposing two adjacent digits (including the transposition of the trailing check digit and the preceding digit).[1][2] The Damm algorithm has the benefit that it does not have the dedicatedly constructed permutations and its position-specific powers of the Verhoeff scheme. A table of inverses can also be dispensed with when all main diagonal entries of the operation table are zero. The Damm algorithm generates only 10 possible values, avoiding the need for a non-digit character (such as the X in the 10-digit ISBN check digit scheme). Prepending leading zeros does not affect the check digit (a weakness for variable-length codes).[1] There are totally anti-symmetric quasigroups that detect all phonetic errors associated with the English language (13 ↔ 30, 14 ↔ 40, ..., 19 ↔ 90). The table used in the illustrating example is based on an instance of such kind. WeaknessesFor all checksum algorithms, including the Damm algorithm, prepending leading zeroes does not affect the check digit,[1] so 1, 01, 001, etc. produce the same check digit. Consequently variable-length codes should not be verified together. DesignIts essential part is a quasigroup of order 10 (i.e. having a 10 × 10 Latin square as the body of its operation table) with the special feature of being weakly totally anti-symmetric.[3][4][i][ii][iii] Damm revealed several methods to create totally anti-symmetric quasigroups of order 10 and gave some examples in his doctoral dissertation.[3][i] With this, Damm also disproved an old conjecture that totally anti-symmetric quasigroups of order 10 do not exist.[5] A quasigroup (Q, ∗) is called totally anti-symmetric if for all c, x, y ∈ Q, the following implications hold:[4]
and it is called weak totally anti-symmetric if only the first implication holds. Damm proved that the existence of a totally anti-symmetric quasigroup of order n is equivalent to the existence of a weak totally anti-symmetric quasigroup of order n. For the Damm algorithm with the check equation (...((0 ∗ xm) ∗ xm−1) ∗ ...) ∗ x0 = 0, a weak totally anti-symmetric quasigroup with the property x ∗ x = 0 is needed. Such a quasigroup can be constructed from any totally anti-symmetric quasigroup by rearranging the columns in such a way that all zeros lay on the diagonal. And, on the other hand, from any weak totally anti-symmetric quasigroup a totally anti-symmetric quasigroup can be constructed by rearranging the columns in such a way that the first row is in natural order.[3] AlgorithmThe validity of a digit sequence containing a check digit is defined over a quasigroup. A quasigroup table ready for use can be taken from Damm's dissertation (pages 98, 106, 111).[3] It is useful if each main diagonal entry is 0,[1] because it simplifies the check digit calculation. Validating a number against the included check digit
Calculating the check digitPrerequisite: The main diagonal entries of the table are 0.
ExampleThe following operation table will be used.[1] It may be obtained from the totally anti-symmetric quasigroup x ∗ y in Damm's doctoral dissertation page 111[3] by rearranging the rows and changing the entries with the permutation φ = (1 2 9 5 4 8 6 7 3) and defining x ⋅ y = φ−1(φ(x) ∗ y).
Suppose we choose the number (digit sequence) 572. Calculating the check digit
The resulting interim digit is 4. This is the calculated check digit. We append it to the number and obtain 5724. Validating a number against the included check digit
The resulting interim digit is 0, hence the number is valid. Graphical illustrationThis is the above example showing the detail of the algorithm generating the check digit (dashed blue arrow) and verifying the number 572 with the check digit. References
External linksWikibooks has a book on the topic of: Algorithm Implementation/Checksums/Damm Algorithm |