Curve 25519 is one of the most widely used ECC methods. It uses a curve of \(y^2 = x^3 + 486662 x^2 + x\), and which is a Montgomery curve, over the prime field, and with a prime number of \(2^{255} − 19\). The output is a single x co-ordinate point and the base point is x = 9, with an order of \(2^{252}+27,742,317,777,372,353,535,851,937,790,883,648,493\). Curve 25519 is used in many applications including with TLS 1.3, OpenSSH, SmartFTP, Tor, SAFE (created by Maidsafe), Signal, WhatsApp, and Facebook Messenger.
Curve 25519 with Go |
Coding
package main import ( "golang.org/x/crypto/curve25519" "math/rand" "fmt" "time" ) func main() { rand.Seed(time.Now().UnixNano()) var privateKey [32]byte for i := range privateKey[:] { privateKey[i] = byte(rand.Intn(256)) } fmt.Printf("\nBase point:\t%x\n",curve25519.Basepoint) var publicKey [32]byte curve25519.ScalarBaseMult(&publicKey, &privateKey) fmt.Printf("\nPrivate key (n):\t%x\n",privateKey) fmt.Printf("\nPublic key point (x co-ord):\t%x\n",publicKey) } }
A sample run is:
Base point: 0900000000000000000000000000000000000000000000000000000000000000 Private key (n): 263b88ae941c252a99587abe3ae3ed5c6a2d2100be278526e9af75cbd28cfae7 Public key point (x co-ord): 287c59827ddcd06affd9caa084f05c961190be47a3eca059614f322a7c25a85c