News for hackers. Stuff that matters.
Re:How I implemented my own crypto by loup-vaillant on Thursday August 03, 2017 @05:25AM (#14918122)
> The author's lack of practical familiarity with the memory hierarchy, caching, and pipelining

Maybe I didn't express myself clearly. I knew loading stuff word by word would be much faster, thanks to my knowledge of the memory hierarchy, caching, and pipelining.

What I didn't expect was the magnitude of the overall impact. The core round functions are much, much faster that I had anticipated. I didn't think the loading code, even in its slow version, would account for a significant percentage of the total running time.

> It would be great if this was written in another language.

Easier said than done. I aim for easy integration in projects written in basically anything: C, C++, OCaml, Rust, Python… What would you suggest? Rust? That's a possibility, but (i) it's LLVM only at the moment, and (ii) I believe there's an impedance mismatch between Rust and a C compatible ABI.

I would totally recommend to rewrite the whole thing in Rust for Rust projects, though.

Re:How I implemented my own crypto by arcticbull on Thursday August 03, 2017 @09:08AM (#14919173)
One of the major Rust design goals is simple C ABI compatibility, and it delivers there. That it's LLVM only appears to me irrelevant, as the generated libraries can be linked anywhere, and the specifics of how the Rust compiler are built are out of scope. So long as you get rustc up and running, what does it matter it's architecture?

If you're curious, check this out: https://doc.rust-lang.org/1.5.0/book/ffi.html

> I would totally recommend to rewrite the whole thing in Rust for Rust projects, though.

Any time you rewrite anything, you run the risk of introducing new and unexpected bugs, and you're just doing unnecessary, complex work fraught with pitfalls (doubly so here) -- generally a Rust project would create a wrapper around the C code, invoke the methods and expose idiomatic APIs on top to avoid just that.

This is my go-to article on re-writing things and why not to: https://www.joelonsoftware.com/2000/04/06/things-you-should-...

To be clear I'm not saying you made a mis-step, just that your arguments for it don't seem at first glance to support your decision.

Re:How I implemented my own crypto by loup-vaillant on Thursday August 03, 2017 @10:54AM (#14920080)
> One of the major Rust design goals is simple C ABI compatibility, and it delivers there.

I was just telling one has to write a wrapper either way. Idiomatic Rust is not idiomatic C, so you would need to have a "C ABI" interface in addition to the clean Rust interface.

> That it's LLVM only appears to me irrelevant […]

Not if it targets less platforms than GCC. Though that will likely matter less and less in the future.

> So long as you get rustc up and running, what does it matter it's architecture?

You have to get it up and running. You have another build step. You have to use a binary library (can't just include the source code). It's not much, but I want to maximise ease of deployment.