VeChain Docs
  • Welcome to VeChain
  • Blockchain Basics
    • Introduction to blockchain
    • Introduction to digital property
    • The evolution of the internet
  • Introduction to VeChain
    • About the VeChain blockchain
      • Consensus Deep Dive
      • Governance
    • Dual-Token Economic Model
      • VeChain (VET)
      • VeThor (VTHO)
    • Acquire VeChain Assets
    • Sustainability
  • Core Concepts
    • Networks
      • Thor Solo Node
      • Testnet
      • Mainnet
    • Nodes
      • Node Rewards Programme
    • Blocks
      • Block Model
    • Transactions
      • Transaction Model
      • Transaction Fees
      • Transaction Calculation
      • Meta Transaction Features
        • Transaction Uniqueness
        • Controllable Transaction Lifecycle
        • Clauses (Multi-Task Transaction)
        • Fee Delegation
          • Multi-Party Payment (MPP)
          • Designated Gas Payer (VIP-191)
        • Transaction Dependency
    • Block Explorers
    • Wallets
      • VeWorld
        • User Guide
          • Setup
          • Wallet
          • Signing
          • Activities
          • Settings
        • FAQ
      • Sync2
        • User Guide
          • Setup
          • Wallet
          • Signing
          • Activities
          • Settings
        • FAQ
      • Sync
        • User Guide
          • Wallet
          • Ledger Device
          • Browser dApps and web
          • Interact with dApps
          • Activities
          • Settings
          • Report an Issue
          • Contributing
        • FAQ
    • EVM Compatibility
      • VeChain Modifications
      • Methodology
      • Test Coverage
        • Gas model
        • Raw transaction
        • hardhat specific
          • Ganache failures
          • evm_increaseTime
        • Failures in constructor
        • eth_sign
        • Contract address prediction
        • BadBeacon proxy address at 0x1
      • How to Recreate
      • Additional Information
        • Using Governance Contracts
        • ERC1820/ERC777 Testnet
        • Delegate Options
    • Account Abstraction
      • UserOperation
      • Bundler
      • EntryPoint Contract
      • Account Factory Contract
      • Paymaster Contract
    • Token Bound Accounts
  • How to run a node
    • Nodes
    • How to run a Thor Solo Node
    • Custom Network
    • Connect Sync2 to a Thor Solo Node
  • Developer Resources
    • Getting Started
    • How to build on VeChain
      • Connect to the Network
      • Read Data
        • Read Blocks
        • Read Transactions
        • Read Accounts
        • States & Views
        • Events & Logs
        • VET Transfers
      • Write Data
        • Transactions
        • Fee Delegation
      • Listen to Changes
        • Events
        • VET Transfers
        • Transactions
        • Blocks
        • Beats
      • Build with Hardhat
      • Utilities
        • BigInt and Unit-Handling
        • Name Service Lookups
    • Example dApps
      • Buy me a Coffee
      • Token Bound Accounts
      • PWA with Privy and Account Abstraction
    • EVM Compatibility for Developers
      • Key Architectural Differences and Optimizations
      • Practical Implications for Developers: Key Considerations
      • RPC Methods (Detailed Breakdown)
      • Frequently Asked Questions (FAQs)
      • VeChain Blockchain Specifications
      • Key Differences Between VeChain and Ethereum (Summary)
      • Best Practices for Developing on VeChainThor
    • How to verify Address-Ownership
      • Next.js Session Verification
    • Debug Reverted Transactions
    • Account Abstraction
    • VIP-191: Designated Gas Payer
      • How to Integrate VIP-191 (I)
      • How to Integrate VIP-191 (II)
      • How to Integrate VIP-191 (III)
    • Index with Graph Node
      • Setup with Docker
      • Index with OpenZeppelin
        • Create Subgraph Project
        • Configure Contracts
        • Deploy Subgraph and start Indexing
        • Track Subgraph Indexing
        • Access Subgraph
        • Update Subgraph
    • SDKs & Providers
      • SDK
        • Architecture
        • Accounts
        • Bloom Filter
        • Certificates
        • Contracts
        • Cryptography
        • Debug
        • Encoding
        • Polls
        • Subscriptions
        • Thor Client
        • Transactions
      • Thor DevKit
        • Installation
        • Usage
          • Cryptography
          • Accounts
          • Encoding
          • Transactions
          • Certificates
          • Bloom Filter
      • DApp Kit
        • v2
          • Installation
          • React
            • Installation
            • Usage
          • Vanilla JS
            • Installation
            • Usage
          • Core
            • Installation
            • Usage
          • Theme Variables
          • i18n
        • v1
          • Installation
          • React
            • Installation
            • Usage
          • Vanilla JS
            • Installation
            • Usage
          • Core
            • Installation
            • Usage
          • Theme Variables
          • i18n
          • Node Polyfills
          • V0 to V1
        • v0
          • Installation
          • Usage
          • React
            • Installation
            • Usage
          • Vanilla (UI)
            • Installation
            • Usage
          • Styles (UI)
          • i18n
      • DevPal
      • Web3-Providers-Connex
        • Installation
        • Usage
      • Connex
        • Installation
        • API Specification
    • Frameworks & IDEs
      • Hardhat
      • Remix
    • Built-in Contracts
    • VORJ
    • Useful Links
  • How to contribute
Powered by GitBook
On this page
  • Purpose of Certificates
  • Structure of a Certificate
  • Usage of Certificates
  • Self-Signed Certificates

Was this helpful?

  1. Developer Resources
  2. SDKs & Providers
  3. Thor DevKit
  4. Usage

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.

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.

import { Certificate, secp256k1, blake2b256, address } from 'thor-devkit'

// Generate a private key and address for the signer
const privateKey = secp256k1.generatePrivateKey()
const publicKey = secp256k1.derivePublicKey(privateKey)
const signerAddress = address.fromPublicKey(publicKey)

// Create a certificate
const cert = {
    purpose: 'identification',
    payload: {
        type: 'text',
        content: 'fyi'
    },
    domain: 'localhost',
    timestamp: 1545035330,
    signer: signerAddress
}

// Sign certificate
const jsonStr = Certificate.encode(cert)
const signature = secp256k1.sign(blake2b256(jsonStr), privateKey)

// Add 0x to signature
cert.signature = '0x' + signature.toString('hex')

// Verify certificate
Certificate.verify(cert)

// Get certificate id
const id = '0x' + blake2b256(Certificate.encode(cert)).toString('hex')
console.log(id)
// 0x0...
PreviousTransactionsNextBloom Filter

Last updated 11 months ago

Was this helpful?