Skip to content

fix: use internal tag for signature response type for backwards compatibility#358

Merged
4 commits merged intomainfrom
bookrock/fix-serialization-of-signatures
Apr 10, 2025
Merged

fix: use internal tag for signature response type for backwards compatibility#358
4 commits merged intomainfrom
bookrock/fix-serialization-of-signatures

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Apr 10, 2025

The signature responses for ECDSA are non-backwards compatible after creating the enum type SignatureResponse for multiple signature schemes.
v1:

{
  "big_r": { "affine_point": "02C05BBFD4FB13618F96D4A38523C83773EC27EBD284E370708541D69AC125F21B" },
  "s": { "scalar": "6E4F121548CD389B21735B002DBBA1F0990BCDF3FCAB5A279D37AA6015083061" },
  "recovery_id": 0
}

v2

{
  "Secp256k1": {
    "big_r": { "affine_point": "03D707678DA8B6A9B6E70FD00E98810076FDAEAF1FF4C75BF475679B69FDCD97DC" },
    "s": { "scalar": "28620BFC193491ED21E94578FF7C6A17B431D59E22729E829748E427BDBF9CB8" },
    "recovery_id": 0
  }
}

To fix this we can encode the enum type internally, such that it becomes an additive change for old clients, preserving backwards compatibility:

{
  "scheme": "Secp256k1",
  "big_r": { "affine_point": "02C05BBFD4FB13618F96D4A38523C83773EC27EBD284E370708541D69AC125F21B" },
  "s": { "scalar": "6E4F121548CD389B21735B002DBBA1F0990BCDF3FCAB5A279D37AA6015083061" },
  "recovery_id": 0,
}

@ghost ghost changed the title fix: use internally tagged enum type for backwards compatibility fix: use internal tag for signature response type for backwards compatibility Apr 10, 2025
@ghost ghost marked this pull request as ready for review April 10, 2025 10:38
@ghost ghost merged commit 0e824f7 into main Apr 10, 2025
1 check passed
@ghost ghost deleted the bookrock/fix-serialization-of-signatures branch April 10, 2025 12:26
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants