# 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

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://zpass.docs.aleo.org/zpass-sdk/overview/signcredential.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
