| skipped 16 lines |
17 | 17 | | "strings" |
18 | 18 | | |
19 | 19 | | "github.com/flynn/noise" |
| 20 | + | "golang.org/x/crypto/curve25519" |
20 | 21 | | ) |
21 | 22 | | |
22 | 23 | | // The length of public and private keys as returned by GenerateKeypair. |
| skipped 208 lines |
231 | 232 | | |
232 | 233 | | // PubkeyFromPrivkey returns the public key that corresponds to privkey. |
233 | 234 | | func PubkeyFromPrivkey(privkey []byte) []byte { |
234 | | - | pair, err := noise.DH25519.GenerateKeypair(bytes.NewReader(privkey)) |
| 235 | + | pubkey, err := curve25519.X25519(privkey, curve25519.Basepoint) |
235 | 236 | | if err != nil { |
236 | 237 | | panic(err) |
237 | 238 | | } |
238 | | - | if !bytes.Equal(pair.Private, privkey) { |
239 | | - | panic("privkey was not as expected") |
240 | | - | } |
241 | | - | return pair.Public |
| 239 | + | return pubkey |
242 | 240 | | } |
243 | 241 | | |
244 | 242 | | // ReadKey reads a hex-encoded key from r. r must consist of a single line, with |
| skipped 44 lines |