I was getting bored so I started looking a little into Cryptography. I got interested in this Fair-Coin Flipping protocol. This protocol w开发者_StackOverfloworks with public key cryptography but requires that the algorithm commute (something like RSA I guess). I thought it would be fun to write this in either C or C++ and was wondering how people generally do this public key cryptography in C or C++. For instance, the first few steps of the protocol are:
- Alice and Bob both generate a public/private key pair (which is the commutative secret)
- Alice generates two messages, one indicating heads and the other indicating tails and encrypts both of them using her key and sends them to Bob.
- ...
- ...
Now, for the message, I will use perhaps a string but are there any good libraries for generating the public/private keys and encrypting a given string etc.?
Look at something like crypto++, rather than doing the cryptography yourself. There are other commercial libraries as well, but that should give you a good start.
I wrote a cryptography library as part of a university assignment on combinatorics. I used the GMP (GNUs Multiple Precision) library to generate random huge numbers (any number of bits that your computer can handle. So 4096 bit numbers are easy!)
精彩评论