[ecash-lib] Add payment with asn1 and x509
Summary:
Allows parsing X509 certificates. This is needed for verifying BIP70 PaymentRequests.
This is based on:
- https://github.com/hansekontor/checkout-components/blob/main/lib/b70/utils/asn1.js
- https://github.com/vinarmani/bitcore-payment-protocol
Names for the OID variables have been taken from https://oid-base.com/ (screaming snake case-ified). This is the reason why the OID constant of the secp256k1 curve is called OID_ANSIP256K1, because that's the official name.
Depends on D17733.
Test Plan:
npm test
Also, consider creating your own certificate and verify its signature using Ecc:
- openssl ecparam -genkey -out key.pem -name secp256k1
- openssl req -x509 -new -key key.pem -out cert.pem -sha256 -days 36500 -nodes -subj "/C=CA/ST=British Columbia/L=Vancouver/O=eCash Palace/OU=Software/CN=example.e.cash/emailAddress=example@e.cash"
- Replace the contents of the CERT variable with the inner content of cert.pem (without BEGIN CERTIFICATE)
- npm test -- -g 'asn1.readCert', and update some of the variables
Reviewers: bytesofman, #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D17734