You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Documentation: validatePrivateKey does not check typed array length #4
I'm submitting a ...
[x] bug report
[ ] feature request
[ ] question about the decisions made in the repository
[ ] question about how to use this project
Summary
Right now, I get positive feedback from validatePrivateKey for the input values
so it looks like in all the stack of validatePrivateKey, the input length is not checked.
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
Thanks, I should improve the documentation on validatePrivateKey to clarify the functionality there. There's a short note here on it – basically, I want to avoid adding any runtime checks which aren't necessary for 100% of consumers.
For most applications, when a potential new key is generated, it should be 32 bytes in length, so also validating the length in validatePrivateKey would be extraneous.
Ideally, TypeScript will eventually support stronger type guarantees about the length of a typed array so our function signature can specifically require a 32-byte Uint8Array (microsoft/TypeScript#18471). This would never be an error at runtime, because the compiler should be able to catch any instance in which the programmer accidentally generated the wrong size key (or failed to validate the length of a user-provided key), and those errors should never make it to runtime.
changed the title [-]Check private key length in validatePrivateKey[/-][+]Documentation: validatePrivateKey does not check typed array length[/+]on Jun 15, 2018
Activity
bitjson commentedon Jun 15, 2018
Hey @webmaster128, thanks for opening an issue!
Thanks, I should improve the documentation on
validatePrivateKeyto clarify the functionality there. There's a short note here on it – basically, I want to avoid adding any runtime checks which aren't necessary for 100% of consumers.For most applications, when a potential new key is generated, it should be 32 bytes in length, so also validating the length in
validatePrivateKeywould be extraneous.Ideally, TypeScript will eventually support stronger type guarantees about the length of a typed array so our function signature can specifically require a 32-byte Uint8Array (microsoft/TypeScript#18471). This would never be an error at runtime, because the compiler should be able to catch any instance in which the programmer accidentally generated the wrong size key (or failed to validate the length of a user-provided key), and those errors should never make it to runtime.
[-]Check private key length in validatePrivateKey[/-][+]Documentation: validatePrivateKey does not check typed array length[/+]webmaster128 commentedon Jun 15, 2018
👍 makes sense, thanks. If I know that, I can easily do the check in my own code.
bitjson commentedon Jun 19, 2018
Merging into #3, which I think probably handles this best.