views:

103

answers:

2

I was getting bored so I started looking a little into Cryptography. I got interested in this Fair-Coin Flipping protocol. This protocol works 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:

  1. Alice and Bob both generate a public/private key pair (which is the commutative secret)
  2. 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.
  3. ...
  4. ...

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.?

+2  A: 

I'd suggest looking at something like crypto++, rather than doing cryptography yourself. There are other commercial libraries as well, but that should give you a good start.

Nick
"...are there any good libraries for generating the public/private keys and encrypting a given string etc.?" Sometimes I don't get the down-voting on SO...
Nick
@Nick: +1 for this. Not sure why you got a down vote but for now, this is what I was looking for. Thank You very much.
Legend
+1  A: 

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!)

Duracell
@Duracell: +1 for the library. Looks very impressive. Will try it out soon... Thanks.
Legend