Open penso opened 7 months ago
Ugh, it's rather unfortunate whatever decided to do that used a garbage public key, especially as the value 0
is an actually valid SEC1 encoding of the identity point which would've made more sense for this application.
What decided to encode the key this way? Was it CometBFT itself?
Ugh, it's rather unfortunate whatever decided to do that used a garbage public key, especially as the value
0
is an actually valid SEC1 encoding of the identity point which would've made more sense for this application.What decided to encode the key this way? Was it CometBFT itself?
I'm not sure how it got there since I'm not involved in CometBFT neither DYDX. I feel like it's related to the node itself, maybe in its configuration?
There is a way to decode these points where k256
will accept this value, namely 33-bytes of all zero: using <k256::AffinePoint as GroupEncoding>::from_repr
, which always accepts a 33-byte array as input, and will decode 33-bytes of all zero as the identity point:
https://docs.rs/k256/latest/k256/struct.AffinePoint.html#impl-GroupEncoding-for-AffinePoint
Note however this is not a standard SEC1 encoding, just an eccentricity of how that particular API works because it takes an array as input and can't handle a shorter message, but if it matches what I hope is a CometBFT behavior and not some chain-specific one-off behavior it would fix this particular problem.
The current tendermint::PublicKey::Secp256k1
variant expressly disallows the identity point though, as it's not typically a valid public key, so switching to that would entail changing that variant to represent all secp256k1 public keys as k256::AffinePoint
rather than k256::ecdsa::VerifyingKey
, or handling this case with e.g. Option
, which might be a bit onerous from an API perspective.
As a follow-up, the way I "fixed" it is using my own code with reqwest (and not tendermint-rs) to fetch status information from nodes.
What went wrong?
There is an issue with secp256k1 parsing blank secp256k1 public keys.
The status json includes:
I don't think an invalid key should block using tendermint-rs for RPC calls, but not sure how this should be fixed. Do we expect public keys to be verified by default?