> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bbrands.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Signature engine (MaihueSigner)

> MaihueSigner is the in-house electronic signature engine of the platform: one-time-code signing, per-signer evidence, a tamper-evident audit chain and PAdES-sealed PDFs, with no external signature vendor.

> [!NOTE]
>
> This section documents **MaihueSigner**, the platform's own electronic
> signature engine. In code it is the `internal-signer` provider inside
> `horizon-api`. It is a platform capability, not part of one product flow:
> any product that needs documents signed uses the same engine.

## What it is

MaihueSigner lets people sign PDF documents with a **simple electronic
signature** under Chilean Law 19.799, without an external signature vendor.
A signer proves who they are with a one-time code sent to their email, and
one gesture signs every document of the group. The engine records evidence
for each signer, chains every event in a tamper-evident audit log and, once
everyone has signed, seals the PDFs with PAdES signatures.

The same engine handles the other party too. A **workflow** decides who signs
on the company's side, in which order, and whether those seats sign in person
or unattended with a representative's certificate.

> [card] What it does
>
> Opens a signature group for N documents and M signers, sends one-time
> codes, registers each signer's gesture with its evidence, applies the
> company's countersignature, and seals the signed PDFs. It can also verify
> a group's audit chain.

> [card] What it does NOT do
>
> It does not decide **when** a document must be signed or what happens to
> the business record afterwards. That belongs to the product that uses it.

## How a signature group flows

```mermaid theme={null}
flowchart LR
    create["Consumer opens<br/>a signature group"] --> otp["Signer requests<br/>a one-time code"]
    otp --> sign["Signer signs every<br/>document at once"]
    sign --> more{"Other signers<br/>pending?"}
    more -->|yes| otp
    more -->|no| company["Company side signs<br/>(attended or unattended)"]
    company --> seal["PDFs sealed:<br/>evidence sheet + PAdES"]
    seal --> done["Consumer stores the<br/>signed documents"]
```

The order between the two sides is set by the workflow: the company side can
sign after the customers (the default) or before them.

## Key terms

| Term | Meaning |
| - | - |
| Signature group | One `signature` row that groups the documents and the signers of one send |
| Seat | One signer in the group (`signature_signer`), on the customer side or the company side |
| Gesture | The seat owner's act: signing with a valid one-time code, or rejecting (which takes no code) |
| Workflow | The rules for the company side: which representatives, how many, attended or unattended, and the phase order |
| Evidence | What the engine records for each gesture: who, when, from where, and the hash of what was signed |
| Audit chain | The append-only, hash-linked log of every engine event for a group |
| Seal | The PAdES signatures applied to each PDF once every seat has signed |

## Who uses it

| Consumer | How |
| - | - |
| [Digital contracting](https://docs.bbrands.io/digital-contracting/introduction.md) | Signs the contract and its annex: customers in the portal, Maihue's representatives unattended |

Any new product reuses the engine and its workflow model instead of adding
its own signing.

## Where to go next

> [card] [Architecture](https://docs.bbrands.io/signature-engine/architecture.md)
>
> Components, files, tables and the boundary with the products that use it.

> [card] [History](https://docs.bbrands.io/signature-engine/history.md)
>
> How the engine was built and how it changed afterwards.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.