Skip to content

Commit

Permalink
change ed19 verify operator, to comply with ed spec (#600)
Browse files Browse the repository at this point in the history
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 <hannes.karppila@gmail.com>
  • Loading branch information
3 people authored Jul 29, 2024
1 parent afb3c8e commit 6ebbe21
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/fuel-vm/instruction-set.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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:

Expand All @@ -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).

Expand Down

0 comments on commit 6ebbe21

Please sign in to comment.