-
Notifications
You must be signed in to change notification settings - Fork 219
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: add optional range proof types #5372
feat: add optional range proof types #5372
Conversation
base_layer/core/src/transactions/transaction_components/encrypted_value.rs
Outdated
Show resolved
Hide resolved
base_layer/core/src/transactions/transaction_components/encrypted_value.rs
Outdated
Show resolved
Hide resolved
base_layer/core/src/transactions/transaction_components/encrypted_value.rs
Outdated
Show resolved
Hide resolved
// Encrypted Pedersen commitment openings (value and mask) for the output | ||
EncryptedOpenings encrypted_openings = 6; | ||
// The type of range proof used in the output | ||
uint32 range_proof_type = 7; |
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.
Would it make more sense to make this a proper enum
for clarity and consistency?
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.
I would keep it like this as it is a simple conversion and consistent with uint32 output_type = 2;
// Encrypted Pedersen commitment openings (value and mask) for the output | ||
EncryptedOpenings encrypted_openings = 6; | ||
// The type of range proof used in the output | ||
uint32 range_proof_type = 7; |
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.
Would it make more sense to make this a proper enum
for clarity and consistency?
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.
I would keep it like this as it is a simple conversion and consistent with uint32 output_type = 2;
base_layer/core/src/transactions/transaction_components/encrypted_openings_x.rs
Outdated
Show resolved
Hide resolved
base_layer/core/src/transactions/transaction_components/encrypted_openings_x.rs
Outdated
Show resolved
Hide resolved
base_layer/core/src/transactions/transaction_components/encrypted_openings_x.rs
Outdated
Show resolved
Hide resolved
base_layer/core/src/transactions/transaction_components/encrypted_openings_x.rs
Outdated
Show resolved
Hide resolved
base_layer/core/src/transactions/transaction_components/encrypted_openings_x.rs
Outdated
Show resolved
Hide resolved
base_layer/core/src/transactions/transaction_components/encrypted_openings_x.rs
Outdated
Show resolved
Hide resolved
c1c40bb
to
6021f47
Compare
As per discussion with @stringhandler and @SWvheerden, it seems like a good strategy to implement the following:
Any comments? |
c237c62
to
e5d5363
Compare
I'm not sure this does everything you might hope. I'll use the signer/helper terminology that I've used elsewhere, where the helper is a semi-trusted device that must not gain spend authority, but which is tasked with scanning for outputs intended for the signer. For standard interactive outputs, it was presumably already possible for the helper to receive the value encryption key at some point from the signer. At this point, it could attempt value decryption as an initial check. Without the rewind key, it would be unable to extract the mask, which could only be done by the signer when it wishes to authorize a spend. Note that the helper has no way to itself determine if a commitment is spendable without the signer. For legacy one-sided outputs, it was presumably already possible for the helper to scan for these. It could quickly check scripts to watch for the signer's wallet public key to appear. However, it could not decrypt values or perform mask extraction without being able to complete the sender's ephemeral Diffie-Hellman exchange, which would require access to the signer's wallet secret key. For stealth one-sided outputs, it was not already possible for the helper to perform any scanning itself, since it could not check scripts for one-time public keys without completing the sender's ephemeral Diffie-Hellman exchange, which again would require access to the signer's wallet secret key. Further, it could not decrypt values or perform mask extraction for the same reason. The proposed change does unify the handling of masks, which previously would have been different in the case of revealed-value outputs that do not have range proofs to use for mask extraction. In the case of legacy and stealth one-sided outputs, the ability (or lack thereof) of the helper to scan for outputs does not change, as the value-with-mask encryption key would still be derived from a Diffie-Hellman exchange that requires the signer's wallet secret key to complete. In the case of standard interactive outputs, the scanning process seems to be made worse by the new design, depending on the handling of scripts. The use of a single encrypted field for value and mask means that a helper who can authenticate the ciphertext obtains both the value and mask, which grants it spend authority in the absence of any additional script public key whose corresponding secret key is known only to the signer. This seems out of line with the security goals. |
Another comment worth noting for standard interactive outputs is that if an additional script key (known only to the signer) is always required for spend authority in addition to knowledge of the commitment mask, the use of range proof offloading (which requires nontrivial state-machine interaction between signer and helper) would be unnecessary. |
f16bbca
to
e52af63
Compare
60aa71f
to
c107dbe
Compare
Test Results 4 files + 4 2 errors 12 suites +12 16m 15s ⏱️ + 16m 15s For more details on these parsing errors and failures, see this check. Results for commit f86a5f4. ± Comparison against base commit 8809b9f. ♻️ This comment has been updated with latest results. |
f86a5f4
to
e767067
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.
This looks good
base_layer/core/src/transactions/transaction_components/unblinded_output_builder.rs
Outdated
Show resolved
Hide resolved
base_layer/core/src/transactions/transaction_protocol/transaction_initializer.rs
Outdated
Show resolved
Hide resolved
base_layer/wallet/migrations/2023-05-15-112514_encrypted_openings/up.sql
Show resolved
Hide resolved
e767067
to
2e617f3
Compare
Test Results (CI)1 147 tests +6 1 147 ✔️ +6 9m 59s ⏱️ +51s Results for commit f2b1aad. ± Comparison against base commit 53ee32b. This pull request removes 7 and adds 13 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
2e617f3
to
5033485
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.
I might have missed it, but I don't see the block validation to make sure a transaction is correct when the value is revealed
base_layer/core/src/transactions/transaction_components/encrypted_openings.rs
Outdated
Show resolved
Hide resolved
I prefer the name |
You'd also need separate extended nonces, and would therefore bloat the ciphertext by an extra 40 bytes. Agreed that there is no advantage unless there's a use case where an entity would need to be able to authenticate the ciphertext without learning, say, the commitment mask. And it sounds like that is not expected to be the case. |
7791f07
to
05b97e9
Compare
Added optional range proof ...
05b97e9
to
f2b1aad
Compare
Must do ^^ |
@hansieodendaal: Is it always guaranteed that a value-revealing range proof check will also have a separate check for a valid metadata signature? This is required according to the verification step described in RFC-0182. Previously, range proof verification was sufficient on its own to assert a commitment value is valid. Now, doing the zero-nonce scalar check in a value-revealing case is insufficient to conclude anything unless the entire metadata signature is also verified, which is not done internally to your range proof verifier. My concern would be that some code path might assume validity without signature verification. |
Addressed in #5411 with a signature verification check. |
## [0.50.0-pre.2](v0.50.0-pre.1...v0.50.0-pre.2) (2023-05-29) ### ⚠ BREAKING CHANGES * add optional range proof types (5372) ### Features * add metadata signature check ([5411](#5411)) ([9c2bf41](9c2bf41)) * add optional range proof types ([5372](#5372)) ([f24784f](f24784f)) * added burn feature to the console wallet ([5322](#5322)) ([45685b9](45685b9)) * improved base node monitoring ([5390](#5390)) ([c704890](c704890)) ### Bug Fixes * **comms:** only set final forward address if configured to port 0 ([5406](#5406)) ([ff7fb6d](ff7fb6d)) * deeplink to rfc spec ([5342](#5342)) ([806d3b8](806d3b8)) * don't use in memory datastores for chat client dht in integration tests ([#5399](#5399)) ([cbdca6f](cbdca6f)) * fix panic when no public addresses ([5367](#5367)) ([49be2a2](49be2a2)) * loop on mismatched passphrase entry ([5396](#5396)) ([ed120b2](ed120b2)) * use domain separation for wallet message signing ([5400](#5400)) ([7d71f8b](7d71f8b))
Description
Added optional range proof types where the Bulletproof+ is no longer the only acceptable proof.
The
RevealedValue
proof hinges on the prover revealing the commitment value as equal to theminimum_value_promise
and creating a special version of the metadata signature where the deterministic
ephemeral_commitment
noncer_a
isset equal to zero (see RFC-0182).
As a result of the optional range proof, we do not use Bulletproof+ range-proof rewinding anymore. Encrypted value was replaced with encrypted openings and updated scanning and recovery based on encrypted openings.
Updated the
igor
andesmeralda
genesis block faucets to make use of the new optional range proofs.Motivation and Context
This will allow faucet outputs in the genesis block without the data overhead of a Bulletproof+ range proof for each. Other use cases include special transactions with revealed value outputs, but subject to the consensus constants where
RevealedValue
range proofs need to be switched on explicitly.How Has This Been Tested?
Unit tests
Cucumber tests
System-level tests:
igor
- base nodes, SHA3 mining, merged mining, console walletsesmeralda
- base nodes, SHA3 mining, merged mining, console walletsWhat process can a PR reviewer use to test or verify this change?
Recommend a system-level test
Breaking Changes
BREAKING CHANGE: New genesis block for
igor
andesmeralda
, thus restart the blockchains.