Download presentation
Presentation is loading. Please wait.
Published byอุกฤษฏ์ บราวน์ Modified over 5 years ago
1
Modulo Arithmetic & Text Coding ECE6612 - Slides-03a John Copeland
Georgia Tech
2
= 1001110000101111 Cryptographic Operations make use of :
XOR (faster than add - no “carry” operations) and (A + B) + B = A if A + B = C then A = B + C Modulo (%) 2n arithmetic: % 216 = Still to handle 256-bit numbers on a 32-bit Computer requires representing the number as an array: N = N[0] + N[1]*232 + N[2]*264 + … + N[7]*2224 2
3
To multiple two 256-bit numbers modulo(2256),
X = M * N % where int64 N[8], M[8], X[8] N = N[0] + N[1]*232 + N[2]*264 + … + N[7]*2224 M = M[0] + M[1]*232 + M[2]*264 + … + M[7]*2224 X = N[0]*M[0] + (N[0]*M[1] + N[1]*M[0])* … X[n] = ∑(i=0 to n) ∑(j=0 to [n-j]) N[i]*M[j] as array Carries must then be processed: X[i] = X[i] + (X[i-1] >> 32) ; X[i-1] &= 0xffffffff Note that half the terms are not needed: those with i+j >7 because of the modulo(2256) 3
4
Compute the following: (A * B * C) % 10 A = 15897229742
Answer: A * B * C % 10 = ( A %10 ) * ( B %10 ) * ( C %10 ) = (2 * 8 * 3) %10 = ( 48 ) %10 = 8 The modulo operation can be done on any intermediate values that exceed the modulus, for addition or multiplication. 4
5
Note that 9, 99, 999, 999…999 - all modulo 9 = 0, therefore:
Just for fun, ,without using a calculator, or pen and paper, compute the following: (A * B * C) % 9 A = B = C = Answer: Note that 9, 99, 999, 999…999 - all modulo 9 = 0, therefore: 1, 10, 100, …000 - all modulo 9 = 1 (each is 1 + integer * 9) A %9 = % add up the digits = 11%9 = 1+1 = 2 etc. So, (A * B * C) % 9 = (2 * 7 * 3) %9 = 14 %9 * 3 = 15 %9 = 6 Also (A + B + C) %9 = ( ) %9 = 3 The “method of nines” can check addition and multiplication. 5
6
If X %m = x then X = integerX * m + x (0<= x <m)
The modulo operation can be done on any intermediate values that exceed the modulus, for addition or multiplication. Why does this work? If X %m = x then X = integerX * m + x (0<= x <m) (X + Y) %m = {(integerX + integerY) *m + (x + y)} %m (X + Y) %m = (x + y) %m (X * Y) %m = {(integerX * integerY) *m2 )} %m + + {(integerX *y *m)} %m + {(integerY *x *m)} %m + (x * y) %m (X * Y) %m = (x * y) %m 6
7
End-Line(s) UTF-8 Since 2007 Teletype, MSDOS, Internet: LF and CR
Teletype, MSDOS, Internet: LF and CR UNIX: LF (^J, 0x0A) Mac OS Before OS X CR (^M ,0x0D) After OSX Either CR or LF HTML ...<br> or <p>...</p> UTF-8 Since 2007 To type control characters. hold down Control Key and type the letter in 3rd column. ( LF is typed as Control+J written as ^J ) 7
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.