Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent signature results #37

Open
idcmp opened this issue Dec 9, 2022 · 1 comment
Open

Inconsistent signature results #37

idcmp opened this issue Dec 9, 2022 · 1 comment

Comments

@idcmp
Copy link

idcmp commented Dec 9, 2022

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?

@magierhsu
Copy link

the "privKey" in Go should be "seed[32]" concatenate "public_key[32]" in test.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants