Skip to content
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

Switch to ASN.1/OER encoding #19

Merged
merged 4 commits into from Apr 5, 2016
Merged

Switch to ASN.1/OER encoding #19

merged 4 commits into from Apr 5, 2016

Conversation

justmoon
Copy link
Contributor

This PR makes three changes to both spec and implementation:

  • Add the type ID to the condition format.

    This is very, very slightly inefficient, because it makes conditions larger (by about 3%.) But it reduces the risk that a spec writer or implementer will make a mistake and allow a collision between types.

    For example, if there is some bug where an implementation gets confused and treats an RSA-SHA-256 condition as a PREIMAGE-SHA-256 condition, then you could fulfill it just by providing the public key.

    This change makes this bug much less likely to happen. In addition it ensures that conditions start with the same prefix as their fulfillments, making crypto-conditions more consistent and easier to use.

    The types are:

    • 0 ... PREIMAGE-SHA-256
    • 1 ... PREFIX-SHA-256
    • 2 ... THRESHOLD-SHA-256
    • 3 ... RSA-SHA-256
    • 4 ... ED25519
  • Switch to ASN.1/OER encoding.

    Reduces the amount of time the spec has to spend on specifying the binary format. It reduces the chance that there will be errors or mistake in defining the binary format and gives both spec writers and implementers additional tools they can use.

  • Remove the version field.

    With the first change above, we now have a bit too many numbers in the condition. But one of them is pretty redundant: the version. We already have a field which has the semantics of a version field: The type field. So if we want to increment the version of this standard, introduce a new format, etc. we can simply bump the type field to a value that has not been assigned. As a result, conditions and fulfillments are shorter and easier to read.

Before:

'cf:1:2:AQIBAwABAAABACMgIHahWSBEpuT1ESZbynOmBNkLBSnR32Ar4woZqSV2YNH1Yg'
'cc:1:2b:fUAUR2rFcOtNs1ARv_7WVkEPNrdCtFHkxLsFlEsBPbs:145'

'cf:1:4:IDtqJ7zOtqQtYqOo0CpvDXNlMhV3HeJDpjrASKGLWdopQI-JWzyv4slQYDnQ4qZjglaABGdP6NI3eFCS5A1qr0g-T8YBaHBfMfEBWWE4ziGqNXwNMqBk9CPcPuSqOr9T-AM'
'cc:1:20:O2onvM62pC1io6jQKm8Nc2UyFXcd4kOmOsBIoYtZ2ik:98'

After:

'cf:2:AQEBAgEBBAAAAQAAAQEAJwAEASAgIHahWSBEpuT1ESZbynOmBNkLBSnR32Ar4woZqSV2YNEBYA'
'cc:2:2b:oQQ12Y-XpoAmeHsTBN640Neg8dIHrdtfFk8SLFyK8KQ:146'

'cf:4:O2onvM62pC1io6jQKm8Nc2UyFXcd4kOmOsBIoYtZ2imPiVs8r-LJUGA50OKmY4JWgARnT-jSN3hQkuQNaq9IPk_GAWhwXzHxAVlhOM4hqjV8DTKgZPQj3D7kqjq_U_gD'
'cc:4:20:O2onvM62pC1io6jQKm8Nc2UyFXcd4kOmOsBIoYtZ2ik:96'

Note the fulfillment (cf:) only has one version/type field now and both condition and fulfillment now start with the same type ID.

Conditions don't always start with the same type identifier as their fulfillment counterparts. This
is due to the difference between bitmasks and type IDs. This change adds the type ID to the
beginning of conditions so that conditions start with the same versioning data as their fulfillment
counterparts.
Conditions and fulfillments both start now with two integer fields that are both evaluated as "if this field has a value higher than I understand, abort". This is redundant. The type field *is* our version field and when we want to change either the binary or string formats, we can simply use a type that has not been assigned.
@justmoon justmoon merged commit 479b821 into master Apr 5, 2016
@justmoon justmoon deleted the feature/asn branch April 5, 2016 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant