-
Notifications
You must be signed in to change notification settings - Fork 274
Error: Expected private key to be an Uint8Array #268
Comments
@shrpne do you have a script or repo to reproduce? using your code snippet works for me and I don't run into the error, it returns the publicKey fine for me. |
You can try it on my project. Try to run this test directly https://github.com/MinterTeam/minterjs-util/blob/ethereum-7/test/public.test.js#L13 or run If it is not suitable, then I can try to make a minimal test case later. But I still don't understand, how such code can run without problems: const privateToPublic = function(privateKey: Buffer): Buffer {
assertIsBuffer(privateKey)
publicKeyCreate(privateKey, false)
}
function publicKeyCreate (seckey, compressed = true, output) {
isUint8Array('private key', seckey, 32)
/* ... */
}, Because |
@shrpne a Node.js You can test this e.g. with the following code snippet in > let t = Buffer.alloc(0)
undefined
> t
<Buffer >
> Buffer.isBuffer(t)
true
> t instanceof Uint8Array
true This is also the code executed in the assertions from the function calls in your example above. |
Thank you for clarification Looks like it is an issue with |
Ok, will close here. |
@holgerd77 could this be |
i worked around this by adding |
@kumavis did a bit of a first read on duck typing - e.g. https://realpython.com/lessons/duck-typing/ - but have no great experience with the concept. Please just open a new issue if you think this is worth a change to make (everyone else of course as well). |
Problem & solution: ethereumjs/ethereumjs-util#268
With such code:
I've got an error
privateToPublic want
Buffer
argument. And it uses publicKeyCreate which wantsUint8Array
.So I can't use either
Buffer
orUint8Array
My setup
macOS - 10.15.6
Node - 12.16.1
ethereumjs-util - 7.0.3
secp256k1 - 4.0.2
BTW I tried to clone
ethereumjs-util
and run its test and everything work fine, I don't understand why.The text was updated successfully, but these errors were encountered: