-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Derivation proc macro for commitment encoding #121
Merged
Merged
Conversation
This file contains 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
crisdut
previously approved these changes
May 2, 2023
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 did the initial tests for consecutive transfers. With that version of commit_verify, everthing works!
bb1567d
to
291e24d
Compare
crisdut
approved these changes
May 2, 2023
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
*consensus*
Issues affecting distributed concensus
enhancement
New feature or request
refactoring
Refactoring of the existing code
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.
These are consensus-level changes required for solving the RGB-WG/rgb-std#36 and an upstream dependency for completing the work in RGB-WG/rgb-core#153
Derivation macro are required to get commitment encoding work properly. Let me explain what is needed to be achieved schematically.
Let's assume we have three data types, used by each other:
A -> B -> Data
, whereData
has data which may be concealed.(I am skipping some derives and code details to prevent visual clutter).
Before this PR, there was no way of getting
Data
committed without bulletproofs: the setup we hadwas not achieving the goal, since bulletproofs are get encoded even if we do a custom implementation of the
CommitConceal
for theData
type likesince when we call
A::commit_encode()
it does conceal for all types underneath - but instead of callingself.b.commit_encode(..)
it callsself.strict_encode
, thusData::commit_encode
is never get called and bulletproofs are still serialized into the hasher.The only way of getting the whole thing to work properly is to provide a custom implementation of
CommitEncode
for each type aboveData
. In reality, for RGB it means implementing for dozens of data types - with the risk that some implementation of commit-encode will accidentially diverge from strict encoding serialization which we control in deterministic way with strict type system. I.e. this was highly undesirable.Adding derivation macros allows to avoid this problem and achieve our goal with simply adding
#[derive(CommitEncode)]
forA
andB
types, and addingskip
directive to bulletproofs:In such way we clearly see where we diverge from strict encoding - while being sure that everywhere else we follow the same serialization rules.