---
updatedAt: 2025-07-26T15:36:24.000Z
agentTools:
  projectIndex: https://docs.metakeep.xyz/llms.txt
---

# User Signatures

You can use MetaKeep to generate signatures for messages using the private key of the asymmetric key pair. The signature can be verified using the public key.

## Calling sign

You can ask the user to sign a `bigint` by using the`signMessage` function in MetaKeep SDK. The `bigint` is converted to a `big-endian` byte array and then converted to a `hex string`. The hex string is then sent to the `signMessage` function along with the `reason`. The function expects a non-empty `reason` which is shown to the user at the time of message signing.

The operation result is returned in the [callback object](https://docs.metakeep.xyz/reference/mobile-sdk-101#sdk-operation-callback) passed to the `signMessage` function  or the `Promise` object returned by the `signMessage` function.

```javascript JS SDK
await sdk.signMessage(
    // bigint as big-endian byte hex string
    "0x0000260e66bea5cc8114947584de9f68574710c9e472378d4595febfd51eb853",
    // signing reason
    "reason",
);
```
```kotlin Android SDK - Kotlin
sdk.signMessage(
    // bigint as big-endian byte hex string
    "0x0000260e66bea5cc8114947584de9f68574710c9e472378d4595febfd51eb853",
    // signing reason
    "reason",
    // Callback
    Callback(
        onSuccess = { response: JsonResponse ->
            Log.d("onSuccess", response.toString())
        },
        onFailure = { error: JsonResponse ->
            Log.d("onFailure", error.toString())
        },
    ),
)
```
```swift iOS SDK - Swift
sdk.signMessage(
  // bigint as big-endian byte hex string
  message: "0x0000260e66bea5cc8114947584de9f68574710c9e472378d4595febfd51eb853",
  // signing reason
  reason: "reason",
  // Callback
  callback: Callback(
    onSuccess: { (result: JsonResponse) in
      print("onSuccess")
      print(result.description)
    },
    onFailure: { (error: JsonResponse) in
      print("onFailure")
      print(error.description)
    }
  )
)
```
```javascript React Native SDK
await sdk.signMessage(
    // bigint as big-endian byte hex string
    "0x0000260e66bea5cc8114947584de9f68574710c9e472378d4595febfd51eb853",
    // signing reason
    "reason",
);
```
```javascript Flutter SDK
await sdk.signMessage(
    // bigint as big-endian byte hex string
    "0x0000260e66bea5cc8114947584de9f68574710c9e472378d4595febfd51eb853",
    // signing reason
    "reason",
);
```

## Response

On success, the callback `onSuccess` or the `Promise resolve` function is called with the signature inside a `JSON` object. The signature is a  64-byte `compressed EdDSA signature` in hex format as defined in [RFC 8032](https://tools.ietf.org/html/rfc8032).

This is what the response looks like:

```json Successful response from SDK
{
    "status": "SUCCESS",
    // 64-byte compressed EdDSA signature in hex format
    "signature": "0x20ba78dcc23893aefaa3c8c2c9d99598831265e3ce32638d3cfda6c4d2028c8ade8b897c9d4542259204224ff59b72f7fea835727df8cee40cafd3a6d101ff02"
}
```

Here's a reference implementation of this code for JS SDK: <https://jsfiddle.net/passbird/14er9xoy/>

## Error status

Callback `onFailure` or the `Promise reject` function is called when the user cancels the operation or if there's an error. The error object contains a status field, a string indicating the status of the operation. Here's what the error object looks like:

```json Error object
{
  status: "USER_CONSENT_DENIED"
}
```

Here's a table of all possible error status returned by the SDK:

<Table align={["left","left"]}>
  <thead>
    <tr>
      <th>
        Status
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        USER\_REQUEST\_DENIED
      </td>

      <td>
        The user has denied the sign operation.
        In this case, you should ask the user if they want to try again.
      </td>
    </tr>

    <tr>
      <td>
        INVALID\_REQUEST
      </td>

      <td>
        Invalid data passed to sign operation.
        Please get in touch with us if you are unable to fix this.
      </td>
    </tr>

    <tr>
      <td>
        INVALID\_MESSAGE
      </td>

      <td>
        The message to sign is not valid. Make sure that it's a valid hex string.
      </td>
    </tr>

    <tr>
      <td>
        APP\_ID\_REQUIRED
      </td>

      <td>
        No `app-id` was provided when initializing the SDK.
        You can find the app ID in the MetaKeep Developer Console.
      </td>
    </tr>

    <tr>
      <td>
        APP\_NOT\_FOUND
      </td>

      <td>
        The provided `app-id` is invalid.
        You can find the correct `app-id` in the MetaKeep Developer Console.
      </td>
    </tr>

    <tr>
      <td>
        SOMETHING\_WENT\_WRONG
      </td>

      <td>
        An unknown error happened.
        Please get in touch with us if you continue seeing this error.
      </td>
    </tr>
  </tbody>
</Table>

<br />

***

© 2025 Passbird Research, Inc. All rights reserved. This documentation and underlying technology are protected by patents, trademarks, and intellectual property rights under U.S. and international law.

***

&#x20;