# The state of cryptographic libraries

**URL:** <https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724>\
**Category:** Community\
**Tags:** cryptography\
**Created:** [October 10, 2019, 9:41am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724 "2019-10-10T09:41:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Janis\_Erdmanis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/janis_erdmanis/32/10869_2.png) [@Janis\_Erdmanis](https://discourse.julialang.org/u/Janis_Erdmanis)\
**Post date:** [October 10, 2019, 9:41am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/1 "2019-10-10T09:41:37Z")

</div>

Hello, everyone!

For my next project, I need hashing and public-key cryptography. What are the options currently available in the Julia ecosystem to get those things?

Also, I need a secure messaging system within Julia. Ideally, a Julia client for Telegram, which I could not find. Is there anything else available what can I interface easily with Julia?

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [October 11, 2019, 7:18am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/2 "2019-10-11T07:18:37Z")

</div>

Pallier.jl is the only one I knoe

---

<div class="post-metadata">

**Author:** ![Janis\_Erdmanis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/janis_erdmanis/32/10869_2.png) [@Janis\_Erdmanis](https://discourse.julialang.org/u/Janis_Erdmanis)\
**Post date:** [October 16, 2019, 9:17am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/3 "2019-10-16T09:17:57Z")

</div>

I could not find Pallier.jl. Could you provide a link for it?

---

<div class="post-metadata">

**Author:** ![Janis\_Erdmanis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/janis_erdmanis/32/10869_2.png) [@Janis\_Erdmanis](https://discourse.julialang.org/u/Janis_Erdmanis)\
**Post date:** [October 16, 2019, 9:20am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/4 "2019-10-16T09:20:47Z")

</div>

I have found that ECC.jl in principle could provide the stuff I need. However, the library is too technical for my present understanding of cryptography. It would be really helpful if someone could answer the usage questions I have on it. I have posted them in [the GitLab issue](https://gitlab.com/braneproject/ECC.jl/issues/5).

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [October 16, 2019, 9:44am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/5 "2019-10-16T09:44:01Z")

</div>

[https://www.google.com/search?q=paillier.jl&rlz=1C1CHBF\_en-GBAU861AU861&oq=paillier.jl&aqs=chrome..69i57j0l5.2958j0j7&sourceid=chrome&ie=UTF-8](https://www.google.com/search?q=paillier.jl&rlz=1C1CHBF_en-GBAU861AU861&oq=paillier.jl&aqs=chrome..69i57j0l5.2958j0j7&sourceid=chrome&ie=UTF-8)

I have spoken to the author so let me know if you need an intro.

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [October 16, 2019, 9:47am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/6 "2019-10-16T09:47:12Z")

</div>

There is also `Nettle.jl`

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [October 16, 2019, 10:57am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/7 "2019-10-16T10:57:00Z")

</div>

A whole bunch of them are written in C/C++ and can easily be leveraged by Julia or by julia’s access to Bash.

---

<div class="post-metadata">

**Author:** ![Janis\_Erdmanis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/janis_erdmanis/32/10869_2.png) [@Janis\_Erdmanis](https://discourse.julialang.org/u/Janis_Erdmanis)\
**Post date:** [October 16, 2019, 11:33am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/8 "2019-10-16T11:33:23Z")

</div>

It’s perfect! Thank you 🙂

---

<div class="post-metadata">

**Author:** ![Janis\_Erdmanis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/janis_erdmanis/32/10869_2.png) [@Janis\_Erdmanis](https://discourse.julialang.org/u/Janis_Erdmanis)\
**Post date:** [October 16, 2019, 11:39am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/9 "2019-10-16T11:39:04Z")

</div>

Thanks. I will take hashing functions from there 🙂

---

<div class="post-metadata">

**Author:** ![Janis\_Erdmanis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/janis_erdmanis/32/10869_2.png) [@Janis\_Erdmanis](https://discourse.julialang.org/u/Janis_Erdmanis)\
**Post date:** [October 16, 2019, 11:41am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/10 "2019-10-16T11:41:29Z")

</div>

That was my backup plan. But then that would work only for Unix systems and wrapping and building C/C++ can be a pain.

---

<div class="post-metadata">

**Author:** ![bhgomes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bhgomes/32/9091_2.png) [@bhgomes](https://discourse.julialang.org/u/bhgomes)\
**Post date:** [October 29, 2019, 6:41pm UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/11 "2019-10-29T18:41:13Z")

</div>

> [@xiaodai](#):
>
> Pallier.jl is the only one I knoe

Are you referring to: [https://github.com/snipsco/paillier-libraries-benchmarks/tree/master/julia-sketch](https://github.com/snipsco/paillier-libraries-benchmarks/tree/master/julia-sketch)

---

<div class="post-metadata">

**Author:** ![foobar\_lv2](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Post date:** [October 30, 2019, 8:42am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/12 "2019-10-30T08:42:19Z")

</div>

For most applications, I really really recommend using a well-established conservative C library, and _not_ using some half-baked implementation from github / gitlab. Don’t get me wrong, half-baked implementations from github / gitlab are awesome and are exactly what you want for toying around with protocols and cryptographic research.

Crypto that faces attackers is _hard_.

For example, you probably want your public key functions resistant against timing sidechannel. ECC.jl is not constant-time, as far as I looked at the code. Even if it was, you are unqualified to audit the implementation for side-channels and therefore should never use it in prod.

---

<div class="post-metadata">

**Author:** ![mratsim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mratsim/32/10557_2.png) [@mratsim](https://discourse.julialang.org/u/mratsim)\
**Post date:** [October 30, 2019, 10:10am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/13 "2019-10-30T10:10:57Z")

</div>

I’m working in crypto, and finding generic side-channel resistant elliptic curve libraries seem close to impossible. People always use `if` branches for some reason ;).

So far only [Milagro](https://milagro.apache.org/docs/amcl-overview/#multi-lingual-support) seems to fit the bill but the build process involves Python codegen for specific curves and the coding style is very strange for the GO/Rust/Java implementation.

---

<div class="post-metadata">

**Author:** ![Janis\_Erdmanis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/janis_erdmanis/32/10869_2.png) [@Janis\_Erdmanis](https://discourse.julialang.org/u/Janis_Erdmanis)\
**Post date:** [October 30, 2019, 10:49am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/14 "2019-10-30T10:49:34Z")

</div>

I am just hoping that by making an awesome use of cryptographic libraries someone would be willing to invest time to make cryptographic library situation better for Julia. For the moment half baked implementations are good for me 😉

---

<div class="post-metadata">

**Author:** ![Janis\_Erdmanis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/janis_erdmanis/32/10869_2.png) [@Janis\_Erdmanis](https://discourse.julialang.org/u/Janis_Erdmanis)\
**Post date:** [October 30, 2019, 11:47am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/15 "2019-10-30T11:47:52Z")

</div>

Would be great to have a Milagro.jl 😉

---

<div class="post-metadata">

**Author:** ![Brian\_Thorne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brian_thorne/32/6990_2.png) [@Brian\_Thorne](https://discourse.julialang.org/u/Brian_Thorne)\
**Post date:** [January 22, 2020, 8:53pm UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/16 "2020-01-22T20:53:39Z")

</div>

Author of [Paillier.jl](https://github.com/hardbyte/Paillier.jl) here, just wanted to point out it is not using constant time functions, and doesn’t offer any hashing capabilities. Rather it is a tool for building prototypes of systems and protocols relying on a partially homomorphic cryptosystem.

---

<div class="post-metadata">

**Author:** ![blenessy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blenessy/32/14210_2.png) [@blenessy](https://discourse.julialang.org/u/blenessy)\
**Post date:** [April 19, 2020, 4:21pm UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/17 "2020-04-19T16:21:10Z")

</div>

I have created libs & bindings for [Apache Milagro Crypto Library (AMCL) 2.0.1](https://github.com/apache/incubator-milagro-crypto-c). It is in very early stage, but all C API should be exposed in Julia and it supports all Julia platforms (incl. Linux, Windows, MacOS, FreeBSD).

I’m working on getting it registered in the General Julia registry. Until then, you can install it from here:

> **[GitHub - blenessy/MilagroCrypto.jl: Julia bindings for AMCL\_jll](https://github.com/blenessy/MilagroCrypto.jl)**
>
> Julia bindings for AMCL\_jll. Contribute to blenessy/MilagroCrypto.jl development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Janis\_Erdmanis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/janis_erdmanis/32/10869_2.png) [@Janis\_Erdmanis](https://discourse.julialang.org/u/Janis_Erdmanis)\
**Post date:** [April 19, 2020, 6:30pm UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/18 "2020-04-19T18:30:21Z")

</div>

This is big! Thank you for the wrapper, it is much needed 🙌

In the example, I see how to make signatures and verify them. Is it also possible to work directly with the primitives themselves? For example, can I access cryptographic groups (or curves) to use them to implement Diffie-Hellman key exchange?

---

<div class="post-metadata">

**Author:** ![blenessy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blenessy/32/14210_2.png) [@blenessy](https://discourse.julialang.org/u/blenessy)\
**Post date:** [April 20, 2020, 9:18am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/19 "2020-04-20T09:18:45Z")

</div>

Yes, you can access all primitives and low-level functions to build your own crypto.  
I just did not have time to do more examples.

Get the generator point for BLS381:

```julia
using AMCL
g = AMCL.ECP_BLS381(undef)
ECP_BLS381_generator(g)

```

Most of the work remaining is to make the lib more fluent by defining relevant operators in the Base package. E.g. currently you can only compare two BLS381 points in the base field:

> <https://github.com/blenessy/MilagroCrypto.jl/blob/v0.201.0/src/AMCL.jl#L43>

But its only mechanical work to add these

---

<div class="post-metadata">

**Author:** ![blenessy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blenessy/32/14210_2.png) [@blenessy](https://discourse.julialang.org/u/blenessy)\
**Post date:** [April 26, 2020, 8:08am UTC](https://discourse.julialang.org/t/the-state-of-cryptographic-libraries/29724/20 "2020-04-26T08:08:57Z")

</div>

- Renamed the package to more descriptive [MilagroCrypto](https://github.com/blenessy/MilagroCrypto.jl).

- Created a [PR](https://github.com/JuliaRegistries/General/pull/13666) to get it into the Julia [General](https://github.com/JuliaRegistries/General) registry.

- Enabled all AMCL primitives (BIG\*, DBIG\*, FP\*, ECP\*) that I could identify. You should be able to implement whatever Crypto Lib/App efficiently on top of this now.
