Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Create Schema RPC on node #25

Closed
Vishwas1 opened this issue Feb 10, 2022 · 2 comments · Fixed by #49
Closed

Implement Create Schema RPC on node #25

Vishwas1 opened this issue Feb 10, 2022 · 2 comments · Fixed by #49
Assignees
Labels

Comments

@Vishwas1
Copy link
Contributor

Vishwas1 commented Feb 10, 2022

Introduction

The Credential Schema is a document that is used to guarantee the structure, and by extension the semantics, of the set of claims comprising a Verifiable Credential. A shared Credential Schema allows all parties to reference data in a known way.

4 Perspective of schema

  1. Author: An author creates a schema as a blueprint for a verifiable credential, specifying the shape and format of the data in such a credential.
  2. Issuer: utilize schemas to provide structure and meaning to the data they issue as verifiable credentials.
  3. Verifier: A schema always guarantees the structure of a credential. The described structure can be used by the Verifier to understand what data the Holder holds.
  4. Holder: Holders, or those who are the subject of credential issuance, can make sense of the data they own -- values -- by viewing it against a schema -- keys.

Credential Schemas are created and made available as immutable objects on a distributed ledger.

** id **

A globally unique identifier to locate the schema on a distributed ledger. This identifier is a Generic DID Parameter Name based upon the author of the schema. For example, if the author had a did like

did:work:abcdefghi

Metadata

  • type
  • modelVersion
  • id
  • schemaVersion
  • name
  • author
  • authored

A possible schema ID the author created would have ID such as:

did:work:abcdefghi;id=17de181feb67447da4e78259d92d0240;version=1.0

Example

{
  "type": "https://w3c-ccg.github.io/vc-json-schemas/schema/1.0/schema.json",
  "modelVersion": "1.0",
  "id": "did:work:MDP8AsFhHzhwUvGNuYkX7T;id=06e126d1-fa44-4882-a243-1e326fbe21db;version=1.0",
  "name": "EmailCredentialSchema",
  "author": "did:work:MDP8AsFhHzhwUvGNuYkX7T",
  "authored": "2018-01-01T00:00:00+00:00",
  "schema": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "description": "Email",
    "type": "object",
    "properties": {
      "emailAddress": {
        "type": "string",
        "format": "email"
      }
    },
    "required": ["emailAddress"],
    "additionalProperties": false
  },
  "proof": {
      "created": "2019-09-27T06:26:11Z",
      "creator": "did:work:MDP8AsFhHzhwUvGNuYkX7T#key-1",
      "nonce": "0efba23d-2987-4441-998e-23a9d9af79f0",
      "signatureValue": "2A7ZF9f9TWMdtgn57Y6dP6RQGs52xg2QdjUESZUuf4J9BUnwwWFNL8vFshQAEQF6ZFBXjYLYNU4hzXNKc3R6y6re",
      "type": "Ed25519VerificationKey2018"
  }
}

Versioning

Revision
The addition or removal of an optional field is what constitutes a REVISION. Read more https://w3c-ccg.github.io/vc-json-schemas/v1/index.html#revision

Model

When a schema breaks historical data we call it a model change. The most common case of a MODEL change is the addition or subtraction of a required field.

An example of this rule is when the additionalProperties field’s value changes. Changing additionalProperties from false to true OR from true to false constitutes a breaking change, necessitating a MODEL increment.

This line was wrritten in https://hyperledger-indy.readthedocs.io/projects/node/en/latest/transactions.html#schema not sure why?

It’s not possible to update an existing schema. So, if the Schema needs to be evolved, a new Schema with a new version or new name needs to be created.

Reference

@Vishwas1
Copy link
Contributor Author

Vishwas1 commented Feb 11, 2022

Example schema https://ssi.hypermine.in/core/api/v1/schema/sch_f3ab4b78-48fa-4a4d-9fe4-8f06dc501a6b

Schema Proto

https://w3c-ccg.github.io/vc-json-schemas/v1/index.html#credential_schema_definition_metadata

Schema: {
  type: string
  modelVersion: string
  id: string
  name: string
  author: string
  authored: string
  schema: SchemaProto
}

Schema Property Proto

https://w3c-ccg.github.io/vc-json-schemas/v1/index.html#credential_schema_definition_schema

ScheamProperty :{ 
  $schema: string / any
  description: string
  properties: string / any
  required: array
  additionalProperties: boolean
}

RPC

createSchema(Schema schema, Signatures  sig)

Validation

Validate basic format of shchema

Validate the format of id field

<did>;id=<guid>;version=<version>

example:

did:work:abcdefghi;id=17de181feb67447da4e78259d92d0240;version=1.0

did:work:abcdefghi;id=17de181feb67447da4e78259d92d0240;version=1.1

Validate Signature

  1. Get the author (did) from schema
  2. Get the the didDoc and publickey of the author
  3. If the didDoc does nto exists error => author did does not exists
  4. verify signature using the public key present in the did

Store the schema

key

id=17de181feb67447da4e78259d92d0240

value

schema

@Vishwas1 Vishwas1 changed the title Implement Credential Schema on Node Implement Create Schema RPC on node Feb 11, 2022
@arnabghose997 arnabghose997 self-assigned this Feb 11, 2022
@arnabghose997
Copy link
Contributor

arnabghose997 commented Feb 12, 2022

The PR (#49) has been merged. The details of test cases are updated in the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants