Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BLS12-381 verification #531

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/fuel-vm/instruction-set.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
- [`ECK1`: Secp251k1 signature recovery](#eck1-secp256k1-signature-recovery)
- [`ECR1`: Secp256r1 signature recovery](#ecr1-secp256r1-signature-recovery)
- [`ED19`: EdDSA curve25519 verification](#ed19-eddsa-curve25519-verification)
- [`BLS`: Barreto-Lynn-Scott 12-381 signature verification](#blsa-bls12-381-verification)
- [`K256`: keccak-256](#k256-keccak-256)
- [`S256`: SHA-2-256](#s256-sha-2-256)
- [Other Instructions](#other-instructions)
Expand Down Expand Up @@ -2333,6 +2334,32 @@ Verification are specified [here](../protocol/cryptographic-primitives.md#eddsa-

If there is an error in verification, `$err` is set to `1`, otherwise `$err` is cleared.

### BLS BLS12-381 verification

| | |
|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| Description | Verification recovered from 48-byte public key(s) starting at `$rA` and 64-byte signature starting at `$rC` on 32-byte message hashes starting at `$rB` by 8-byte number of messages at `MEM[$rC + 64, 8]`. |
| Operation | ```bls_12381_verify(MEM[$rA, 48 * NUM_MESSAGES], MEM[$rB, 32 * NUM_MESSAGES], MEM[$rC, 64], $rD);``` |
| Syntax | `ed19 $rA, $rB, $rC, #rD` |
| Encoding | `0x00 rA rB rC rD` |
| Notes | If `$rD` is set to a value of `0`, verification will happen over an unaggregated signature, `1` specifies verifying over an aggregate signature set by the transaction user in memory, a single message at `$rB` are included in a valid aggregated BLS12-381 signature verification within the current block or that a single valid signature be present at `$rC`. |

Panic if:

- `$rA + 48 * NUM_MESSAGES` overflows
- `$rB + 32 * NUM_MESSAGES` overflows
- `$rC + 64 * NUM_MESSAGES` overflows
- `$rA + 48 * NUM_MESSAGES > VM_MAX_RAM`
- `$rB + 32 * NUM_MESSAGES > VM_MAX_RAM`
- `$rC + 64 * NUM_MESSAGES > VM_MAX_RAM`
- `$rD == 0 && NUM_MESSAGES > 1`

Verification are specified [here](../protocol/cryptographic-primitives.md#eddsa-public-key-cryptography).

If there is an error in verification, `$err` is set to `1`, otherwise `$err` is cleared.

BLS specifies BLS version A which in this case is the standardized BLS12-381 curve.

### `K256`: keccak-256

| | |
Expand Down
Loading