Skip to content
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

multi: Add decred staking. #1249

Merged
merged 4 commits into from Mar 17, 2021
Merged

multi: Add decred staking. #1249

merged 4 commits into from Mar 17, 2021

Conversation

JoeGruffins
Copy link
Contributor

@JoeGruffins JoeGruffins commented Sep 4, 2020

Add two new input and four output script types.

Decred ticket purchases consist of a stake submission, op returns, and
change addresses. Although change addresses are allowed by consensus,
they are no longer used in practice and so have been given the
restrictions of a null pubkey and no value. Stake scripts are almost
identical to p2pkh or p2sh except for an extra opcode in front. Inputs
are currently only used in the form of one input three outputs with the
first output, or stake submission, paying to a public key hash, or with
two inputs and five outputs with the stake submission paying to a
multisig script hash. The op returns are directed to the user in the
case of one and the voting service provider and user in the case of two.

One of the sstx commitment for a ticket must pay back to the trezor
wallet. This is checked and an error is thrown if we don't find the
expected public key hash.

Because this adds the ability to create new types of outputs once the
ticket votes, two new input script types are also needed. A successful
vote will lead to a stake generation script that must be spent, and an
unsuccessful vote will lead to a revocation script that must be spent.
If we allowed stake change scripts to have a valid pubkey, that too
would require another op code, but we disallow those for output.

@tsusanka tsusanka added the feature Product related issue visible for end user label Sep 4, 2020
@JoeGruffins
Copy link
Contributor Author

JoeGruffins commented Nov 14, 2020

I think this is where we want functionality as far as core is concerned. Of course we would also like this on legacy... Will try to keep it up-to-date with master.

@JoeGruffins
Copy link
Contributor Author

I've had a request for custom labels. I apologise but one more change incoming.

@matejcik
Copy link
Contributor

@JoeGruffins after an internal discussion, we decided that we will not accept the "validate staking keys on Trezor" functionality at this time.

Feel free to use the CipherKeyValue feature, as proposed by @andrewkozlik above, to generate your exportable private keys. This should fulfil your requirements: the keys are fully recoverable with only the Trezor device, and the user needs to confirm the export.

However, from the firmware point of view this is a hack: you're relying on a meaningful string for use as a key, which of course means that it can't ever be changed or translated, this would need to be hardcoded both in firmware and any wallets, the mechanism can be adapted but not cleanly reused for other similar usecases. It's a finicky solution at best.

So at this time we won't be implementing or accepting the Trezor countepart, so it won't be possible to verify that the staking keys come from the same Trezor.

Tagging for product decision, whether to:
(a) not support this for the foreseeable future at all
(b) implement the CipherKeyValue process inside Trezor, knowing the drawbacks
(c) design and implement a purpose-built mechanism for this purpose, i.e., exporting private key material that can also be used by Trezor itself, with UI/UX considerations, etc.

@JoeGruffins
Copy link
Contributor Author

@matejcik Understood and accepted.

In that case lets get this wrapped up! Will take one more good look at the tests, and I think that's it from my side, except for rebasing of course. Also, the initial commit's comment no longer reflects reality.

@JoeGruffins
Copy link
Contributor Author

Just going to put this here for recording purposes. I'm sure none of the devs have anything to do with this.
https://twitter.com/Trezor/status/1359929807908311045

@matejcik
Copy link
Contributor

matejcik commented Mar 16, 2021

it seems some (maybe all?) of my comments are resolved in 20aa862, but that is not a part of this PR. can you fix this @andrewkozlik ?

is there more to resolve at this point?

@matejcik
Copy link
Contributor

but that is not a part of this PR

huh, except it is and github is being weird.

@andrewkozlik
Copy link
Contributor

but that is not a part of this PR

huh, except it is and github is being weird.

Strange, I also had some problems with seeing that commit, so I squashed everything up to an including 20aa862 and rebased the branch over master. The rebase involved reworking the layouts code, so @matejcik you might want to look at that if you like, but it's probably not necessary.

@matejcik
Copy link
Contributor

one last thing: a changelog entry is missing

