Skip to content

Inconsistent signature results #37

Description

@idcmp

Note: this library stores private keys in a different format than some other libraries, notably libsodium. They tend to store the concatenation of the seed and public_key as their private key representation. If you wish to be compatible with these libraries you must keep the seed around.

Can you expand on this? In Go, I'm generating a key pair, and using it for signing:

        // pubKey = 32 bytes, privKey = 64 bytes (which is seed + publicKey)
	pubKey, privKey, err := ed25519.GenerateKey(rand.Reader)

	goSignature := ed25519.Sign(privKey, exampleBytes)

When I do something similar with the same key material and ed25519_sign, I get a different signature:

	var pubBuf, privBuf, messageBuf, signatureBuf bytes.Buffer
	messageBuf.Write(exampleBytes)
	pubBuf.Write(pubKey)
	privBuf.Write(privKey)

	for i := 0; i != 64; i++ {
		signatureBuf.WriteByte(0)
	}
	C.ed25519_sign(
		(*C.uchar)(&signatureBuf.Bytes()[0]),
		(*C.uchar)(&messageBuf.Bytes()[0]),
		(C.ulong)(len(exampleBytes)),
		(*C.uchar)(&pubBuf.Bytes()[0]),
		(*C.uchar)(&privBuf.Bytes()[0]))

I'm guessing this is related to the comment above, but I'm not quite sure?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions