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

Add flag for specifying secret key #77

Merged
merged 2 commits into from Jan 19, 2023

Conversation

networkException
Copy link
Contributor

This pull request adds a command line flag allowing users to pass a hex encoded ed25519 private key to be used for the router identity keypair.

Signed-off-by: networkException <git@nwex.de> (private sign-off)

Copy link
Contributor

@neilalexander neilalexander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn’t using the hex-provided input as the private key, this is using the hex-provided input as a seed to the random generator. I assume this isn’t what you intended?

@networkException
Copy link
Contributor Author

The implementation is just using the seed as the private key, I'm not sure if thats a great idea but...

Here its reading the seed from the passed reader to then generate a new keypair which just gets the seed set as the private key

@networkException
Copy link
Contributor Author

Do you know of a better way to do this?

@devonh
Copy link
Collaborator

devonh commented Jan 15, 2023

Instead of using GenerateKey when a private key is provided, could you just use NewKeyFromSeed directly?
It's a little clearer to understand since there is no indirection through the rand reader.
ie. something like:

	var sk ed25519.PrivateKey
	if len(*secretkey) != 0 {
		secretkeyHex, err := hex.DecodeString(*secretkey)
		if err != nil {
			panic(err)
		}

		sk = ed25519.NewKeyFromSeed(secretkeyHex)
	} else {
		var err error
		_, sk, err = ed25519.GenerateKey(nil)
		if err != nil {
			panic(err)
		}
	}

This patch adds a command line flag allowing users to pass a hex encoded
ed25519 private key to be used for the router identity keypair.

Signed-off-by: networkException <git@nwex.de>
@devonh devonh self-requested a review January 19, 2023 19:21
@devonh devonh merged commit 6430893 into matrix-org:main Jan 19, 2023
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

Successfully merging this pull request may close these issues.

None yet

3 participants