3 ms·
If you want to see a "from scratch" implementation using existing algorithms, here's short working snippet of elliptic curve cryptography (specifically Bitcoin'
by wyc 9y ago
If you want to see a "from scratch" implementation using existing algorithms, here's short working snippet of elliptic curve cryptography (specifically Bitcoin's) without 3rd party libraries:
https://github.com/wyc/haschain/blob/master/Secp256K1.hs https://github.com/wyc/haschain/blob/master/Secp256K1.hs
The implementation doesn't concern itself with groups or fields, but they're still very useful to make sense of the code at all. Actually, I should add some types and implement an instance of Data.Group when I have more time.
Of course, it's for fun and not production use. I didn't give the slightest thought to timing attacks, optimized performance, etc.