Refactor IsValidSignatureEncoding
Refactor IsValidSignatureEncoding

Summary:
Mostly reorder stuff and add a lot of comments to explain what it is doing.

Depends on D1571

Test Plan:
  make check

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Subscribers: jasonbcox, teamcity

Differential Revision: https://reviews.bitcoinabc.org/D1576

bitcoinxt/bitcoinxt,bitcoinxt/bitcoinxt,bitcoinxt/bitcoinxt,bitcoinxt/bitcoinxt,bitcoinxt/bitcoinxt,bitcoinxt/bitcoinxt