> ## Documentation Index
> Fetch the complete documentation index at: https://trustos.telefonicatech.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Model

A certificate is a tamper-proof and verifiable collection of data that represents a process, a file/document, an accomplishment or any activity that can benefit from the immutability and authenticity.

Thanks to certificates, it allows you to **assure any fact in your business case recording the information along with parameters that everyone can verify** (e.g. signatures, issuance/expiration time, network evidences, etc..).

Every certificate is identified by a unique ID and is composed of three complementary but different parts: Data, Metadata and Access.

```mermaid theme={null}
graph TB
    A[Certificate]
    B[certID]
    C[Data]
    D[Metadata]
    E[Access]

    A --> B
    A --> C
    A --> D
    A --> E
```

### Data

Data contains the **immutable information about the certificate**: who issued it, when it was issued, when it will expire and of course what it is certified and what does it mean.

The certificate **`data`** contains the following fields:

| Field         |    Type   | Optional | Description                                                                            |
| :------------ | :-------: | :------: | :------------------------------------------------------------------------------------- |
| `name`        |  `string` |     ❌    | Name of the certificate.                                                               |
| `description` |  `string` |     ❌    | Description of the certificate.                                                        |
| `type`        |  `string` |     ❌    | Type of the certificate.                                                               |
| `content`     |  `object` |     ❌    | JSON of the certificate content. It contains the required information to be certified. |
| `issuer`      |  `string` |     ❌    | Issuer of the certificate.                                                             |
| `issuedOn`    | `integer` |     ❌    | Date and time of issuance in which the certificate was issued (Unix format).           |
| `expires`     | `integer` |     ✅    | Date and time of expiration in which the certificate will expire (Unix format).        |
| `hash`        |  `string` |     ❌    | Hash of the certificate.                                                               |

### Metadata

Metadata contains the **additional information that feeds the certificate** in order to update the status of the certificate (e.g. revocation, evidences) or to add required data to be valid and know how to verify it (e.g. signatures).

The certificate **`metadata`** contains the following fields:

| Field             |    Type   | Optional | Description                                                                         |
| :---------------- | :-------: | :------: | :---------------------------------------------------------------------------------- |
| `type`            |  `string` |     ❌    | Type of the transaction (Evidence/Signature/Revocation).                            |
| `networkId`       | `integer` |     ❌    | ID of the blockchain network.                                                       |
| `smartContract`   |  `string` |     ❌    | Address of the smart contract in the blockchain network.                            |
| `transactionHash` |  `string` |     ❌    | Transaction hash in the blockchain network.                                         |
| `trustPointHash`  |  `string` |     ❌    | Hash of the evidence (trustpoint) in the blockchain network.                        |
| `timestamp`       | `integer` |     ❌    | Date and time of the transaction in which the certificate was issued (Unix format). |

### Access

The property **`access`** contains the **information to access the certificate**. This information collects the personalized identifier of the certificate **`externalId`** if it has been established and its privacy.

Certificate **`access`** contain the following fields:

| Field            |    Type   | Optional | Description                                                                                       |
| :--------------- | :-------: | :------: | :------------------------------------------------------------------------------------------------ |
| `externalId`     |  `string` |     ✅    | Custom identifier of the certificate. It can be used to access the certificate instead of the ID. |
| `public`         | `boolean` |     ❌    | Indicates if the certificate is public or private.                                                |
| `certificatePin` |  `string` |     ✅    | Encrypted pin for access to the certificate if it is private.                                     |
