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

Blinding API cleanups #143

Merged
merged 9 commits into from
Oct 5, 2022
Merged

Conversation

sanket1729
Copy link
Member

@sanket1729 sanket1729 commented Aug 3, 2022

  • This required the user to explicitly maintain whether the current TxIn
    has issuance or not whereas it can directly be calculated from
    assetIssuance field

The blinding APIs are separated into smaller chunks. This allows
- Blinding only the values or the assets but not both
- Not relying on rng to set asset/value blinding factors
- Better input parameters

Note I had to edit the test vectors the order in which they were sampled from rng had changed.

@apoelstra
Copy link
Member

Should I review this? I have been holding off because of the sea of red in CI.

@sanket1729
Copy link
Member Author

The downstream options project is stable enough. I can rewive this PR today.

@sanket1729 sanket1729 force-pushed the blind_cleanups branch 3 times, most recently from c082ee9 to 157e4ef Compare September 30, 2022 11:41
@sanket1729
Copy link
Member Author

Cherry-picked the MSRV commit here. This might not be an easy review, but I would really like this to go into the next release.

@apoelstra
Copy link
Member

Will need rebase after #147 (and then I think we'll no longer need the MSRV bump, though we will need a CHANGELOG update). But I'll review this as-is.

AssetId::generate_asset_entropy(prevout, contract_hash)
} else {
// re-issuance
sha256::Midstate::from_inner(self.issuance_asset_entropy.unwrap_or([0u8; 32]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 8b41c13:

Should use unwrap_or_default here like above (or change both to unwrap_or([8; 32]); having two ways to write the same thing makes it look like these do different things, which is confusing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still present in 04ad35f

Copy link
Member Author

@sanket1729 sanket1729 Oct 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in fa753b4

.collect::<Vec<_>>();

Ok((inp_secrets, blind_out_indices))
}

/// Obtains the surjection inputs for this pset. This servers as the domain
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 8b41c13:

Typo servers should be serves.

I also wonder if you should define "domain" ... e.g. write domain (set of assets on the "input side") since this term isn't really used elsewhere, and it isn't obvious unless you're pretty familiar with the word "surjection".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still present in 04ad35f

Copy link
Member Author

@sanket1729 sanket1729 Oct 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in fa753b4

src/blind.rs Outdated Show resolved Hide resolved
src/blind.rs Outdated Show resolved Hide resolved
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 49d1ec2

@apoelstra
Copy link
Member

All my comments are nits which could be addressed with additional commits or even in another PR.

Also, can you add a commit which runs cargo fmt?

@sanket1729
Copy link
Member Author

Also, can you add a commit which runs cargo fmt?

@apoelstra, do you mean on the entire codebase

@apoelstra
Copy link
Member

@sanket1729 let's say, just on blind.rs and psbt/mod.rs which are otherwise heavily modified in this PR (and there are a couple format nits I didn't want to write out in those files).

@sanket1729
Copy link
Member Author

@apoelstra, any interest in reviving #80? We have enforced rustfmt across rust-bitcoin org in many repos.

@sanket1729
Copy link
Member Author

sanket1729 commented Oct 1, 2022

Addressed the comments. Will rebase after we have #147 in

@sanket1729
Copy link
Member Author

Also added a test to test tx verification with partially blinded transactions

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 073e720

This required the user to explicitly maintain whether the current TxIn
has issuance or not whereas it can directly be calculated from
assetIssuance field
Now the blinding APIs are separated into smaller chunks. This allows
1) Blinding only the values or the assets but not both
2) Not relying on rng to set asset/value blinding factors
3) Bunch of API cleanups with better input parameters
Issuances are still not blinded in pset. We can add another parameter to
Pset::blind_last and Pset::blind_non_last, but it is add another
parameter to the API.

We can implement this in future if required.
This was only used in issuance blinding nonce, so was never really
tested
Should be 0x0a not 0x10 :)
While the positions of inputs and outputs don't usually matter, they do
matter in covenant constructions. This allows easier construction rather
than creating a new vec or swapping things around
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 582325e

@apoelstra apoelstra merged commit 55b6cce into ElementsProject:master Oct 5, 2022
@RCasatta RCasatta mentioned this pull request Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants