COMMAND-LINE MODULAR ARITHMETIC PROGRAMS ---------------------------------------- 1. bd_ModExp.exe computes the modular exponentiation a^e mod m 2. bd_ModInv.exe computes the modular inversion a^{-1} mod m 3. bd_ModMult.exe computes the modular multiplication a*b mod m 4. bd_Convert.exe converts a number in decimal format to hexadecimal and vice versa To install ---------- Copy the EXE files into a directory on your current search path, such as C:\WINDOWS. Alternatively, copy to any directory and open the command prompt in that directory. Syntax ------ bd_ModExp [-x] a e m calculates b = a^e mod m Options: -x = use hex numbers (default = decimal). bd_ModInv [-x] a m calculates b = a^{-1} mod m. Options: -x = use hex numbers (default = decimal). bd_ModMult [-x] a b m calculates c = a*b mod m Options: -x = use hex numbers (default = decimal). bd_Convert [-x2d|-d2x] b converts number b in decimal format to hexadecimal and vice versa Options: -d = b is in decimal, convert to hex (default) -x = b is in hex, convert to decimal Examples -------- bd_modexp 14313 3 17947 13366 bd_modinv 3 17680 11787 bd_modexp 13366 11787 17947 14313 bd_modexp -x 3436 2e0b 461b 37e9 (i.e. the same calculation as before but in hex) bd_convert -x 37e9 14313 bd_convert 65537 10001 Show that (m^e mod n).z^e mod n == (m.z)^e mod n for m=0xdead, z=0xbeef, n=0xcafefacade: LHS: bd_modexp -x dead 3 cafefacade dead^3 mod cafefacade = 5ecc612b9d bd_modexp -x beef 3 cafefacade beef^3 mod cafefacade = bf65886479 bd_modmult -x 5ecc612b9d bf65886479 cafefacade 5ecc612b9d*bf65886479 mod cafefacade = c8b85f8ae9 --[1] RHS: bd_modmult -x dead beef cafefacade dead*beef mod cafefacade = a6144983 bd_modexp -x a6144983 3 cafefacade a6144983^3 mod cafefacade = c8b85f8ae9 --[2] Thus LHS == RHS. Limits ------ The bd_mod functions accept in theory positive numbers of unlimited size. This may be limited by the character limit of your command line interpreter. Written by David Ireland Copyright (c) 2002-11 DI Management Services Pty Limited Report bugs to http://www.di-mgt.com.au First published: 14 November 2002 Last updated: 11 November 2011 +++++++++++++++++++++++++++++++++