Skip to content

Commit 4dd47d2

Browse files
authored
Signatures.md: update and document the signature identifier (#221)
In order to avoid probing signatures that don't match a public key, signatures are prefixed with an algorithm identifier. That identifier was present in examples, but not in the specification. So, mention it in the specification. In addition, current implementations don't consider that the identifier is part of the signature, so match these implementations. It doesn't make any difference beyond the encoded signature length.
1 parent 30f4997 commit 4dd47d2

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

Signatures.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ where a `signature` is encoded as:
109109
| ------------- | ----------- | ---------------------------------------------------------- |
110110
| key_id_len | `varuint32` | Public key identifier length in bytes (can be `0`) |
111111
| key_id | `bytes` | Public key identifier |
112+
| signature_id | `byte` | Signature algorithm identifier |
112113
| signature_len | `varuint32` | Signature length in bytes |
113114
| signature | `bytes` | Signature for `hashes` that can be verified using `key_id` |
114115

@@ -181,6 +182,8 @@ Public and private keys must include the algorithm and parameters they were crea
181182
| Ed25519 public key | 1 + 32 bytes | `0x01` |
182183
| Ed25519 key pair | 1 + 64 bytes | `0x81` |
183184

185+
Ed25519 algorithm identifier: `0x01`.
186+
184187
Representation of Ed25519 keys:
185188

186189
- Ed25519 public key:
@@ -258,8 +261,9 @@ Content of the signature section, for a single signature:
258261
- `1` (`signatures_count`)
259262
- signature:
260263
- `0` (`key_id_len` - no key ID)
261-
- `65` (`signature_len`)
262-
- `<65 bytes>` (0x01 ‖ Ed22519(k, hashes))
264+
- `0x01` (Ed25519 algorithm identifier)
265+
- `64` (`signature_len`)
266+
- `<64 bytes>` (Ed22519(k, hashes))
263267

264268
### Signatures allowing partial verification.
265269

@@ -306,8 +310,9 @@ Content of the signature section, for a single signature:
306310
- `1` (signatures_count)
307311
- signature:
308312
- `0` (key_id_len - no key ID)
309-
- `65` (signature_len)
310-
- `<65 bytes>` (0x01 ‖ Ed22519(k, hashes))
313+
- `0x01` (Ed25519 algorithm identifier)
314+
- `64` (signature_len)
315+
- `<64 bytes>` (Ed22519(k, hashes))
311316

312317
Variant with two signatures for the same content and key identifiers:
313318

@@ -321,10 +326,12 @@ Variant with two signatures for the same content and key identifiers:
321326
- signature_1:
322327
- `5` (key_id_len)
323328
- `"first"` (key_id)
324-
- `65` (`signature_len`)
325-
- `<65 bytes>` (0x01 ‖ Ed22519(k_first, hashes))
329+
- `0x01` (Ed25519 algorithm identifier)
330+
- `64` (`signature_len`)
331+
- `<64 bytes>` (Ed22519(k_first, hashes))
326332
- signature_2:
327333
- `6` (key_id_len)
328334
- `"second"` (key_id)
329-
- `65` (`signature_len`)
330-
- `<65 bytes>` (0x01 ‖ Ed22519(k_second, hashes))
335+
- `0x01` (Ed25519 identifier)
336+
- `64` (`signature_len`)
337+
- `<64 bytes>` (Ed22519(k_second, hashes))

0 commit comments

Comments
 (0)