zPass docs
  • zPass
    • Introduction
    • Quickstart
    • Background
    • Benefits & Use Cases
    • Technical Foundations
    • System Participants
    • Powered by Aleo
  • Fundamentals
    • Issuer
    • Holder
    • Verifier
    • Off-chain flow
    • On-chain flow
    • Local Execution with WASM
  • ZPass Programs
    • Background
    • Verify offchain program
    • zPass issuance program
    • zPass hiding program
    • zPass invalidate program
    • zPass invalidate hiding program
    • zPass merkle tree size 8 program
  • ZPass SDK
    • Methods References
      • constructor
      • setNewHost
      • issueZPass
      • getZPassRecord
      • proveOnChain
      • proveOffChain
      • verifyOnChain
      • verifyOffChain
      • signCredential
      • initThreadPool
      • createAleoWorker
      • getMerkleRoot
      • getMerkleTree
      • getMerkleProof
      • getLeavesHashes
      • signMerkleRoot
  • Example Usage
    • Step-by-step Guide
Powered by GitBook
On this page
  • Description
  • Parameters
  • Returns
  • Example
  1. ZPass SDK
  2. Methods References

signCredential

Description

The signCredential method allows you to hash credential data and sign it with a private key. This is useful for the issuer to create digital signatures that can verify the authenticity and integrity of data.

Parameters

  • options (SignCredentialOptions): An object containing:

    • data (object): The data to be signed, can be any properties and values type that are supported by Leo program

    • hashType (HashAlgorithm): The hashing algorithm to use, type can be imported from zpass-sdk

    • privateKey (string, optional): Optional private key to use for signing. If not provided, uses the SDK instance's private key

Returns

Returns a Promise that resolves to an object containing:

  • signature (string): The generated signature

  • hash (string): The hash of the data

Example

const { signature, hash } = await zpass.signCredential({
    data: {
      issuer: issuer,
      subject: subject,
      dob: dob,
      nationality: nationality,
      expiry: expiry,
      salt: salt,
    },
    hashType: HashAlgorithm.POSEIDON2,
  });
PreviousverifyOffChainNextinitThreadPool

Last updated 4 months ago