-
Notifications
You must be signed in to change notification settings - Fork 92
feat: initial draft of secp256r1-verify SIP
#247
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
brice-stacks
wants to merge
1
commit into
stacksgov:main
Choose a base branch
from
brice-stacks:sip-secp256r1-verify
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| # Preamble | ||
|
|
||
| SIP Number: | ||
|
|
||
| Title: Clarification of Clarity's `secp256r1-verify` Behavior | ||
|
|
||
| Author(s): | ||
|
|
||
| - Brice Dobry <brice@stackslabs.com> | ||
|
|
||
| Status: Draft | ||
|
|
||
| Consideration: Technical | ||
|
|
||
| Type: Informational | ||
|
|
||
| Layer: Consensus | ||
|
|
||
| Created: 2025-12-15 | ||
|
|
||
| License: BSD-2-Clause | ||
|
|
||
| Sign-off: | ||
|
|
||
| Discussions-To: | ||
|
|
||
| - https://github.com/stacksgov/sips/pull/247 | ||
|
|
||
| # Abstract | ||
|
|
||
| A discrepancy has been identified between the behavior described in SIP-033 for | ||
| the `secp256r1-verify` function added in Clarity 4 and the actual behavior | ||
| implemented and activated in Epoch 3.3. | ||
|
|
||
| # Copyright | ||
|
|
||
| This SIP is made available under the terms of the BSD-2-Clause license, | ||
| available at https://opensource.org/licenses/BSD-2-Clause. This SIP’s copyright | ||
| is held by the Stacks Open Internet Foundation. | ||
|
|
||
| # Introduction | ||
|
|
||
| In SIP-033, `secp256r1-verify` was described as: | ||
|
|
||
| > The `secp256r1-verify` function verifies that the provided `signature` of the | ||
| > `message-hash` was produced by the private key corresponding to `public-key`. | ||
| > The `message-hash` is the SHA-256 hash of the message. The `signature` must be | ||
| > 64 bytes (compact signature). Returns `true` if the signature is valid for the | ||
| > given `public-key` and message hash, otherwise returns `false`. | ||
|
|
||
| The implementation that activated with Clarity 4 in epoch 3.3 however introduces | ||
| a double-hash -- the `message-hash` that is passed in is again SHA256 hashed, | ||
| and the resulting hash is used to verify the signature. Changing the behavior is | ||
| a consensus-change, requiring a hard fork, so the intention of this SIP is | ||
| simply informational, to clarify and document this discrepancy in behavior, and | ||
| to prepare the ecosystem for a future SIP that will define a new version of | ||
| Clarity (activated in a new epoch) which will implement the originally intended | ||
| behavior. | ||
|
|
||
| # Specification | ||
|
|
||
| The `secp256r1-verify` documentation will be updated from the existing: | ||
|
|
||
| > The `secp256r1-verify` function verifies that the provided signature of the | ||
| > message-hash was signed with the private key that generated the public key. | ||
| > `message-hash` is typically the `sha256` of a message and `signature` is the | ||
| > raw 64-byte signature. High-S signatures are allowed. Note that this is NOT | ||
| > the Bitcoin (or default Stacks) signature scheme, secp256k1, but rather the | ||
| > NIST P-256 curve (also known as secp256r1). | ||
|
|
||
| to: | ||
|
|
||
| > The `secp256r1-verify` function verifies that the provided signature of the | ||
| > message-hash was signed with the private key that generated the public key. | ||
| > **In Clarity 4, the `message-hash` is SHA256 hashed again internally before | ||
| > verification (i.e. double SHA256)**. `message-hash` is typically the `sha256` | ||
| > of a message and `signature` is the raw 64-byte signature. High-S signatures | ||
| > are allowed. Note that this is NOT the Bitcoin (or default Stacks) signature | ||
| > scheme, secp256k1, but rather the NIST P-256 curve (also known as secp256r1). | ||
|
|
||
| Developers wishing to verify signatures using this function in Clarity 4 must | ||
| ensure that the signature was generated over the double-hash of the original | ||
| message, specifically (pseudo-code): | ||
|
|
||
| ``` | ||
| Signature = ECDSA_Sign(SHA256(SHA256(original_message)), private-key) | ||
| ``` | ||
|
|
||
| # Related Work | ||
|
|
||
| [SIP-033](../sip-033/sip-033-clarity4.md) describes the originally intended | ||
| behavior of `secp256r1-verify`. | ||
|
|
||
| # Backwards Compatibility | ||
|
|
||
| No technical changes will be made based on this SIP, other than documentation | ||
| changes. | ||
|
|
||
| # Activation | ||
|
|
||
| This SIP should be activated upon receiving sign off from the Technical CAB, | ||
| ensuring that the details described herein are correct. | ||
|
|
||
| # Reference Implementation | ||
wileyj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| N/A | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rafaelcr @314159265359879 @jiga i didn't see any other SIP using this number, so i'm pre-emptively proposing it here.