decentralized-identity / lds-ecdsa-secp256k1-2019.js

EcdsaSecp256k1Signature2019 JSON-LD Signature Suite
https://identity.foundation/lds-ecdsa-secp256k1-2019.js/
Apache License 2.0
17 stars 4 forks source link

Examples, Command-Line Details, Webapp, and/or Shell Script Harness? #23

Open ChristopherA opened 4 years ago

ChristopherA commented 4 years ago

For those of use who are not Javascript devs, but wish to either leverage this library to create working example valid documents, for testing for conformance, or to test our own non-Javascript implementations, I would really like to see:

a) An examples folder, with keys, input and the resulting output, in sufficient detail that node and javascript are not required to test against.

b) Either details in the documentation of how to generate the examples in a completely from the command-line, or shell scripts to do the same.

c) A webapp doing the signing locally that can test with given WIF and HEX private keys.

OR13 commented 4 years ago

It should be possible to overwrite the signer similar to how we do for gpg here: https://github.com/transmute-industries/lds-gpg2020/blob/master/bin/bin.js#L117

The issue is that 90% of what this suite does is actually in jsonld.js & bitcoin-ts... the signing itself is defined here:

https://bitauth.github.io/bitcoin-ts/interfaces/secp256k1.html#signmessagehashcompact

I would actually recommend avoiding this library and using https://github.com/transmute-industries/lds-jws2020

Which makes it much clearer how to generate signatures, because it uses standard jose...

https://github.com/transmute-industries/lds-jws2020/blob/master/src/JsonWebKeyLinkedDataKeyClass2020.js#L198

^ this library also supports ed25519 / p-256 / rsa.... so for the cost of understanding one kind of signature (detachd jws), you can now use all the JWS algs supported by jose... of course, if you know you only need secp256k1 or ed25519, you can choose to use suites that only support them.

OR13 commented 4 years ago

This web app demo: https://identity.foundation/lds-ecdsa-secp256k1-2019.js/demo/

uses the web assembly version of bitcoin-ts, does the signing locally in browser, but the interface requires keys in JWK format... you can use this to convert to JWK from hex:

https://github.com/decentralized-identity/lds-ecdsa-secp256k1-2019.js/blob/master/packages/es256k-jws-ts/src/keyUtils.spec.ts#L20

OR13 commented 4 years ago

c) A webapp doing the signing locally that can test with given WIF and HEX private keys.

This should be very easy to do, we just do the key conversion locally before using the library as we do in the demo today.

b and c) are sorta accomplished here:

It would probably be better to just make a new test in jws2020 which was closer to https://tools.ietf.org/html/rfc7520

OR13 commented 4 years ago

the difference between this suite and jws2020, is that this one runs in the browser, and only supports ES256K.