Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Geiner Grandez Valle committed Oct 10, 2024
1 parent 31582fd commit 2ad6ee4
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,58 @@ const vcPayload: JwtCredentialPayload = {
const privateKey = "<PRIVATE_KEY>";
const AMOY_CHAIN_ID = 80002;
const issuer = createDidEthrFromPrivateKey(privateKey, {chainNameOrId: AMOY_CHAIN_ID})
const proofTypeCredential = new ProofTypeJWT({issuer})
const proofTypeJwtCredential = new ProofTypeJWT({issuer})

const vcJwt = await proofTypeCredential.generateProof(vcPayload)
const vcJwt = await proofTypeJwtCredential.generateProof(vcPayload)
console.log(vcJwt)
// eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NkstUiJ9.eyJpYXQi...0CQmqB14NnN5XxD0d_glLRs1Myc_LBJjnuNwE
```

## Verifying JWTs
```ts
import { ResolverOrOptions, ProofTypeJWT } from '@kaytrust/prooftypes'
const RPC_AMOY = "<RPC_AMOY>";
const AMOY_CHAIN_ID = 80002;
const resolver:ResolverOrOptions = {registry: '0xBC56d0883ef228b2B16420E9002Ece0A46c893F8', rpcUrl: RPC_AMOY, chainId: AMOY_CHAIN_ID}
const proofTypeJwtCredential = new ProofTypeJWT({resolver})

const verifiedVC = await proofTypeJwtCredential.verifyProof(vcJwt)
console.log(verifiedVC)
/*
{
"payload": {
// the original payload of the signed credential
},
"doc": {
// the DID document of the credential issuer (as returned by the `resolver`)
},
"issuer": "did:ethr:0xf1232f840f3ad7d23fcdaa84d6c66dac24efb198", //the credential issuer
"signer": {
//the publicKey entry of the `doc` that has signed the credential
},
"jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NkstUiJ9.eyJpYXQiOjE1NjY...Sx3Y2IdWaUpatJQA", // the original credential
//parsed payload aligned to the W3C data model
"verifiableCredential": {
"@context": [Array],
"type": [ "VerifiableCredential", "UniversityDegreeCredential" ],
"issuer": {
"id": "did:ethr:0xf1232f840f3ad7d23fcdaa84d6c66dac24efb198"
},
"issuanceDate": "2019-07-12T16:51:22.000Z",
"credentialSubject": {
"id": "did:ethr:0x435df3eda57154cf8cf7926079881f2912f54db4"
"degree": {
"type": "BachelorDegree",
"name": "Baccalauréat en musiques numériques"
},
},
"proof": {
// proof type for internal use, NOT a registered vc-data-model type
"type": "JwtProof2020",
"jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NkstUiJ9.eyJpYXQiOjE1NjY...Sx3Y2IdWaUpatJQA"
}
}
}
*/
```

0 comments on commit 2ad6ee4

Please sign in to comment.