cryptoconditions
cryptoconditions copied to clipboard
Where to validate a condition's subtypes?
Some questions:
- Should the implementation silently ignore extra unsupported subtypes?
If not, then when should the implementation complain about it?
- At parsing time?
- When
.validate()
is explicitly called?
As an example, if we were to validate the subtypes when parsing, we could do so:
class ConditionTypes(BitString):
namedValues = NamedValues(
('preImageSha256', 0),
('prefixSha256', 1),
('thresholdSha256', 2),
('rsaSha256', 3),
('ed25519Sha256', 4),
)
subtypeSpec = ValueSizeConstraint(0, 5)
The line subtypeSpec = ValueSizeConstraint(0, 5)
requires the length of the BIT STRING
to be no longer than 5.