INNER CODE UNIT · Go

ExampleGenerateKey

aead/minisign · example_test.go:17

func ExampleGenerateKey() {
	// Generate a new minisign private / public key pair.
	publicKey, privateKey, err := minisign.GenerateKey(rand.Reader)
	if err != nil {
		panic(err) // TODO: error handling
	}

	// Sign a message with the private key
	message := []byte("Hello Gopher!")
	signature := minisign.Sign(privateKey, message)

	// Verify the signature with the public key and
	// print the message if the signature is valid.
	if minisign.Verify(publicKey, message, signature) {
		fmt.Println(string(message))
	}
	// Output: Hello Gopher!
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…