Photo by Tyler Easton on Unsplash

Big Integers and Some Crypto Homomorphic Magic

--

In software, we normally use integers that have 32-bit or 64-bit values. But in cryptography, we can be using 1,024, 2,048 and even 4,096-bit values. So, how do we do that? Well, we use Big Integers, and which can be of any size. In this article, we will implement a Paillier homomorphic method using Big Integers. A 2,048-bit value, for example, has this many digits:

32,317,006,071,311,007,300,714,876,688,669,951,960,444,102,669,715,
484,032,130,345,427,524,655,138,867,890,893,197,201,411,522,
913,463,688,717,960,921,898,019,494,119,559,150,490,921,095,088,152,386,448,283,120,630,877,367,300,996,091,750,197,750,389,652,
106,796,057,638,384,067,568,276,792,218,642,619,756,161,838,094,338,476,170,470,581,645,852,036,305,042,887,575,891,541,065,808,
607,552,399,123,930,385,521,914,333,389,668,342,420,684,974,786,564,569,494,856,176,035,326,322,058,077,805,659,331,026,192,708,
460,314,150,258,592,864,177,116,725,943,603,718,461,857,357,598,351,152,301,645,904,403,697,613,233,287,231,227,125,684,710,820,
209,725,157,101,726,931,323,469,678,542,580,656,697,935,045,997,268,352,998,638,215,525,166,389,437,335,543,602,135,433,229,604,
645,318,478,604,952,148,193,555,853,611,059,596,230,656

In Golang, we assign a value to a Big Integer in many ways, such as assigning an integer, byte values, or from an integer string. For integer casting, we can use…

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.