Created
November 6, 2017 11:45
-
-
Save mimoo/1af93fe436c75511b737eddd9fe763bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
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