veramolabs / community-discord-bot

0 stars 1 forks source link

Kudos Credential schema #3

Closed simonas-notcat closed 2 years ago

simonas-notcat commented 2 years ago

Create and publish Kudos credential schema at https://github.com/veramolabs/vc-json-schemas

Example of current VCs:

{
  "credentialSubject": {
    "name": "okay_nick",
    "kudos": "For great work on DIDComm + libp2p",
    "author": {
      "name": "simonas",
      "avatar": "https://cdn.discordapp.com/avatars/306063654845939723/3c21cb6158e1a24a6789c56f155ec091.png"
    },
    "channel": {
      "id": "1001857008770760767",
      "name": "general",
      "nsfw": false
    },
    "guild": {
      "id": "1001857008229691432",
      "name": "Staging Veramo"
    },
    "avatar": "https://cdn.discordapp.com/avatars/682320516430037063/4bca4a46cd90f4ef34eb92308247c7d5.png",
    "id": "did:web:staging....7063"
  },
  "issuer": {
    "id": "did:web:staging.community.veramo.io:discord:306063654845939723"
  },
  "id": "1009104779064127602",
  "type": [
    "VerifiableCredential",
    "Kudos"
  ],
  "@context": [
    "https://www.w3.org/2018/credentials/v1"
  ],
  "issuanceDate": "2022-08-16T14:22:07.000Z",
  "proof": {
    "type": "JwtProof2020",
    "jwt": "eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiS3Vkb3MiXSwiY3JlZGVudGlhbFN1YmplY3QiOnsibmFtZSI6Im9rYXlfbmljayIsImt1ZG9zIjoiRm9yIGdyZWF0IHdvcmsgb24gRElEQ29tbSArIGxpYnAycCIsImF1dGhvciI6eyJuYW1lIjoic2ltb25hcyIsImF2YXRhciI6Imh0dHBzOi8vY2RuLmRpc2NvcmRhcHAuY29tL2F2YXRhcnMvMzA2MDYzNjU0ODQ1OTM5NzIzLzNjMjFjYjYxNThlMWEyNGE2Nzg5YzU2ZjE1NWVjMDkxLnBuZyJ9LCJjaGFubmVsIjp7ImlkIjoiMTAwMTg1NzAwODc3MDc2MDc2NyIsIm5hbWUiOiJnZW5lcmFsIiwibnNmdyI6ZmFsc2V9LCJndWlsZCI6eyJpZCI6IjEwMDE4NTcwMDgyMjk2OTE0MzIiLCJuYW1lIjoiU3RhZ2luZyBWZXJhbW8ifSwiYXZhdGFyIjoiaHR0cHM6Ly9jZG4uZGlzY29yZGFwcC5jb20vYXZhdGFycy82ODIzMjA1MTY0MzAwMzcwNjMvNGJjYTRhNDZjZDkwZjRlZjM0ZWI5MjMwODI0N2M3ZDUucG5nIn19LCJzdWIiOiJkaWQ6d2ViOnN0YWdpbmcuY29tbXVuaXR5LnZlcmFtby5pbzpkaXNjb3JkOjY4MjMyMDUxNjQzMDAzNzA2MyIsImp0aSI6IjEwMDkxMDQ3NzkwNjQxMjc2MDIiLCJuYmYiOjE2NjA2NTk3MjcsImlzcyI6ImRpZDp3ZWI6c3RhZ2luZy5jb21tdW5pdHkudmVyYW1vLmlvOmRpc2NvcmQ6MzA2MDYzNjU0ODQ1OTM5NzIzIn0.mWYv1_jVVd-nUuRMU0JDqwOeRERZQ_fDua6fagcnlP3Lbg44noTxBtKfBXdQ3r5tIpnXW9DU2kQ7SbVstrVrlQ"
  }
}
simonas-notcat commented 2 years ago

Kudos Credential Issuance options

Example situation:

Alice has asked a support question in one of the Discord channels. Bob quickly answered Alice's question. Alice wants to give kudos to Bob for quick response

Example slash-command:

/kudos to: @bob kudos: For quick support! 

In this scenario we have:

We want to create a Verifiable Credential that represents this interaction, so that it can be later used as part of portable and verifiable reputation for Bob and Alice.

Option 1 - custodial DIDs

Community bot checks if there is a managed DID associated with a discord userIds that are involved in this interaction, if not - creates custodial DIDs for them

const alice = await agent.didManagerGetOrCreate({
  alias: 'community.veramo.io:discord:1234567890',
  provider: 'did:web'
})

const bob = await agent.didManagerGetOrCreate({
  alias: 'community.veramo.io:discord:45678901234',
  provider: 'did:web'
})

Then issues credential on behalf of Alice:

const vc = await agent.createVerifiableCredential({
  save: true,
  proofFormat: 'jwt',
  credential: {
    id: interaction.id,
    issuer: { id: alice.did },
    credentialSubject: {
      id: bob.did,
      kudos: 'For quick support!'
      channel: 'https://discord.com/channels/878293684620234752/890207307433136178'
    },
    issuanceDate: new Date().toISOString(),
    type: ['VerifiableCredential', 'Kudos'],
    '@context': ['https://www.w3.org/2018/credentials/v1'],
  }
})

Option 2 - community bot as a Witness

There is only one managed DID in the agent, which represents the bot it self.

const bot = await agent.didManagerGetOrCreate({
  alias: 'community.veramo.io',
  provider: 'did:web'
})

We use this DID to issue a VCred:

const vc = await agent.createVerifiableCredential({
  save: true,
  proofFormat: 'jwt',
  credential: {
    id: interaction.id,
    issuer: { id: bot.did },
    credentialSubject: {
      id: 'https://discord.com/users/45678901234',
      kudos: 'For quick support!'
      author: 'https://discord.com/users/1234567890',
      channel: 'https://discord.com/channels/878293684620234752/890207307433136178'
    },
    issuanceDate: new Date().toISOString(),
    type: ['VerifiableCredential', 'Kudos'],
    '@context': ['https://www.w3.org/2018/credentials/v1'],
  }
})

Option 3 - Self Sovereign Identity model

In this scenario Alice and Bob should connect their wallets to the bot and register their self sovereign DID.

The code to issue VCred would look similar to the Option 1, but would require additional steps when onboarding users.

Also every interaction would require users to sign VCreds in their wallets

Comparison

Decision

After some internal conversations we decided to go with the Option 2.

Main reasons why: