---
title: "aiken/crypto/bls12_381/pairing"
---

> Documentation Index
> Fetch the complete documentation index at: https://aiken-lang.com/llms.txt
> Use this file to discover all available pages before exploring further.

# aiken/crypto/bls12_381/pairing

## Functions

### `miller_loop` {#miller_loop}

```aiken
miller_loop(q: G1Element, p: G2Element) -> MillerLoopResult
```

Computes a MillerLoop over the elements `q` and `p`

### `mul` {#mul}

```aiken
mul(left: MillerLoopResult, right: MillerLoopResult) -> MillerLoopResult
```

Multiplies two `MillerLoopResult` together.

This aggregates several pairings into a single `MillerLoopResult` before a
final verification, relying on the bilinearity of the pairing `e`:

```aiken
// e(q1, p1) * e(q2, p2)
mul(miller_loop(q1, p1), miller_loop(q2, p2))
```

### `final_exponentiation` {#final_exponentiation}

```aiken
final_exponentiation(left: MillerLoopResult, right: MillerLoopResult) -> Bool
```

Final exponentiation against two `MillerLoopResult`.

```aiken
prove: e(q^x, p^m) == e(q, p^m*x)
let secret: State<Scalar> = scalar.from_int(44203)

let public_value: G1Element = g1.generator |> g1.scale(secret)

let message: ByteArray = #"acab"

let challenge: G2Element =
  message |> g2.hash_to_group(domain_separation_tag_nul)

let witness: G2Element =
  message
    |> g2.hash_to_group(domain_separation_tag_nul)
    |> g2.scale(secret)

final_exponentiation(
  miller_loop(public_value, challenge),
  miller_loop(g1.generator, witness),
)
```

Source: https://aiken-lang.com/stdlib/aiken/crypto/bls12_381/pairing/index.mdx
