-
Notifications
You must be signed in to change notification settings - Fork 671
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
feat: require signatures to prove control of signer-key
in pox
#4277
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## next #4277 +/- ##
===========================================
+ Coverage 58.59% 77.07% +18.47%
===========================================
Files 445 446 +1
Lines 317218 318455 +1237
===========================================
+ Hits 185882 245435 +59553
+ Misses 131336 73020 -58316 ☔ View full report in Codecov by Sentry. |
|
After further thought, I think we should follow SIP018 (signed structured data) for this. That also unlocks the ability for signers to use a web app to request signatures from a wallet. |
#4247 is about delegating signer duties, not delegating stx. As far as I understand. Pool operators can already refuse to |
Everyone needs to prove ownership of their signing key. This goes for solo stackers as well, via |
2b4b228
to
89d8a7f
Compare
Instead of delegate stack stx, pool operators now provide the key in stack aggregation-* function calls. See #4274 |
Good to know - and I'll have to change this to build off the change from |
delegate-stx
signer-key
in pox
👍 that's reflected in the current state of the PR |
There are a number of tests outside of the pox-4 tests related to nakamoto that are failing because of the change to |
|
||
/// Generate a message hash for signing structured Clarity data. | ||
/// Reference [SIP018](https://github.com/stacksgov/sips/blob/main/sips/sip-018/sip-018-signed-structured-data.md) for more information. | ||
pub fn structured_data_message_hash(structured_data: Value, domain: Value) -> Sha256Sum { |
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.
Why does this belong in util_lib
? Isn't this only used in testing? If so, then please remove this file altogether and put this into stackslib/src/chainstate/stacks/boot/mod.rs
.
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.
At the moment it's only used in tests, but we'll add it (in a separate PR) to stacks-signer
so we can expose a CLI function like:
stacks-signer create-stacking-signature --stacker S --reward-cycle R
I don't have a strong opinion whether it should live here or not, and I'm not the best person to know. But I think it is helpful to expose somewhere that isn't just for tests.
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.
Sounds like this belongs in libsigner
then. libsigner
can be a dev-dependency for stackslib
.
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.
Generally pox_4.clar updates LGTM minus a few syntax issues & one ERR constant inconsistency.
FYI I'm going to rebase/build this off of #4269, because that changes the function signatures in pox-4. Shouldn't be too much work and then I'll move the ticket back to review. |
I've updated this PR with changes since receiving Jude's feedback. Tagging @jcnelson @setzeus @MarvinJanssen @friedger for reviews.
I've also added some code in |
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.
This LGTM -- I'd just suggest using the define_named_enum!
macro for the topics, and you should add another unit test that asserts equality between the rust message hash constructor and the contract's read-only fn.
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.
Included a formatting/syntax NIT but outside of that LGTM! Great job on this @hstove.
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.
LGTM -- just see if the ...Old
enum can be removed.
Ah crap, thanks for catching that. CI should pass and then I think this is good to merge! |
The message hash function now includes topic
and period
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This closes #4247, which is to ensure that all Signers are using signing keys that they either control, or are controlled by the account they're delegating to.
This is done by adding a
signer-sig
param to:The signature follows SIP018 for signed structured data. Following SIP018 has the benefit of built-in wallet support, so signers can use hardware wallets and apps to generate these signatures.
Following SIP018, the structured data is
{ reward-cycle, reward-cycle }
, wherereward-cycle
is the current stacking cycle where the transaction is made. Thedomain
is{ app: "pox-4-signer", version: "1.0.0", chain-id }
.Because we'll almost certainly be building the ability for
stacks-signer
to generate these signatures (ie via CLI), I added a SIP18 util library at/stacksib/src/lib_util/signed_structured_data
. That library has tests that validate the functionality based on the test vectors in SIP018.I added a function
to_rsv
toMessageSignature
to match the byte order that Clarity uses for signatures.Note that I added the new
signer-sig
param as the second-to-last argument because of other conversations around expected argument order, but I'm not really familiar with the requirements there. I also am not sure what other touch points use these functions where the arguments need to be updated. cc @zone117x regarding param order