This is an attempt at solving #758 and this is up for discussion.
The underlying issue is that downstream copied the code of ecdsa_signature_parse_der_lax
to their files (as initially intended). However later on, their copy and our copy evolved differently apparently without anyone being really aware of this or pointing this out, see https://github.com/bitcoin/bitcoin/pull/19228#issuecomment-641795558 for a detailed overview. This is bad for the obvious reasons that duplicate code should be avoided. Moreover, this turned out to be surprising, at least for me. For example, I was super careful in #578 because I and possibly also some of the reviewers assumed I’m touching (what will become) consensus code but in fact I was not (plus I reinvented some of the changes done already downstream). I can imagine I was not the only one who was confused and I guess the mere existence of the same function defined multiple times in the Bitcoin Core codebase in different ways has confused reviewers in the past because they may have been looking at the wrong code.
My initial plan was to take the downstream changes and apply them here, and then take any remaining differences and apply them upstream to make sure that the copies are in sync. However, I don’t think that’s the best solution because it doesn’t fix the underlying code duplication issue, and it would waste reviewer cycles (for touching consensus code that does not need to be touched).
My second plan was to propose a change to downstream that would simply include our contrib file. But that’s arguably against the spirit of the contrib files as @sipa pointed out. These functions rather serve as “documentation”. However, if that’s the primary purpose, we don’t need to keep them here in our repo but we can just refer to their downstream versions instead, in particular because we’re a subproject.
So taking all of this into account and after discussion this with @sipa, it seems that the cleanest way is to remove these files and simply point users to the downstream code. This also makes clear who (primarily) owns this code. This PR add the pointers to downstream now in our API help, which is also easier to find than the nowhere-mentioned contrib dir.
One seemingly strange thing about this PR is that it first tidies the DER seckey parsing function a little bit (renaming arguments and improving docs) and also gives the files better names, but then just removes the files. This is for historical reasons: The tidying commits are from my “initial plan”. But since I think these changes are real improvements (and should be applied to downstream – note that this touches only seckey parsing, not sig parsing) I kept them in here for reference. I can squash this of course, if people prefer this.
edit: also note that we explicitly didn’t guarantee the existence of these functions https://github.com/bitcoin-core/secp256k1/blob/master/contrib/lax_der_parsing.h#L8