Skip to content

Update NanoTDF spec to handle ECSDA signature with different r and s value sizes #17

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
606 changes: 605 additions & 1 deletion diagrams/nanotdf.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 25 additions & 10 deletions schema/nanotdf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private key and the resulting signature. The structure of this section:
| Section | Minimum Length (B) | Maximum Length (B) |
|---------------|---------------------|---------------------|
| Public Key | 33 | 67 |
| Signature | 64 | 132 |
| Signature | 66 | 134 |

##### 3.3.3.1 Public Key

Expand All @@ -287,7 +287,7 @@ the message.

##### 3.3.3.2 Signature

This section contains the encoded `r` and `s` values of the ECDSA signature.
This section contains the size of `r` and `s` and encoded `r` and `s` values of the ECDSA signature.
They are encoded as described in [Section 5.2].

### 3.4 nanotdf Types
Expand Down Expand Up @@ -483,18 +483,33 @@ the X9.62 ECC Public Key Compressed Encoding format.

[Section 5.2]: #52-ecdsa-signature-encoding

ECDSA signatures are big endian encodings of the `r` and `s` values of an ECDSA
signature. The length of `r` and `s` values is determined by the ECC Mode used
for the signature. The encoding for the signature is the big endian encodings of
R and S concatenated to each other. For example, `r = 1` and `s = 2` for an
The structure of this section is as follows:

| Section | Minimum Length (B) | Maximum Length (B) |
|------------------------|--------------------|---------------------|
| Size of 'r' value | 1 | 1 |
| ECDSA 'r' value | 33 | 67 |
| Size of 's' value | 1 | 1 |
| ECDSA 's' value | 33 | 67 |


ECDSA signature 'r' and 's' values are big endian encoding.
The length of `r` and `s` values is determined by the ECC Mode used for the signature.

NOTE: 'r' and 's' value need not be of same length for example for curve secp256k1,
the size of 'r' value can be 31 bytes and 's' value can be of 32 bytes. In this
case the 'r' value is padded with '0x0'

For example, `r = 1` and `s = 2` for an
ECDSA signature of a secp256k1 key would be (line breaks and spaces are added
for easier visualization):

```
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 02
```

## 6. Examples
Expand Down