Damm algorithm
In 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, as a part of his PhD dissertation entitled ''Totally Antisymmetric Quasigroups.''
Strengths and weaknesses
Strengths
The 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. 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.
Prepending leading zeros does not affect the check digit.
There are totally anti-symmetric quasigroups that detect all phonetic errors associated with the English language. The table used in the illustrating example is based on an instance of such kind.
Weaknesses
For all checksum algorithms, including the Damm algorithm, prepending leading zeroes does not affect the check digit, so 1, 01, 001, etc. produce the same check digit. Consequently variable-length codes should not be verified together.Design
Its essential part is a quasigroup of order 10 with the special feature of being weakly totally anti-symmetric. Damm revealed several methods to create totally anti-symmetric quasigroups of order 10 and gave some examples in his doctoral dissertation. With this, Damm also disproved an old conjecture that totally anti-symmetric quasigroups of order 10 do not exist.A quasigroup is called totally anti-symmetric if for all, the following implications hold:
- ,
a weak totally anti-symmetric quasigroup with the property
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.
Algorithm
The 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. It is useful if each main diagonal entry is, because it simplifies the check digit calculation.Validating a number against the included check digit
- Set up an interim digit and initialize it to.
- Process the number digit by digit: Use the number's digit as column index and the interim digit as row index, take the table entry and replace the interim digit with it.
- The number is valid if and only if the resulting interim digit has the value of.
Calculating the check digit
- Set up an interim digit and initialize it to.
- Process the number digit by digit: Use the number's digit as column index and the interim digit as row index, take the table entry and replace the interim digit with it.
- The resulting interim digit gives the check digit and will be appended as trailing digit to the number.
Example
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |
| 0 | 0 | 3 | 1 | 7 | 5 | 9 | 8 | 6 | 4 | 2 |
| 1 | 7 | 0 | 9 | 2 | 1 | 5 | 4 | 8 | 6 | 3 |
| 2 | 4 | 2 | 0 | 6 | 8 | 7 | 1 | 3 | 5 | 9 |
| 3 | 1 | 7 | 5 | 0 | 9 | 8 | 3 | 4 | 2 | 6 |
| 4 | 6 | 1 | 2 | 3 | 0 | 4 | 5 | 9 | 7 | 8 |
| 5 | 3 | 6 | 7 | 4 | 2 | 0 | 9 | 5 | 8 | 1 |
| 6 | 5 | 8 | 6 | 9 | 7 | 2 | 0 | 1 | 3 | 4 |
| 7 | 8 | 9 | 4 | 5 | 3 | 6 | 2 | 0 | 1 | 7 |
| 8 | 9 | 4 | 3 | 8 | 6 | 1 | 7 | 2 | 0 | 5 |
| 9 | 2 | 5 | 8 | 1 | 4 | 3 | 6 | 7 | 9 | 0 |
Suppose we choose the number 572.