Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
LaTeX TikZ for Cryptographers (iacr.org)
105 points by lordqwerty on Aug 15, 2018 | hide | past | favorite | 22 comments


I never liked the syntax of TikZ and that things like computing points on a parametrized curve correctly are difficult due to the limitations of TeX...

Asymptote [0] is a great alternative to prepare precise illustrations programmatically, which also integrates neatly with LaTeX. Making figures like [1] for a thesis (all lines and intersection points computed exactly) was actually fun.

But for diagrams with lines and boxes I would really just use Inkscape.

[0] http://asymptote.sourceforge.net/

[1] https://imgur.com/a/7QzsbDP


I always use keynote for diagrams with lines and boxes, I really like how simple it is to do something nice.

I agree with your sentiment on tikz though, it is not a pleasure to write.


TikZ (and all the abstractions you can build on it) is one of my favorite parts of the LaTeX ecosystem. At its core is a layout engine where you describe how nodes and lines are laid out relative to others, and it spaces everything for you. https://github.com/jluttine/tikz-bayesnet , for instance, is a lightweight wrapper that lets you represent graphical models with code like:

    \node[latent, left=of y, yshift=0.5cm] (mu) {$\mu$} ;
Now that I'm no longer in academia, I've lost my muscle memory for the syntax, but every time I need to build a flowchart, I think back on this with fondness. If someone were to repackage this with a cloud-based IDE and autocomplete (maybe using something like https://latexbase.com/ ), maybe slightly kinder syntax, I could see it meeting a business need even for non-technical users who are fed up with the difficulty of "fitting something in" in a large PowerPoint flowchart.

There's also http://sketch4latex.sourceforge.net/ for 3D drawing, which is equally cool.


TikZ is a microcosm of LaTeX itself: powerful, expressive, able to automate repetitive tasks, beautiful output -- but sometimes, it takes forever to do something that would take a few mouse clicks in a GUI tool.


I completely hear you. Despite my extremely limited skills with TikZ, My brain "somehow" stubbornly insists to keep chugging along with TikZ, spending unreasonable amounts of time. But I love the end result; the way text and diagrams meld so cleanly. Nothing comes close.

On the unreasonable amount of time spent: Last December, "merely" to get the arrows right neatly arranged, I spent more than 2 hours :-(. See the transition from: wonky-arrows1.png --> wonky-arrows2.png --> much-better-arrows3.png --> even-better-arrows4.png (the "final") here[1].

In two months I have another deadline to produce some technical material with TikZ diagrams (that's my choice, though). I'm determined to become more efficient at it.

[1] https://kashyapc.fedorapeople.org/temp/tikz/


... but the text in the boxes still has a weird baseline. Sorry to spoil the fun, but if you just invested a few hours to learn how to work with Inkscape, you would become much more efficient sooner.

At some point during my PhD I accepted that LaTeX is not the right tool for graphical work. Stubbornly I was still texing my slides with Beamer, but half their content was figures prepared in Inkscape.


For this kind of thing, something like yEd [1], specialized for graphs should work nicely as well.

[1] https://www.yworks.com/yed-live/#file=https://gist.githubuse...


...weird baseline.

Is that caused by the tails of the letters "y" and "p"? The one box that doesn't have a tailed letter, "base", looks fine. There should be a way to tell the system to use the normal font baseline instead of something it can figure out geometrically.


I'm sure there is a way to tell TikZ about that.

In Inkscape you would just shift-click all words and click the baseline icon in the align-and-distribute panel.

The thing with preparing figures is that you want to iterate rapidly on small changes. That works so much better without a mental context switch between code and result and without having to wait for the compilation to finish (significant if the figure is embedded in a large document).

If you had to prepare hundreds of very similar diagrams that all need to look great, then I could understand the point of using TikZ for such a job.

Typesetting document text is different because LaTeX does a great job by default.


Hmm, I haven't even noticed the "weird baseline" (what is so weird about it?).

On Inkscape, another colleague also suggested it. I'll give it a try next week. My main use of LaTex (with Beamer) + TikZ is for not too complicated diagrams for presentations.


Yeah, I use beamer for (text + math + plot)-only content but as soon as any video or animation is needed, gotta switch to ppt or keynote


Yeah, I keep using it in the hope that I will slowly memorize it, and one day I will be able to use it effectively without constantly reading docs. This approach worked for LaTeX itself, and vim...


It's a pretty sweet system. I use it to design puzzle books. (Crisscross, Cryptograms, nonograms, fill-a-pix, etc.)

There is no greater time-sink than writing a true program in Latex... I generally write a C++ program to write the latex/Tikz code using the most basic primitives. I would prefer to do layout using a pure C++ 2d library such as SFML and then export a 'screen' as a PDF. But, to date we haven't been able to match the sheer 'beauty' of Latex/Tkz output.

Shameless plug for our puzzle books: search Amazon for Klooto Games.


I wish I had known about this when I was writing my dissertation.

This looks reasonably complete for a lot of the mathematical diagrams in cryptography. It would be nice if the supersingular isogeny support included more diagrams than just the Diffie Hellman key exchange protocol, but they’re a relatively recent are of study so it makes sense. But there are a lot of isogeny diagrams (such as endomorphisms, volcanoes and random walks) beyond SIDH.

For example, Luca De Feo’s 2017 article on isogeny mathematics in cryptography [1] (pages 10,11,13,18,21,27,28,32,35) and the 2011 Feo-Jao-Plut paper introducing isogeny key exchange [2] (pages 4,6,8,9,10) both have very beautiful, full-color diagrams to walk through very complex concepts. Luca De Feo has a tendency to put the TeX of his papers and slides on GitHub [3], so I’ve reused some of his diagrammatic code before :). I recall spending hours on some diagrams to make them look as nice as these.

Lattice-based constructions sometimes need good diagrammatic code as well, but thankfully you can mostly get by without it (even though lattice depictions can be pretty, as one of De Feo’s GitHub packages shows) - for instance, note the relative lack of diagrams in Peikert’s well-known survey on lattice cryptography [4].

____________________

1. https://arxiv.org/abs/1711.04062

2. https://eprint.iacr.org/2011/506.pdf

3. https://github.com/defeo

4. https://web.eecs.umich.edu/~cpeikert/pubs/lattice-survey.pdf


There is a great selection of examples of TikZ at http://www.texample.net/tikz/examples/


When I first saw TikZ code, I can't imagine how it could possibly work. Mystically beautiful.


The versatility stuns me to this day http://www.texample.net/tikz/examples/all/


My favorite feature is the "step-wise reveal" mechanic.


Is the code that powers this open source? It would be useful to collect snippets for other fields


Yes, and it has a documentation counting > 1000 pages:

https://ctan.org/pkg/pgf https://sourceforge.net/projects/pgf/


I meant the code for the site, not TikZ/PGF


I agree. Most scientific fields could benefit by having access to a repository of models and diagrams that are easily[1] modifiable.

[1] for some values of easy.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: