-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
packages/snap/src/lib/keyDeriver.ts
Outdated
chain: ChainDefinition, | ||
keyIndex = 1, | ||
): Promise<PrivateKey> { | ||
if (keyIndex === 0) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
No description provided.