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

Using different active and owner keys #13

Merged
merged 9 commits into from
Dec 5, 2024

Conversation

dafuga
Copy link
Contributor

@dafuga dafuga commented Dec 4, 2024

No description provided.

chain: ChainDefinition,
keyIndex = 1,
): Promise<PrivateKey> {
if (keyIndex === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is a strong enough check.

If I pass in keyIndex = undefined to this function, the value won't be equal to 0 - so it'll bypass this and then pass undefined to derivePrivateKey, which will default to 0 and return the owner key.

Maybe we need to write it like this:

if (Number(keyIndex) > 0) {
  return derivePrivateKey(chain, keyIndex);
}
throw new Error('Invalid key index');

We just need to make sure there's no way to access index 0 from this call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if you pass undefined then the default 1 will be used 😄

Copy link
Contributor Author

@dafuga dafuga Dec 4, 2024

Choose a reason for hiding this comment

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

If you want, I'll change the default of derivePrivateKey to 1 so the owner key is never returned by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍

@dafuga dafuga merged commit 2a49201 into master Dec 5, 2024
7 checks passed
@dafuga dafuga deleted the using-different-active-owner-keys branch December 5, 2024 01:30
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.

2 participants