From 6ebbe21dce65e19c93e4bf87317c265c9e13d565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Est=C3=A1cio=20=7C=20stacio=2Eeth?= Date: Mon, 29 Jul 2024 18:24:29 -0300 Subject: [PATCH] change ed19 verify operator, to comply with ed spec (#600) When using EdDSA (Ed25519) to verify a signature, the payload is not limited by 32 bytes. ### After merging, notify other teams - [ ] [Rust SDK](https://github.com/FuelLabs/fuels-rs/) - [ ] [Sway compiler](https://github.com/FuelLabs/sway/) - [ ] [Platform documentation](https://github.com/FuelLabs/devrel-requests/issues/new?assignees=&labels=new+request&projects=&template=NEW-REQUEST.yml&title=%5BRequest%5D%3A+) (for out-of-organization contributors, the person merging the PR will do this) - [ ] [Connectors](https://github.com/FuelLabs/fuel-connectors/) --------- Co-authored-by: Hannes Karppila <2204863+Dentosal@users.noreply.github.com> Co-authored-by: Hannes Karppila --- src/fuel-vm/instruction-set.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/fuel-vm/instruction-set.md b/src/fuel-vm/instruction-set.md index d4f5b31e..1f4c4ab1 100644 --- a/src/fuel-vm/instruction-set.md +++ b/src/fuel-vm/instruction-set.md @@ -2229,7 +2229,7 @@ All these instructions advance the program counter `$pc` by `4` after performing | Operation | ```MEM[$rA, 64] = ecrecover_k1(MEM[$rB, 64], MEM[$rC, 32]);``` | | Syntax | `eck1 $rA, $rB, $rC` | | Encoding | `0x00 rA rB rC -` | -| Notes | | +| Notes | Takes message hash as an input. You can use `S256` to hash the message if needed. | Panic if: @@ -2252,7 +2252,7 @@ To get the address from the public key, hash the public key with [SHA-2-256](../ | Operation | ```MEM[$rA, 64] = ecrecover_r1(MEM[$rB, 64], MEM[$rC, 32]);``` | | Syntax | `ecr1 $rA, $rB, $rC` | | Encoding | `0x00 rA rB rC -` | -| Notes | | +| Notes | Takes message hash as an input. You can use `S256` to hash the message if needed. | Panic if: @@ -2269,19 +2269,19 @@ To get the address from the public key, hash the public key with [SHA-2-256](../ ### `ED19`: EdDSA curve25519 verification -| | | -|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------| -| Description | Verification recovered from 32-byte public key starting at `$rA` and 64-byte signature starting at `$rB` on 32-byte message hash starting at `$rC`. | -| Operation | ```ed19verify(MEM[$rA, 32], MEM[$rB, 64], MEM[$rC, 32]);``` | -| Syntax | `ed19 $rA, $rB, $rC` | -| Encoding | `0x00 rA rB rC -` | -| Notes | | +| | | +|-------------|-----------------------------------------------------------------------------------------------------------------------------| +| Description | Verification 64-byte signature at `$rB` with 32-byte public key at `$rA` for a message starting at `$rC` with length `$rD`. | +| Operation | ```ed19verify(MEM[$rA, 32], MEM[$rB, 64], MEM[$rC, $rD]);``` | +| Syntax | `ed19 $rA, $rB, $rC, $rD` | +| Encoding | `0x00 rA rB rC rD` | +| Notes | Takes message instead of hash. **For backwards compatibility reasons, if `$rD == 0`, it will be treated as `32`.** | Panic if: - `$rA + 32` overflows or `> VM_MAX_RAM` - `$rB + 64` overflows or `> VM_MAX_RAM` -- `$rC + 32` overflows or `> VM_MAX_RAM` +- `$rC + $rD` overflows or `> VM_MAX_RAM` Verification are specified [here](../protocol/cryptographic-primitives.md#eddsa-public-key-cryptography).