new Ethers.Wallet giving me a 132 character public key? #2026
-
Hey guys I need help understanding something. When I use wallet = new Ethers.Wallet() and pass in a private key, and then wallet.publicKey, I am given a public key with 132 characters ( INCLUDING the 0x, so 130 without) Everywhere I read says a public key is 128 characters without the 0x. Eth.Build gives me a public key of 128 characters as a reference. any idea what I'm missing? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
A public key (uncompressed) is 65 bytes, which is 130 nibbles. The first byte for an uncompressed key is always If you are using a library that expects just the raw Make sense? |
Beta Was this translation helpful? Give feedback.
A public key (uncompressed) is 65 bytes, which is 130 nibbles. The first byte for an uncompressed key is always
04
, which indicates the key is uncompressed. The first by of a compressed key is always either02
or03
, depending on whether they
coordinate is “positive” or “negative” (the first bit is0
or1
respectively).If you are using a library that expects just the raw
x
andy
, you can trim off the first byte (the04
), but most libraries should be able to understand that initial byte and length indicates the following key is uncompressed and trim it off for you.Make sense?