I'm working on code that signs a message with an ed25519 key.
I expected that when signing the same message over and over, I'd get a
different signature each time.
But I find when I run the test (below) more than once, I get the same
signature bytes each time. Here's sample (identical) output from two
consecutive tests:
$ go run ~/devel/signtest/*.go
{
"Format": "ssh-ed25519",
"Blob":
"BRnwjfCMNZiqRRJdkZi7Gh0sOdJzOcPVIu/wWxlpRjogRnGJT3yn0wH3Fz6WvAmdYakNY7qkKfgSWe+t9PXiCQ=="
}
$ go run ~/devel/signtest/*.go
{
"Format": "ssh-ed25519",
"Blob":
"BRnwjfCMNZiqRRJdkZi7Gh0sOdJzOcPVIu/wWxlpRjogRnGJT3yn0wH3Fz6WvAmdYakNY7qkKfgSWe+t9PXiCQ=="
}
Am I misunderstanding how the ed25519 package signs? Do I have a bug in
the test code?
I'm very eager to better understand what's going on. Thanks in advance for
any help.
-Dave
package main
import (
"crypto/rand"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"golang.org/x/crypto/ssh"
)
func main() {
// generate key with `ssh-keygen -t ed25519 -N '' -f /tmp/id_ed25519`
buffer, err := ioutil.ReadFile("/tmp/id_ed25519")
check(err)
signer, err := ssh.ParsePrivateKey(buffer)
check(err)
signMe := []byte("sign me")
sig, err := signer.Sign(rand.Reader, signMe)
check(err)
out, err := json.MarshalIndent(sig, "", "\t")
check(err)
fmt.Println(string(out))
}
func check(err error) {
if err != nil {
log.Fatal(err)
}
}
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.