 # Identity and Access Management

## The Luhn PUID Check Digit Method

The last of the ten digits of the PUID is a check digit that can be used to detect when digits of the PUID (including the check digit) have been typed or transcribed incorrectly.

## Computing the Check Digit

The check digit is computed according to a slight modification of the Luhn method, described in ANSI/ISO/IEC 7812-1:1993.

The computational method incorporates the sum of the products of each digit with its position number. When the check digit is not part of the computation -- the case when it's first computed -- position numbers start at two at the rightmost digit and increase by one going to the left. When a product has two digits -- e.g., 6 X 2 = 12 -- each digit of the product is added to the sum separately.

Consider the calculation of a check digit for 12312345. Here are the digit products, starting at the rightmost digit ('5'), and the accumulating sum.

5: X 2 = 10, sum + 0 = 0, sum + 1 = 1
4: X 3 = 12, sum + 2 = 3, sum + 1 = 4
3: X 4 = 12, sum + 2 = 6, sum + 1 = 7
2: X 5 = 10, sum + 0 = 7, sum + 1 = 8
1: X 6 = 6, sum + 6 = 14
3: X 7 = 21, sum + 1 = 15, sum + 2 = 17
2: X 8 = 16, sum + 6 = 23, sum + 1 = 24
1: X 9 = 9, sum + 9 = 33

The final sum, 33, is reduced to a single digit by applying a modulus of ten to it and subtracting that modulus, 3, from 10. That produces a check digit of 7, making the complete number, including its check digit, 123123457, or 01231-23457 in formal PUID display format.

## Checking the Check Digit

When the goal is to verify the validity of the PUID, the check digit is included in the computation and its position is one. If modulus ten of the resulting sum is zero, then the verification was successful; if it's any other digit, the verification failed.

Here's an example of a successful verification of 01231-23457

7: X 1 = 7, sum + 7 = 7
5: X 2 = 10, sum + 0 = 7, sum + 1 = 8
4: X 3 = 12, sum + 2 = 10, sum + 1 = 11
3: X 4 = 12, sum + 2 = 13, sum + 1 = 14
2: X 5 = 10, sum + 0 = 14, sum + 1 = 15
1: X 6 = 6, sum + 6 = 21
3: X 7 = 21, sum + 1 = 22, sum + 2 = 24
2: X 8 = 16, sum + 6 = 30, sum + 1 = 31
1: X 9 = 9, sum + 9 = 40
123123457: sum 40 is OK.

Since the last digit of the sum (and its modulus of ten) is zero, the verification was successful.

Exchanging digits eight and nine (counting right to left, starting at one) of the above PUID (without changing the check digit), making it 02131-23457, produces this result:

7: X 1 = 7, sum + 7 = 7
5: X 2 = 10, sum + 0 = 7, sum + 1 = 8
4: X 3 = 12, sum + 2 = 10, sum + 1 = 11
3: X 4 = 12, sum + 2 = 13, sum + 1 = 14
2: X 5 = 10, sum + 0 = 14, sum + 1 = 15
1: X 6 = 6, sum + 6 = 21
3: X 7 = 21, sum + 1 = 22, sum + 2 = 24
1: X 8 = 8, sum + 8 = 32
2: X 9 = 18, sum + 8 = 40, sum + 1 = 41

Since the last digit of the sum (and its modulus of ten) is not zero, the verification failed.

## Luhn Check Digit Failures

The Luhn method detects errors about 90% of the time. One classic failure is when two adjacent digits with the same products are exchanged and the products remain the same. For example, exchanging digits three and four, "34" in the previous example, leaves the products unchanged because digit three with a product of 4 X 3, becomes digit four with an equal product of 3 X 4, and the same happens to digit four. Here's the analysis of the failure:

7: X 1 = 7, sum + 7 = 7
5: X 2 = 10, sum + 0 = 7, sum + 1 = 8
3: X 3 = 9, sum + 9 = 17
4: X 4 = 16, sum + 6 = 23, sum + 1 = 24
2: X 5 = 10, sum + 0 = 24, sum + 1 = 25
1: X 6 = 6, sum + 6 = 31
3: X 7 = 21, sum + 1 = 32, sum + 2 = 34
2: X 8 = 16, sum + 6 = 40, sum + 1 = 41
1: X 9 = 9, sum + 9 = 50

The last digit of the sum is zero (and its modulus of ten zero), so the verification apparently succeeded, even though there was a transposition of digits three and four.

Feedback | Contact Purdue
Maintained by: IAMO Team

Purdue University, West Lafayette, IN 47907, (765) 494-4600
© 2010 - 2013 Purdue University | An equal access/equal opportunity university | Copyright Complaints