> For the complete documentation index, see [llms.txt](https://aliniex.gitbook.io/alix-pay/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aliniex.gitbook.io/alix-pay/api-reference/introduction/digital-signature.md).

# Digital Signature

## Digital signature <a href="#digital-signature" id="digital-signature"></a>

Currently, AliX is using the RSA 2048 bit algorithm. In addition to data digital signing, it is also used for encryption and decryption.

Partners can create signatures with online tool:&#x20;

<https://8gwifi.org/RSAFunctionality?rsasignverifyfunctions=rsasignverifyfunctions&keysize=2048>

or refer to how to generate keys using the command line: <https://www.scottbrady91.com/OpenSSL/Creating-RSA-Keys-using-OpenSSL>

Standard signature: RSA - PKCS1 or RSA - PKCS8.

The signature pair consists of a private key and a public key:

* Private key for partners to create signatures
* Public key which partner provides for AliX to verify the partner's signature.

  At the same time, AliX provides partners with AliX's public key for partners to verify AliX's signature.

AliX algorithms support partners: SHA1, SHA256, SHA384, SHA224, SHA512 Partner informs AliX the algorithm that is using.

Partners can use online tools to put strings before encryption and check signature output, such as <https://8gwifi.org/RSAFunctionality?rsasignverifyfunctions=rsasignverifyfunctions&keysize=2048>

### Code examples <a href="#how-to-do-signature-creation-verification" id="how-to-do-signature-creation-verification"></a>

#### 1. Creation

```typescript
import * as crypto from 'crypto';

function create(data: string, privateKey: string): string 
{
  const signer = crypto.createSign('RSA-SHA256');
  signer.update(data);
  signer.end();

  return signer.sign(privateKey, 'base64');
}
```

#### 2. Verification

```typescript

function verify (data: string, signature: string, pubKey: string): boolean
{
        const verify = createVerify('RSA-SHA256');
        verify.update(data);
        verify.end();
        return verify.verify(pubKey, signature, 'base64');
}
```
