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
[zPIV] PublicCoinSpend v4 - Coin Randomness Schnorr Signature #936
[zPIV] PublicCoinSpend v4 - Coin Randomness Schnorr Signature #936
Conversation
There we go 👌 , concept ACK. |
7676093
to
8a70a55
Compare
Thinking more about it, we can also remove the coin serial number from the coinSpend serialization of v2 coins. cc2a3ab implements the new spend serialization. A new Unit tests show:
|
the |
@Fuzzbawls I don't think it's because of this, since that particular test doesn't involve zerocoins and even ends at block 330 (while CoinSpend activation is 350 for v3 and 450 for v4). Restarting the Travis job seems to have fixed it. On a related matter, functional tests on regnet for this change will be provided soon. |
Needs Rebase |
a534e47
to
45415f4
Compare
Rebased. |
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.
Concept and code ACK with a few minor nits.
As discussed, keeping the signature for v2 mints in v4 spends is not strictly necessary but given the space available in our blocks and the huge improvements public spends are it is not a problem either.
Unit tests are passing nicely.
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.
utACK 764f4d6 with 2 nits:
- the indenting changes make it unnecessarily hard to review this PR
- why no
const CBigNum BN_THREE = CBigNum(3);
?
Is there a 'real-life' way to test this or is all we can do to rely on the tests?
It's easier for review to check the commits individually. The indenting change is only in the first commit (which is tagged with
There weren't as many instances. There are still 8 of them tough (in
RegTest has no v1 functionality unfortunately (if anyone wants to add it is more than welcome to do so). I'm updating the publicSpend test to include v4 spends at least for v2 coins. Other than that, we'll soon protobump a "segregated" testnet to do more functional testing there. |
afce1cc
to
63b5616
Compare
Rebased on top of #976 to be able to add the functional test. |
3dcdf3a
to
3bd8974
Compare
cfb829e
to
01086b5
Compare
e8b39bc
to
c97c8d1
Compare
sets temporarily the activation height for zerocoin public spends v4. Also defines an helper function Zerocoin_PublicSpendVersion which returns the version active at a given block height
now that coinSpend has not the same version of the PublicCoin (extracted from the serial) we need a convenient way to retrieve the latter. This has to be used in HasValidSignature.
Instead of rejecting v1 serials, enforce the proper spend version. v1 serial will fail spend version 3 validation.
c97c8d1
to
6cf4922
Compare
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.
We can merge this already, ACK 6cf4922 .
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.
utACK 6cf4922 (unfortunately cannot really test it)
…ture 6cf4922 [Bug][Wallet] Guard chainActive access in GetMintMaturityHeight (random-zebra) 95c1532 [Build] Fix CMake linking order (random-zebra) 46f1e53 [Build] Add CoinRandomnessSchnorrSignature to CMakeLists.txt (random-zebra) 183bce4 [zPIV] Add schnorr pk to challenge hash (random-zebra) 0178bbc [Tests] Additional cases for zc public spends v4 (random-zebra) 64efc69 [Tests] Add v4 Spends to zerocoin_valid_public_spend functional test (random-zebra) 3398090 [Refactor] add BN_THREE hardcoded constant for CBigNum(3) (random-zebra) 95952f1 [Cleanup] Fix non UTF-8 chars in ParamGeneration comments (random-zebra) 6288bb7 [Tests] PublicCoinSpend v4 / CRSchnorrSig unit tests (random-zebra) 7b81e54 [zPIV] Remove v2 serials from serialized v4 PublicCoinSpend (random-zebra) a9b8aa0 [Consensus] PublicCoinSpend v4 enforcement (random-zebra) ecd9bcd [zPIV] PublicCoinSpend v4 definition (random-zebra) 0f1f881 [zPIV] CoinSpend: define getCoinVersion() (random-zebra) 5a2ab57 [Consensus] set placeholder for nPublicZCSpendsV4 (random-zebra) e346308 [zPIV] CoinRandomnessSchnorrSignature class definition (random-zebra) 5f9de6d [Refactor] Use hardcoded constants for CBigNum 0, 1, 2 (random-zebra) Pull request description: This PR proposes (as hard fork) a new PublicCoinSpend protocol suitable to be used also with zerocoins version 1. Closes #937 Motivation and overview in the following document: https://github.com/random-zebra/PIVX-Wiki/blob/master/Developer-Documentation/Specs/zPIV/CoinRandomnessSchnorrSignature.mediawiki Enforcement height uses placeholder values (one million blocks after the activation of spends v3 for main net and testnet, and 100 blocks for regnet). Changes - replaces many instances of `CBigNum(0)`, `CBigNum(1)`, `CBigNum(2)` throughout the code with fixed constants defined in bignum.h. - defines the `CoinRandomnessSchnorrSignature` using the algorithm described in the [wiki](https://github.com/random-zebra/PIVX-Wiki/blob/master/Developer-Documentation/Specs/zPIV/CoinRandomnessSchnorrSignature.mediawiki). - defines the temporary activation height and also defines an helper function `Zerocoin_PublicSpendVersion` which returns the version active at a given block height. - defines a convenient method to retrieve the coin version from a `PublicCoinSpend` class (now that coin version and spend version are different). - defines `PublicCoinSpend` behaviour for v4. - enforces the PublicCoinSpend version in `ContextualCheckZerocoinSpendNoSerialCheck`. - provides unit tests for the new v4 `PublicCoinSpend` class. ACKs for top commit: furszy: We can merge this already, ACK 6cf4922 . Mrs-X: utACK 6cf4922 (unfortunately cannot really test it) Tree-SHA512: 56a4e796323862453e593035d2ee9c1148e67db85bd90af015916c5e2be71e586aad289ebcfa63dc076bd4a6be9a5430ae01b5d42c8f9df7027bfee908dfdb99
e06f7b6 [Tests] Minor optimizations in zerocoin_valid_public_spend test (random-zebra) cdc18ea [RPC] fix parameters check for spendzerocoin (missing ispublicspend) (random-zebra) 72bc39a [Tests] Add zerocoin_valid_public_spend to testRunner (random-zebra) 26045d3 [Consensus] Set zc PublicSpend version v3/v4 via SPORK (random-zebra) Pull request description: This follows #936 It sets the required version for zerocoin PublicSpends via SPORK instead of having it height-based. When `SPORK_18_ZEROCOIN_PUBLICSPEND_V4` is not active (default), the required version is v3 (where old version 1 serials cannot be spent. ref: #891 ). It also fixes the relative functional test `zerocoin_valid_public_spend.py` and adds it to the test_runner. ACKs for top commit: furszy: utACK e06f7b6 Warrows: utACK e06f7b6 Tree-SHA512: 07f18e77a91503f5d48dafad32364cc6292ffd1f9a3f9286a78de72dafc98b07342e6abd96eaabe55d20193f10be383c8d5bbac1b33c45712ade8c522e457b3f
This PR proposes (as hard fork) a new PublicCoinSpend protocol suitable to be used also with zerocoins version 1. Closes #937
Motivation and overview in the following document:
https://github.com/random-zebra/PIVX-Wiki/blob/master/Developer-Documentation/Specs/zPIV/CoinRandomnessSchnorrSignature.mediawiki
Enforcement height uses placeholder values (one million blocks after the activation of spends v3 for main net and testnet, and 100 blocks for regnet).
Changes
replaces many instances of
CBigNum(0)
,CBigNum(1)
,CBigNum(2)
throughout the code with fixed constants defined in bignum.h.defines the
CoinRandomnessSchnorrSignature
using the algorithm described in the wiki.defines the temporary activation height and also defines an helper function
Zerocoin_PublicSpendVersion
which returns the version active at a given block height.defines a convenient method to retrieve the coin version from a
PublicCoinSpend
class (now that coin version and spend version are different).defines
PublicCoinSpend
behaviour for v4.enforces the PublicCoinSpend version in
ContextualCheckZerocoinSpendNoSerialCheck
.provides unit tests for the new v4
PublicCoinSpend
class.