bitcoin: Serialization-deserialization roundtrip of CPubKey does not necessarily result in an equal object

When fuzzing the serialization code for CPubKey I noticed that Deserialize<CPubKey>(Serialize(obj)) == obj does not hold true for all CPubKey obj.

Is there any reason to why CPubKey is deviating from the other serializable classes (for which equality is defined) in this regard? 😃

Context:

template <typename T>
CDataStream Serialize(const T& obj)
{
    CDataStream ds(SER_NETWORK, INIT_PROTO_VERSION);
    ds << obj;
    return ds;
}

template <typename T>
T Deserialize(CDataStream ds)
{
    T obj;
    ds >> obj;
    return obj;
}

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

Fixed by @elichai in #19237 and regression fuzzed by @theStack in #22271.

Nice teamwork friends! 😃