JoeGruffins and others added 4 commits March 17, 2021 12:13
Add two new input and four output script types.

Decred ticket purchases consist of a stake submission, op returns, and
change addresses. Although change addresses are allowed by consensus,
they are no longer used in practice and so have been given the
restrictions of a null pubkey and no value. Stake scripts are almost
identical to p2pkh or p2sh except for an extra opcode in front. Inputs
are currently only used in the form of one input three outputs with the
first output, or stake submission, paying to a public key hash, or with
two inputs and five outputs with the stake submission paying to a
multisig script hash. The op returns are directed to the user in the
case of one and the voting service provider and user in the case of two.

One of the sstx commitment for a ticket must pay back to the trezor
wallet. This is checked and an error is thrown if we don't find the
expected public key hash.

Because this adds the ability to create new types of outputs once the
ticket votes, two new input script types are also needed. A successful
vote will lead to a stake generation script that must be spent, and an
unsuccessful vote will lead to a revocation script that must be spent.
If we allowed stake change scripts to have a valid pubkey, that too
would require another op code, but we disallow those for output.
@matejcik
Copy link
Contributor

matejcik commented Jun 2, 2021

no QA needed - this is a 3rd party feature and we don't have any appropriate scenarios for it

JoeGruffins added a commit to JoeGruffins/decrediton that referenced this pull request Jun 17, 2021
Add a function that can query trezor for deterministic bytes to be used
as the seed for a voting xpriv.

The method for retrieving deterministic private data was suggested by
Trezor developers:
trezor/trezor-firmware#1249 (comment)
JoeGruffins added a commit to JoeGruffins/decrediton that referenced this pull request Jul 13, 2021
Add a function that can query trezor for deterministic bytes to be used
as the seed for a voting xpriv.

The method for retrieving deterministic private data was suggested by
Trezor developers:
trezor/trezor-firmware#1249 (comment)
JoeGruffins added a commit to JoeGruffins/decrediton that referenced this pull request Aug 10, 2021
Add a function that can query trezor for deterministic bytes to be used
as the seed for a voting xpriv.

The method for retrieving deterministic private data was suggested by
Trezor developers:
trezor/trezor-firmware#1249 (comment)
JoeGruffins added a commit to JoeGruffins/decrediton that referenced this pull request Sep 21, 2021
Add a function that can query trezor for deterministic bytes to be used
as the seed for a voting xpriv.

The method for retrieving deterministic private data was suggested by
Trezor developers:
trezor/trezor-firmware#1249 (comment)
JoeGruffins added a commit to JoeGruffins/decrediton that referenced this pull request Dec 30, 2021
Add a function that can query trezor for deterministic bytes to be used
as the seed for a voting xpriv.

The method for retrieving deterministic private data was suggested by
Trezor developers:
trezor/trezor-firmware#1249 (comment)
JoeGruffins added a commit to JoeGruffins/decrediton that referenced this pull request Feb 3, 2022
Add a function that can query trezor for deterministic bytes to be used
as the seed for a voting xpriv.

The method for retrieving deterministic private data was suggested by
Trezor developers:
trezor/trezor-firmware#1249 (comment)
JoeGruffins added a commit to JoeGruffins/decrediton that referenced this pull request Mar 21, 2022
Add a function that can query trezor for deterministic bytes to be used
as the seed for a voting xpriv.

The method for retrieving deterministic private data was suggested by
Trezor developers:
trezor/trezor-firmware#1249 (comment)
JoeGruffins added a commit to JoeGruffins/decrediton that referenced this pull request Jun 24, 2022
Add a function that can query trezor for deterministic bytes to be used
as the seed for a voting xpriv.

The method for retrieving deterministic private data was suggested by
Trezor developers:
trezor/trezor-firmware#1249 (comment)
JoeGruffins added a commit to JoeGruffins/decrediton that referenced this pull request Jun 24, 2022
Add a function that can query trezor for deterministic bytes to be used
as the seed for a voting xpriv.

The method for retrieving deterministic private data was suggested by
Trezor developers:
trezor/trezor-firmware#1249 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Product related issue visible for end user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants