[ANN] ToyPublicKeys.jl - Public key cryptography

Hello everyone! I’m happy to announce the first registered version of ToyPublicKeys, a mostly* Julia-native implementation of public-key cryptographic protocols**.

Public key cryptography is a key pillar of the modern internet, ensuring anonymity, integrity, key exchange and authentication. ToyPublicKeys aims to serve as a playground and educational resource for anyone curious about cryptography in Julia. It’s not meant to be production-ready but rather a starting point to spark more interest in the community.

Contributions—be it implementation, documentation, or auditing—are very much welcome! :slight_smile:

* BigInt from Julia base is binding to libGMP
** So far only RSA is implemented, but Diffie-Helman, ElGamal and the rest of the mainstream cryptosystems are planned :slight_smile:

8 Likes

Looks very interesting :partying_face:. I did not know of a few of the GMP methods one could use in the context of cryptography and I may take a note here. The goal of exploring the different ways one can implement public key cryptography and expose it via APIs is quite useful as users can have different preferences and RSA space is particularly unexplored.

You may also be interested in CryptoGroups.jl, which focuses only on discrete logarithm-based cryptography. As I identified when doing benchmarks for ShuffleProofs.jl, it would benefit from implementing Montgomery arithmetic for modular prime groups and rewriting of elliptic curve implementations for performance.

1 Like

Yes, I think I will likely use CryptoGroups.jl for eliptic stuff as it looks very solid. However, some libGMP functionality is not binded and Julia maintainers do not want to widen support for more the BigInt functionality. It was proposed, to bind it in dedicated package. I am not familiar with the Julia/C memory layout differences as of now, but I might try.

It seems to me, that maybe it could free up some of your util code in CryptoGroups.jl? As of now, I want/need more GMP in ToyPublicKeys as well

1 Like

I think a seperate GMP library that exposes common functionality used in cryptography may be a good idea. In Util.jl I have optimized int2octet and octet2int functions and a jacobi functions that is optimized for BigInt which I could contribute.

The name of the package could be something like CryptoGMP, GMPUtils or something like that would allow it to be easy found on the registry.

Note that the algorithms based on Diffie-Hellman, RSA, elliptic curves etc. are being phased out. NIST has standardized new ones which presumably are more resistant to quantum computers.

I am aware of the LWE based crypto that NIST is proposing. However, I am not yet fully familiar with the math behind it. But it is on my mind and will be hopefully some day implemented