bigchaindb / bigchaindb/cryptoconditions
Make type match type_id
- Dominant language
- Python
- Stars
- 73
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
Currently, the `'type'` field only shows either `'condition'` or `'fulfillment'`, whereas the `'type_id'` is set according to the rfc.
Example:
```python
>>> Condition.from_uri('cc:2:2b:mJUaGKCuF5n-3tfXM2U81VYtHbX-N8MP6kz8R-ASwNQ:146').to_dict()
{'bitmask': 43,
'hash': 'BGcqXDoe5DeQB87es8AQEDWr3A6Dvjuq3egZF5sZ1qfy',
'max_fulfillment_length': 146,
'type': 'condition',
'type_id': 2}
```
This issue proposes to change the above to:
```python
>>> Condition.from_uri('cc:2:2b:mJUaGKCuF5n-3tfXM2U81VYtHbX-N8MP6kz8R-ASwNQ:146').to_dict()
{'bitmask': 43,
'hash': 'BGcqXDoe5DeQB87es8AQEDWr3A6Dvjuq3egZF5sZ1qfy',
'max_fulfillment_length': 146,
'type': 'prefix_sha_256',
'type_id': 2}
```
Unless @sbellem's understanding is wrong this would be in line with the RFC:
> ## 2.4. Condition
>
> Below are the string and binary encoding formats for a condition.
>
> ### 2.4.1. String Format
>
> Conditions are ASCII encoded as:
>
> ```text
> "cc:" BASE16(type) ":" BASE16(featureBitmask) ":"
> BASE64URL(fingerprint) ":" BASE10(maxFulfillmentLength)
> ```
>
> ### 2.4.2. Binary Format
>
> Conditions are binary encoded as:
>
> ```text
> Condition ::= SEQUENCE {
> type ConditionType,
> featureBitmask INTEGER (0..MAX),
> fingerprint OCTET STRING,
> maxFulfillmentLength INTEGER (0..MAX)
> }
>
> ```text
> ConditionType ::= INTEGER {
> preimageSha256(0),
> rsaSha256(1),
> prefixSha256(2),
> thresholdSha256(3),
> ed25519(4)
> } (0..65535)
> ```
Perhaps a different, issue, but raising here as it related. Why not use the word `type` to denote the id, since it is what the spec uses? We could use `type_name` to store the name.
Contributor guide
Assessment
This issue has not been assessed yet.