Hacker News new | past | comments | ask | show | jobs | submit login
Constantine: modular, high-performance, zero-dependency cryptography stack (nim-lang.org)
77 points by michaelsbradley 9 months ago | hide | past | favorite | 12 comments



Author here, adding an accompanying post focused on performance: https://ethresear.ch/t/releasing-constantine-v0-1-0-a-modula...


TW: blockchain

> Releasing Constantine v0.1.0 - A modular cryptography stack for blockchain and proof systems

I guess OP had to “edit” the title for conciseness…


Ferengi Rule of Acquisition #239: Never be afraid to mislabel a product.

Cryptography and cryptocurrency aren't the same, and I know of no other use for blockchain. Maybe they were hoping to win over non-believers by deceiving them about the content of the article.


let me guess, you don't actually write code. just talk down people who actually do this is a crypto lib and the authors repo obv has a ton of hardwork https://github.com/mratsim/constantine


> Cryptography and cryptocurrency aren't the same,

They aren't, but this is a cryptography library.


At a glance it seems fair to say that this is both a cryptocurrency library and a cryptography library.

The only truly general purpose thing here is SHA256. Every protocol on its supported list starts with either "ethereum" or "evm", and to the best of my knowledge the other primitives have seen very little use besides cryptocurrency.


The Internet Engineering Task Force, which in particular standardizes TLS, has acknowledge my contributions for my contributions to the very generic and globally useful hashing-to-curve primitive: https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-t...

And BLS signatures are standards as well: https://www.ietf.org/archive/id/draft-irtf-cfrg-bls-signatur...


BLS signatures are general purpose, the only Ethereum specific thing is choosing which elliptic curves are used for public keys and which for signatures as well as a prefix before hashing inputs.

Similarly KZG polynomial commitments are generic, the Ethereum specific thing is the trusted setup ceremony which needs to be specialized per protocol.

The finite field backends and the elliptic curves supported are all generic as well: https://github.com/mratsim/constantine/blob/master/constanti...


the vehemently anti-blockchain community is starting to sound more religious about their belief than the cryptobros ever did...


I think this is cool, but how sure are the authors that this is side-channel safe? There is a similar (modular, high performance, zero-dependency) library in Common Lisp but it can't give side-channel guarantees due to how some Common Lisp compilers implement integer and arithmetic functions

https://github.com/sharplispers/ironclad


Great question, first of all I did extensive research https://github.com/mratsim/constantine/wiki/Constant-time-ar....

Then the library defines its own types SecretBool and SecretWord throughough library that cannot be mixed with regular Nim types and are based on uint32/uint64 so the compiler cannot assume 0/1 and do boolean logic.

Assembly is used to avoid compilers getting too smart and reintroducing branches but the no-assembly fallback should still compile without branches.

By convention, all variable-time cryptographic functions are suffixed _vartime.

There is a plan to add automated constant-time checks as well https://github.com/mratsim/constantine/issues/7.


> Constantine has been written to have zero-dependency, besides the Nim compiler.

More of this, please. I think this should be the norm.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: