I've been thinking lately about how a dev may use libbitcoinconsensus to add verification to his program. Unfortunately, there are several current issues that (I believe) seriously hamper real-world usage.
For example, bitcoinconsensus_SCRIPT_FLAGS_VERIFY_DERSIG was just recently added as a flag for the lib. For the sake of discussion, let's imagine that this flag was not present in the 0.10 release at all, but it is present in 0.11.
A dev is working against the 0.11 version. He releases a program that loads libbitcoinconsensus.so and uses it to verify. It specifies the bitcoinconsensus_SCRIPT_FLAGS_VERIFY_DERSIG flag and compiles fine, and he distributes it to users. Someone with the 0.10 version of the lib runs the program, which silently verifies without taking the new flag into account. Ouch.
The obvious guard against that would be for the lib to first verify that it understands the flags passed in. If it doesn't, then it bails out with an error.
But there's a problem with that as well... the lib currently understands more flags than it exposes externally. By adding a check to ensure that the user has only used exposed flags, we'd be artificially limiting it. In this case, adding that check would break verification for the user that would've otherwise worked.
I've run in circles trying to figure out how to deal with these issues, so any suggestions would be appreciated.
- If libbitcoinconsensus is passed a flag that is not exposed externally, should it immediately fail?
- If 'no' to 1., if it is passed a flag that is also not understood internally should it immediately fail?
- Despite objections about purity, I believe that ultimately devs will eventually want a bitcoinconsensus_script_isstandard() function. This would likely require having the other flags available as well, so it may change answers to 1. and 2.