()
| 10 | type NyPublicKey [device.NoisePublicKeySize]byte |
| 11 | |
| 12 | func GenerateKey() NyPrivateKey { |
| 13 | key := make([]byte, device.NoisePrivateKeySize) |
| 14 | |
| 15 | if _, err := rand.Read(key); err != nil { |
| 16 | panic(err) |
| 17 | } |
| 18 | |
| 19 | // Modify random bytes using algorithm described at: |
| 20 | // https://cr.yp.to/ecdh.html. |
| 21 | key[0] &= 248 |
| 22 | key[31] &= 127 |
| 23 | key[31] |= 64 |
| 24 | return NyPrivateKey(key) |
| 25 | } |
| 26 | |
| 27 | func (k NyPrivateKey) Pubkey() NyPublicKey { |
| 28 | val, err := x25519.PrivateKey(k[:]).PublicKey() |