-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add a filter for TimestampCommitment and BlockHashCommitment #104
Comments
For this:
|
Ok, this seems to work but the default implementation of the /// A Commitment whose expected data is a Unix time.
pub trait TimestampCommitment : Commitment {
/// Gets the timestamp as a Unix time.
fn timestamp(&self) -> Timestamp {
self.expected_data()
.as_u64()
.unwrap()
.try_into()
.expect("Construction guarantees u32.")
}
} It would be ok if we could enforce the condition that the expected_data must have type Also, I haven't yet run the implementation tests. On the plus side, the implementation of |
Nice one, this is much better and fixes the issue! I've made a couple of modifications:
I think this is good to go in #106 but some potential options for future:
|
…mp-commitment Add filtering for block hash and timestamp commitments, add generic expected data (#104)
Done in #108 |
The
TrivialCommitment
trait includes (optional) support for filtering of the candidate data.In the case of a
TimestampCommitment
, the candidate data is a Bitcoin block header. Currently the expected data (a Unix timestamp) is sought inside the whole header, not just the timestamp field. This introduces a possible attack vector. An attacker could produce a header with a different timestamp but which contains, in a different field, the 32 bits matching a different timestamp. Without filtering of the candidate data, this bogus header would be accepted as valid (in the sense that the commitment would verify successfully).The same applies to the
BlockHashCommitment
(where we should filter on the Merkle root field).The text was updated successfully, but these errors were encountered: