Skip to content

Instantly share code, notes, and snippets.

@mimoo
Created November 6, 2017 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mimoo/1af93fe436c75511b737eddd9fe763bb to your computer and use it in GitHub Desktop.
Save mimoo/1af93fe436c75511b737eddd9fe763bb to your computer and use it in GitHub Desktop.
package main
import(
"fmt"
"encoding/hex"
"golang.org/x/crypto/curve25519"
)
func main(){
// decode given private key
privkey, _ := hex.DecodeString("803fcdab44e9958d2f8e4d47b5f0d481d6ddb79dd462a18ee65cabe94a9e455c")
var privkeyArray [32]byte
copy(privkeyArray[:], privkey)
// decode expected public key
expectedPubKey, _ := hex.DecodeString("26100e941bdd2103038d8dec9a1884694736f591ee814e66ae6e2e2284757136")
// create public key out of given private key
var pubkey [32]byte
curve25519.ScalarBaseMult(&pubkey, &privkeyArray)
// print
fmt.Println("calculated public key:", hex.EncodeToString(pubkey[:]))
fmt.Println(" given public key:", hex.EncodeToString(expectedPubKey))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment