diff --git a/README.md b/README.md index 9c0a021..c82398f 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,17 @@ const notarySecretKeyJwk = await cose.key.generate( const notaryPublicKeyJwk = await cose.key.publicFromPrivate( notarySecretKeyJwk ); -const issuer = cose.detached.signer({ secretKeyJwk: issuerSecretKeyJwk }); -const notary = cose.detached.signer({ secretKeyJwk: notarySecretKeyJwk }); + +const issuer = cose.detached.signer({ + remote: cose.crypto.signer({ + secretKeyJwk: issuerSecretKeyJwk, + }), +}); +const notary = cose.detached.signer({ + remote: cose.crypto.signer({ + secretKeyJwk: notarySecretKeyJwk, + }), +}); const content = fs.readFileSync("./examples/image.png"); const signatureForImage = await issuer.sign({ @@ -76,9 +85,15 @@ const transparentSignature = await cose.receipt.add( receiptForImageSignature ); const resolve = async ( - header: cose.ProtectedHeaderMap + coseSign1: cose.CoseSign1Bytes ): Promise => { - const kid = header.get(4); + const { tag, value } = cose.cbor.decodeFirstSync(coseSign1); + if (tag !== 18) { + throw new Error("Only tagged cose sign 1 are supported"); + } + const [protectedHeaderBytes] = value; + const protectedHeaderMap = cose.cbor.decodeFirstSync(protectedHeaderBytes); + const kid = protectedHeaderMap.get(4); if (kid === issuerPublicKeyJwk.kid) { return issuerPublicKeyJwk; }