This commit is contained in:
Michael Zhang 2022-03-06 16:38:50 -06:00 committed by Michael Zhang
parent 98e1972a80
commit 1884515c6b

View file

@ -1,6 +1,6 @@
+++ +++
title = "Learn by Implementing Elliptic Curve Crypto" title = "Learn by Implementing Elliptic Curve Crypto"
date = 2022-03-03 date = 2022-03-04
tags = ["crypto", "learn-by-implementing"] tags = ["crypto", "learn-by-implementing"]
draft = true draft = true
math = true math = true
@ -12,10 +12,12 @@ Good places to start (in terms of usefulness):
- [A relatively easy to understand primer on elliptic curve cryptography][2] by Cloudflare - [A relatively easy to understand primer on elliptic curve cryptography][2] by Cloudflare
- [Elliptic-curve cryptography][3] from Practical Cryptography - [Elliptic-curve cryptography][3] from Practical Cryptography
- [Elliptic-curve cryptography][1] on Wikipedia - [Elliptic-curve cryptography][1] on Wikipedia
- [Elliptic Curve Cryptography: a gentle introduction][4] by Andrea Corbellini
[1]: https://en.wikipedia.org/wiki/Elliptic-curve_cryptography [1]: https://en.wikipedia.org/wiki/Elliptic-curve_cryptography
[2]: https://blog.cloudflare.com/a-relatively-easy-to-understand-primer-on-elliptic-curve-cryptography/ [2]: https://blog.cloudflare.com/a-relatively-easy-to-understand-primer-on-elliptic-curve-cryptography/
[3]: https://cryptobook.nakov.com/asymmetric-key-ciphers/elliptic-curve-cryptography-ecc [3]: https://cryptobook.nakov.com/asymmetric-key-ciphers/elliptic-curve-cryptography-ecc
[4]: https://andrea.corbellini.name/2015/05/17/elliptic-curve-cryptography-a-gentle-introduction/
I'm writing this post because there's a lot of good posts out there introducing I'm writing this post because there's a lot of good posts out there introducing
the elliptic curve formula, but not many that continue with getting from there the elliptic curve formula, but not many that continue with getting from there
@ -57,9 +59,9 @@ those constraints.
Once we have the curve and a keypair, there's all sorts of different Once we have the curve and a keypair, there's all sorts of different
cryptographic schemes that we can now build on top of these foundations: cryptographic schemes that we can now build on top of these foundations:
- Encryption - [Encryption]({{< ref "#encryption" >}})
- Signatures - [Signatures]({{< ref "#signatures" >}})
- Diffie Hellman - [Key exchange]({{< ref "#key-exchange" >}})
## Implementation ## Implementation
@ -87,11 +89,17 @@ import (
### Math primitives ### Math primitives
```go ```go
type CurveParams struct { type Point struct {
P *big.Int x *big.Int
y *big.Int
inf bool
} }
```
```go
func (a Point) Add(b Point) Point {
return Point{}
}
``` ```
## Cryptographic applications ## Cryptographic applications