Certificates

Certificate related functions.

In the VeChainThor blockchain, a certificate is a data structure used for client-side self-signed certificates. It plays a crucial role in providing a mechanism for secure identification and validation of data. For example, when signing in to a Dapp, users typically need to sign a certificate as part of the authentication process. This certificate serves as cryptographic proof of their identity and authorization. Users use their private keys to sign the certificate, demonstrating their ownership and enabling secure access to the Dapp's services.

Purpose of Certificates

Certificates are primarily used for purposes like attestation, validation, and verification of data authenticity. They are used as proofs of authenticity and origin for data exchanged within the VeChain ecosystem.

Structure of a Certificate

A Certificate in the VeChainThor blockchain typically consists of the following components:

  1. Purpose: The purpose field indicates the intended use or context of the certificate. For example, it could be used for identification, verification, or attestation.

  2. Payload: The payload field holds the actual content of the certificate. This content can be of various types, such as text, images, or other data.

  3. Domain: The domain field represents the specific context or domain for which the certificate is valid. It helps ensure that the certificate is only applicable within the intended context.

  4. Timestamp: The timestamp field records the time at which the certificate was created or issued. This provides a temporal reference for the certificate's validity.

  5. Signer: The signer field indicates the address of the entity that signs the certificate. It is the public key address of the entity that issues the certificate.

  6. Signature: The signature field contains the cryptographic signature generated by the issuer's private key. This signature ensures the integrity and authenticity of the certificate's content.

Usage of Certificates

Certificates are used in various scenarios within the VeChainThor blockchain, including:

  • Proof of Authenticity: Certificates can be used to prove the authenticity and origin of data, ensuring that the data has not been tampered with or altered.

  • Identification: Certificates can be employed to establish the identity of a specific entity or participant within the blockchain ecosystem.

  • Verification: Certificates can be used to verify the validity of data or transactions, providing a mechanism for trust and validation.

Self-Signed Certificates

It's important to note that certificates in the VeChainThor blockchain are self-signed, which means that they are issued and signed by the same entity or user. The signature from the issuer's private key serves as proof of the certificate's authenticity.

// 1 - Generate a private key and address for the signer

const privateKey = await Secp256k1.generatePrivateKey();
const publicKey = Secp256k1.derivePublicKey(privateKey);
const signerAddress = Address.ofPublicKey(publicKey).toString();

// 2 - Create a certificate

const certificate = Certificate.of({
    purpose: 'identification',
    payload: {
        type: 'text',
        content: 'fyi'
    },
    domain: 'localhost',
    timestamp: 1545035330,
    signer: signerAddress
});

// 3 - Sign certificate

certificate.sign(privateKey);

// Verify certificate
certificate.verify();

Last updated