bshambaugh / BlinkyProject

4 stars 0 forks source link

Bring in JavaScript / TypeScript code from key-did-provider-p256Test-remote ... fix signer for JWT #14

Open bshambaugh opened 1 year ago

bshambaugh commented 1 year ago

https://github.com/bshambaugh/key-did-provider-p256Test-remote/tree/master/src

Here is a gist of the results of running remoteT4.js

https://gist.github.com/bshambaugh/9ca6abde074b559ab46a8624bdf0bda6

Here is the relevant stuff:

https://twitter.com/Brent_Shambaugh/status/1595847900650786820?s=20&t=udPnofc1ox3qn2yk5hbmyw message: https://ceramic-clay.3boxlabs.com/api/v0/streams/k3y52l7qbv1fry9pmqrwfi6l7o3aqb387c9ouhwt35klzja8536eg5dxbqvp5yk8w schema: https://gist.github.com/bshambaugh/9ca6abde074b559ab46a8624bdf0bda6

Unfortunately I do not get the same nice results as before:

https://twitter.com/Brent_Shambaugh/status/1595845195685400576?s=20&t=udPnofc1ox3qn2yk5hbmyw

verify the signatures using https://www.rfc-editor.org/rfc/rfc7519 and https://www.rfc-editor.org/rfc/rfc7520

This is the most simple code that will work:


websocketServer.on('stream',function(stream,request) {

 //   stream.setEncoding('utf8');

setTimeout(function(){
  (async function() {

          let did = 'did:key:zDnaezUFn4zmNoNeZvBEdVyCv6MVL69X8NRD8YavTCJWGuXM7';
          const signer = await remoteP256Signer(stream);
          const jwt = await createJWT({ requested: ['name', 'phone'] }, { issuer: did, signer },{alg: 'ES256'})
          console.log(jwt)

  })();

},250);

})

posted in #cplusplus in techlahoma on Nov 11th at 10:05:55PM

this is probably this code: https://github.com/bshambaugh/key-did-provider-p256Test-remote/blob/master/src/remote-matchDIDKeyWRemoteT2-getJWT-nl1.1.ts

go back to verify the JWT using the method in RFC7520 and then

bshambaugh commented 1 year ago

~/Downloads/key-did-provider-p256Test-remote/lib$ node remote-matchDIDKeyWRemoteT2-getJWT-nl1.1.js addr: 127.0.1.1 here is the signature eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2NjkzMjY3ODksInJlcXVlc3RlZCI6WyJuYW1lIiwicGhvbmUiXSwiaXNzIjoiZGlkOmtleTp6RG5hZXpVRm40em1Ob05lWnZCRWRWeUN2Nk1WTDY5WDhOUkQ4WWF2VENKV0d1WE03In0 Uint8Array(188) [ 101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 70, 85, 122, 73, 49, 78, 105, 73, 115, 73, 110, 82, 53, 99, 67, 73, 54, 73, 107, 112, 88, 86, 67, 74, 57, 46, 101, 121, 74, 112, 89, 88, 81, 105, 79, 106, 69, 50, 78, 106, 107, 122, 77, 106, 89, 51, 79, 68, 107, 115, 73, 110, 74, 108, 99, 88, 86, 108, 99, 51, 82, 108, 90, 67, 73, 54, 87, 121, 74, 117, 89, 87, 49, 108, 73, 105, 119, 105, 99, 71, 104, 118, 98, 109, 85, 105, 88, 83, 119, ... 88 more items ] fed a string Uint8Array(32) [ 220, 218, 48, 196, 116, 182, 99, 12, 54, 187, 241, 14, 249, 96, 120, 8, 97, 42, 192, 46, 10, 206, 133, 213, 3, 140, 74, 37, 70, 84, 185, 107 ] dcda30c474b6630c36bbf10ef9607808612ac02e0ace85d5038c4a254654b96b signatureresult signature,33ad3f7eb06df2b408f2bba2d9e5264291ece0e273d192b0e116516c843ea39751d0aeb2c33ac8402dc3517db194085943eb88a48b275bc325f58489462b1b47 Uint8Array(64) [ 51, 173, 63, 126, 176, 109, 242, 180, 8, 242, 187, 162, 217, 229, 38, 66, 145, 236, 224, 226, 115, 209, 146, 176, 225, 22, 81, 108, 132, 62, 163, 151, 81, 208, 174, 178, 195, 58, 200, 64, 45, 195, 81, 125, 177, 148, 8, 89, 67, 235, 136, 164, 139, 39, 91, 195, 37, 245, 132, 137, 70, 43, 27, 71 ] the signature is: M60_frBt8rQI8rui2eUmQpHs4OJz0ZKw4RZRbIQ-o5dR0K6ywzrIQC3DUX2xlAhZQ-uIpIsnW8Ml9YSJRisbRw eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2NjkzMjY3ODksInJlcXVlc3RlZCI6WyJuYW1lIiwicGhvbmUiXSwiaXNzIjoiZGlkOmtleTp6RG5hZXpVRm40em1Ob05lWnZCRWRWeUN2Nk1WTDY5WDhOUkQ4WWF2VENKV0d1WE03In0.M60_frBt8rQI8rui2eUmQpHs4OJz0ZKw4RZRbIQ-o5dR0K6ywzrIQC3DUX2xlAhZQ-uIpIsnW8Ml9YSJRisbRw

bshambaugh commented 1 year ago

add sections to :~/Downloads/testNPMJose/src$ cat testSignature.ts , since this is where you were checking the JWTs (actually JWS) before.