-
Notifications
You must be signed in to change notification settings - Fork 304
Add arbitrary impl for types used in PSBTs #828
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
Conversation
concept NACK these ones -- we aren't allowed to put arbitrary data into these structures. All the C library guarantees us is that the size is OK to assume. In particular, this will produce invalid x-only public keys which will cause aborts if used with the rest of the library. |
Oh i see. Would it be acceptable to create random SecretKey from the doc example:
and use that to generate the arbitrary types in |
@shinghim yeah, secret keys in particular I think you can go ahead and produce using For the other FFI types, I think you can do it, but you need to use a similar strategy to the main crate, where you generate byte arrays then use the (unsafe) decoding functions to produce the actual objects. |
0718503
to
40f073b
Compare
Updated to derive |
In 40f073b: Sorry to keep iterating on this, but could you:
Currently you have the opposite -- to get a XOnlyPublicKey you construct a PublicKey, which consumes a byte to determine parity, which you then just forget. |
No worries, I appreciate the feedback and the review. Updated to create the |
Can you run fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
match bool::arbitrary(u)? {
true => Ok(Parity::Even),
- false => Ok(Parity::Odd)
+ false => Ok(Parity::Odd),
}
}
} |
Unsure why CI is not complaining about this.. |
Updated after running |
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.
ACK 02ac1f2
Is there any chance these loops spin forever making debugging fuzzing harder? |
I don't think so since we're checking the amount of bytes left each time |
Ah sweet, I misread that check as checking the fill buffer length. Thanks man. |
Heh, interesting. I considered nitting the check with "eh, who cares if it 0-fills" but actually, since all-zeroes is not a valid x coordinate, the zero-filling would've caused an infinite loop! Good save. |
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.
ACK 02ac1f2; successfully ran local tests; nice!!
…sed in PSBTs 02ac1f216bea85bbef43b419fd0c2f8453e5f7d2 Add `Arbitrary` impl for SecretKey, Parity, and XOnlyPublicKey (Shing Him Ng) Pull request description: ACKs for top commit: tcharding: ACK 02ac1f216bea85bbef43b419fd0c2f8453e5f7d2 apoelstra: ACK 02ac1f216bea85bbef43b419fd0c2f8453e5f7d2; successfully ran local tests; nice!! Tree-SHA512: bc6248e54770e27dbc72a5e1e72e7918fe6916cdae2208f2841833d56b214e95025a9a4c8ddb991dd99910a58e28d04c283ecf7bc74f60eb1e265b82e4778381
…sed in PSBTs 02ac1f216bea85bbef43b419fd0c2f8453e5f7d2 Add `Arbitrary` impl for SecretKey, Parity, and XOnlyPublicKey (Shing Him Ng) Pull request description: ACKs for top commit: tcharding: ACK 02ac1f216bea85bbef43b419fd0c2f8453e5f7d2 apoelstra: ACK 02ac1f216bea85bbef43b419fd0c2f8453e5f7d2; successfully ran local tests; nice!! Tree-SHA512: bc6248e54770e27dbc72a5e1e72e7918fe6916cdae2208f2841833d56b214e95025a9a4c8ddb991dd99910a58e28d04c283ecf7bc74f60eb1e265b82e4778381
No description provided.