From c870cc7514d0538ff629c1f98184708c5783e766 Mon Sep 17 00:00:00 2001 From: Sylvain Bellemare Date: Mon, 19 Jun 2017 13:22:22 +0200 Subject: [PATCH] Docs --- CONTRIBUTING.rst | 18 ++ README.md | 427 ------------------------------------------ README.rst | 60 ++++++ docs/contributing.rst | 1 + docs/examples.rst | 20 ++ docs/index.rst | 14 +- docs/libref.rst | 68 +++---- docs/usage.rst | 128 +++++++++++++ 8 files changed, 261 insertions(+), 475 deletions(-) create mode 100644 CONTRIBUTING.rst delete mode 100644 README.md create mode 100644 README.rst create mode 100644 docs/contributing.rst create mode 100644 docs/examples.rst create mode 100644 docs/usage.rst diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..a7c9d80 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,18 @@ +Contributing +============ +First clone this repository (optional: and a virtual env). +Note that we support **Python 3.5+**. + +Install in development mode: + +.. code-block:: bash + + $ pip install -e .[dev] + +Write your patch ... + +Run the tests: + +.. code-block:: bash + + $ pytest -v diff --git a/README.md b/README.md deleted file mode 100644 index 9b1c699..0000000 --- a/README.md +++ /dev/null @@ -1,427 +0,0 @@ -[![Build Status](https://travis-ci.org/bigchaindb/cryptoconditions.svg?branch=master)](https://travis-ci.org/bigchaindb/cryptoconditions) -[![PyPI](https://img.shields.io/pypi/v/cryptoconditions.svg)](https://pypi.python.org/pypi/cryptoconditions) -[![codecov.io](https://codecov.io/github/bigchaindb/cryptoconditions/coverage.svg?branch=master)](https://codecov.io/github/bigchaindb/cryptoconditions?branch=master) - - -# How to install and run tests - -First clone this repository (optional: and a virtual env). -Note that we support **Python>=3.4**. - -Install from pypi: - -``` -$ pip install cryptocondtions -``` - -Or install from source -``` -$ pip install -e .[dev] -$ py.test -v -``` - - -# Crypto Conditions - -Python implementation of **Crypto-Conditions**. See draft of specification at -[draft-thomas-crypto-conditions-01](https://tools.ietf.org/html/draft-thomas-crypto-conditions-01). - -The RFC is also on github under -[interledger/rfcs/0002-crypto-conditions/](https://github.com/interledger/rfcs/tree/master/0002-crypto-conditions). - -The Crypto-Conditions specification is part of the - [**Interledger Protocol (ILP)**](https://interledger.org/rfcs/0003-interledger-protocol/). - - -## Motivation - -We would like a way to describe a signed message such that multiple actors in a -distributed system can all verify the same signed message and agree on whether -it matches the description. - -This provides a useful primitive for distributed, event-based systems since we -can describe events (represented by signed messages) and therefore define -generic authenticated event handlers. - -## Usage - -```python -import json -import binascii -import cryptoconditions as cc - -# Parse a condition from a URI -example_condition_uri = 'cc:0:3:47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU:0' -parsed_condition = cc.Condition.from_uri(example_condition_uri) -print(isinstance(parsed_condition, cc.Condition)) -# prints True - -print(binascii.hexlify(parsed_condition.hash)) -# prints b'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' - -# Compile a condition -parsed_condition_uri = parsed_condition.serialize_uri() -print(parsed_condition_uri) -# prints 'cc:0:3:47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU:0' -print(parsed_condition_uri == example_condition_uri) -# prints True - -# Parse a fulfillment -example_fulfillment_uri = 'cf:0:' -parsed_fulfillment = cc.Fulfillment.from_uri(example_fulfillment_uri) -print(isinstance(parsed_fulfillment, cc.PreimageSha256Fulfillment)) -# prints True - -# Retrieve the condition of the fulfillment -print(parsed_fulfillment.condition_uri) -# prints 'cc:0:3:47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU:0' - -# Validate a fulfillment -parsed_fulfillment.validate() -# prints True - -# Serialize fulfillment to JSON -json_data = json.dumps(parsed_fulfillment.to_dict()) -print(json_data) -# prints '{"bitmask": 3, "type_id": 0, "type": "fulfillment", "preimage": ""}' - -# Parse fulfillment from JSON -json_fulfillment = cc.Fulfillment.from_dict(json.loads(json_data)) -print(json_fulfillment.serialize_uri()) -# prints 'cf:0:' -``` - -## ILP Format - -### Condition - -Conditions are ASCII encoded as: - -``` -"cc:" BASE16(TYPE) ":" BASE16(FEATURE_BITMASK) ":" BASE64URL(FINGERPRINT) ":" BASE10(MAX_FULFILLMENT_LENGTH) -``` - -Conditions are binary encoded as: - -``` -CONDITION = - INT TYPE - OCTET_STRING TYPE_BITMASK - OCTET_STRING FINGERPRINT - INT MAX_FULFILLMENT_LENGTH -``` - -### Fulfillment - -Fulfillments are ASCII encoded as: - -``` -"cf:" BASE16(TYPE) ":" BASE64URL(PAYLOAD) -``` - -Fulfillments are binary encoded as: - -``` -FULFILLMENT = - INT TYPE - OCTET_STRING PAYLOAD -``` - -# Condition Types - -## Preimage-SHA-256 - -### Condition - -``` -HASH = SHA256(PREIMAGE) -``` - -### Fulfillment - -``` -FULFILLMENT_PAYLOAD = - VARBYTES PREIMAGE -``` - -### Usage - -```python -import binascii, hashlib -import cryptoconditions as cc - -secret = '' -puzzle = binascii.hexlify(hashlib.sha256(secret.encode()).digest()) -print(puzzle) -# prints b'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' - -# Create a SHA256 condition -sha256condition = cc.Condition() -sha256condition.type_id = cc.PreimageSha256Fulfillment.TYPE_ID -sha256condition.bitmask = cc.PreimageSha256Fulfillment.FEATURE_BITMASK -sha256condition.hash = binascii.unhexlify(puzzle) -sha256condition.max_fulfillment_length = 0 -sha256condition_uri = sha256condition.serialize_uri() -print(sha256condition_uri) -# prints 'cc:0:3:47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU:0' - -# Create a fulfillment -sha256fulfillment = cc.PreimageSha256Fulfillment() - -# Create a condition from fulfillment -sha256fulfillment.condition -# raises ValueError: Could not calculate hash, no preimage provided -sha256fulfillment.preimage = secret -print(sha256fulfillment.condition.serialize_uri() == sha256condition_uri) -# prints True - -# Compile a fulfillment -print(sha256fulfillment.serialize_uri()) -# prints 'cf:0:' - -# Even better: verify that the fulfillment matches the condition -print(sha256fulfillment.validate() and \ - sha256fulfillment.condition.serialize_uri() == sha256condition.serialize_uri()) -# prints True -``` - -## RSA-SHA-256 - -**Warning:** not (yet) implemented in `cryptoconditions`, for info see the -[**ILP specification**](https://tools.ietf.org/html/draft-thomas-crypto-conditions-01). - -## ED25519 - -### Condition - -``` -HASH = UINT256 PUBLIC_KEY -``` - -### Fulfillment - -``` -FULFILLMENT_PAYLOAD = - UINT256 PUBLIC_KEY - UINT512 SIGNATURE -``` - -### Usage - -```python -import cryptoconditions as cc - -# We use base58 key encoding -sk = cc.crypto.Ed25519SigningKey(b'9qLvREC54mhKYivr88VpckyVWdAFmifJpGjbvV5AiTRs') -vk = sk.get_verifying_key() - -# Create an ED25519-SHA256 condition -ed25519_fulfillment = cc.Ed25519Fulfillment(public_key=vk) -ed25519_condition_uri = ed25519_fulfillment.condition.serialize_uri() -print (ed25519_condition_uri) -# prints 'cc:4:20:7Bcrk61eVjv0kyxw4SRQNMNUZ-8u_U1k6_gZaDRn4r8:96' - -# ED25519-SHA256 condition not fulfilled -print(ed25519_fulfillment.validate()) -# prints False - -# Fulfill an ED25519-SHA256 condition -message = 'Hello World! Conditions are here!' -ed25519_fulfillment.sign(message, sk) -print(ed25519_fulfillment.validate(message)) -# prints True - -print(ed25519_fulfillment.serialize_uri()) -# prints 'cf:4:7Bcrk61eVjv0kyxw4SRQNMNUZ-8u_U1k6_gZaDRn4r-2IpH62UMvjymLnEpIldvik_b_2hpo2t8Mze9fR6DHISpf6jzal6P0wD6p8uisHOyGpR1FISer26CdG28zHAcK' -print(ed25519_fulfillment.condition_uri) -# prints 'cc:4:20:7Bcrk61eVjv0kyxw4SRQNMNUZ-8u_U1k6_gZaDRn4r8:96' - -# Parse a fulfillment URI -parsed_ed25519_fulfillment = cc.Ed25519Fulfillment.from_uri('cf:4:7Bcrk61eVjv0kyxw4SRQNMNUZ-8u_U1k6_gZaDRn4r-2IpH62UMvjymLnEpIldvik_b_2hpo2t8Mze9fR6DHISpf6jzal6P0wD6p8uisHOyGpR1FISer26CdG28zHAcK') - -print(parsed_ed25519_fulfillment.validate(message)) -# prints True -print(parsed_ed25519_fulfillment.condition.serialize_uri()) -# prints 'cc:4:20:7Bcrk61eVjv0kyxw4SRQNMNUZ-8u_U1k6_gZaDRn4r8:96' -``` - -## THRESHOLD-SHA-256 - -### Condition - -``` -HASH = SHA256( - VARUINT TYPE_BIT - VARUINT THRESHOLD - VARARRAY - VARUINT WEIGHT - VARBYTES PREFIX - CONDITION -) -``` - - -### Fulfillment - -``` -FULFILLMENT_PAYLOAD = - VARUINT THRESHOLD - VARARRAY - UINT8 FLAGS - OPTIONAL VARUINT WEIGHT ; if FLAGS & 0x40 - OPTIONAL VARBYTES PREFIX ; if FLAGS & 0x20 - OPTIONAL FULFILLMENT ; if FLAGS & 0x80 - OPTIONAL CONDITION ; if ~FLAGS & 0x80 -``` - -### Usage - -```python -import json -import cryptoconditions as cc - -# Parse some fulfillments -ed25519_fulfillment = cc.Ed25519Fulfillment.from_uri('cf:4:7Bcrk61eVjv0kyxw4SRQNMNUZ-8u_U1k6_gZaDRn4r-2IpH62UMvjymLnEpIldvik_b_2hpo2t8Mze9fR6DHISpf6jzal6P0wD6p8uisHOyGpR1FISer26CdG28zHAcK') - -# Create a 1-of-2 threshold condition (OR gate) -threshold_fulfillment = cc.ThresholdSha256Fulfillment(threshold=1) -# Add as an object or by URI -threshold_fulfillment.add_subfulfillment_uri('cf:0:') -threshold_fulfillment.add_subfulfillment(ed25519_fulfillment) -print(threshold_fulfillment.condition_uri) -# prints 'cc:2:2b:mJUaGKCuF5n-3tfXM2U81VYtHbX-N8MP6kz8R-ASwNQ:146' - -# Compile a threshold fulfillment -threshold_fulfillment_uri = threshold_fulfillment.serialize_uri() -# Note: If there are more than enough fulfilled subconditions, shorter -# fulfillments will be chosen over longer ones. -print(threshold_fulfillment_uri) -# prints 'cf:2:AQEBAgEBAwAAAAABAQAnAAQBICDsFyuTrV5WO_STLHDhJFA0w1Rn7y79TWTr-BloNGfivwFg' - -# Validate fulfillment -message = 'Hello World! Conditions are here!' -print(threshold_fulfillment.validate(message)) -# prints True - -# Parse the fulfillment -reparsed_fulfillment = cc.ThresholdSha256Fulfillment.from_uri(threshold_fulfillment_uri) -print(reparsed_fulfillment.validate(message)) -# prints True - -# Increase threshold to a 3-port AND gate -threshold_fulfillment.threshold = 3 -print(threshold_fulfillment.validate(message)) -# prints False - -# Create a nested threshold condition -# VALID = SHA and DSA and (DSA or DSA) -nested_fulfillment = cc.ThresholdSha256Fulfillment(threshold=1) -nested_fulfillment.add_subfulfillment(ed25519_fulfillment) -nested_fulfillment.add_subfulfillment(ed25519_fulfillment) -threshold_fulfillment.add_subfulfillment(nested_fulfillment) -threshold_fulfillment.threshold = 3 # AND gate - -print(threshold_fulfillment.serialize_uri()) -# prints 'cf:2:AQMBAwEBAwAAAAABAWMABGDsFyuTrV5WO_STLHDhJFA0w1Rn7y79TWTr-BloNGfiv7YikfrZQy-PKYucSkiV2-KT9v_aGmja3wzN719HoMchKl_qPNqXo_TAPqny6Kwc7IalHUUhJ6vboJ0bbzMcBwoAAQGBmgACgZYBAQECAQEAJwAEASAg7Bcrk61eVjv0kyxw4SRQNMNUZ-8u_U1k6_gZaDRn4r8BYAEBYwAEYOwXK5OtXlY79JMscOEkUDTDVGfvLv1NZOv4GWg0Z-K_tiKR-tlDL48pi5xKSJXb4pP2_9oaaNrfDM3vX0egxyEqX-o82pej9MA-qfLorBzshqUdRSEnq9ugnRtvMxwHCgAA' -threshold_fulfillment.to_dict() -``` - -```python - { - "bitmask":43, - "subfulfillments":[ - { - "bitmask":3, - "preimage":"", - "type":"fulfillment", - "type_id":0, - "weight":1 - }, - { - "bitmask":32, - "public_key":"Gtbi6WQDB6wUePiZm8aYs5XZ5pUqx9jMMLvRVHPESTjU", - "signature":"4eCt6SFPCzLQSAoQGW7CTu3MHdLj6FezSpjktE7tHsYGJ4pNSUnpHtV9XgdHF2XYd62M9fTJ4WYdhTVck27qNoHj", - "type":"fulfillment", - "type_id":4, - "weight":1 - }, - { - "bitmask":41, - "subfulfillments":[ - { - "bitmask":32, - "public_key":"Gtbi6WQDB6wUePiZm8aYs5XZ5pUqx9jMMLvRVHPESTjU", - "signature":"4eCt6SFPCzLQSAoQGW7CTu3MHdLj6FezSpjktE7tHsYGJ4pNSUnpHtV9XgdHF2XYd62M9fTJ4WYdhTVck27qNoHj", - "type":"fulfillment", - "type_id":4, - "weight":1 - }, - { - "bitmask":32, - "public_key":"Gtbi6WQDB6wUePiZm8aYs5XZ5pUqx9jMMLvRVHPESTjU", - "signature":"4eCt6SFPCzLQSAoQGW7CTu3MHdLj6FezSpjktE7tHsYGJ4pNSUnpHtV9XgdHF2XYd62M9fTJ4WYdhTVck27qNoHj", - "type":"fulfillment", - "type_id":4, - "weight":1 - } - ], - "threshold":1, - "type":"fulfillment", - "type_id":2, - "weight":1 - } - ], - "threshold":3, - "type":"fulfillment", - "type_id":2 - } -``` - - -## (unofficial) Timeout-SHA-256 - -Extends Preimage-SHA-256 - -### Condition - -``` -HASH = SHA256(EXPIRE_TIME) -``` - - -### Fulfillment - -``` -FULFILLMENT_PAYLOAD = - VARBYTES EXPIRE_TIME -``` - -### Usage - -```python -from time import sleep - -import cryptoconditions as cc -from cryptoconditions.types.timeout import timestamp - -time_expire = str(float(timestamp()) + 5) # 5 secs from now -timeout_fulfillment = cc.TimeoutFulfillment(expire_time=time_expire) - -# Small test to see the state change -for i in range(8): - timeout_valid = timeout_fulfillment.validate(now=timestamp()) - seconds_to_timeout = int(float(time_expire) - float(timestamp())) - print('timeout_fulfillment valid: {} ({}s to timeout)'.format(timeout_valid, seconds_to_timeout)) - sleep(1) -``` - -```python -timeout_fulfillment valid: True (3s to timeout) -timeout_fulfillment valid: True (2s to timeout) -timeout_fulfillment valid: True (1s to timeout) -timeout_fulfillment valid: True (0s to timeout) -timeout_fulfillment valid: False (0s to timeout) -timeout_fulfillment valid: False (-1s to timeout) -timeout_fulfillment valid: False (-2s to timeout) -timeout_fulfillment valid: False (-3s to timeout) -``` diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..18840b2 --- /dev/null +++ b/README.rst @@ -0,0 +1,60 @@ +.. image:: https://img.shields.io/pypi/v/cryptoconditions.svg + :target: https://pypi.python.org/pypi/cryptoconditions + +.. image:: https://img.shields.io/travis/bigchaindb/cryptoconditions/master.svg + :target: https://travis-ci.org/bigchaindb/cryptoconditions + +.. image:: https://img.shields.io/codecov/c/github/bigchaindb/cryptoconditions/master.svg + :target: https://codecov.io/github/bigchaindb/cryptoconditions?branch=master + +.. image:: https://readthedocs.org/projects/cryptoconditions/badge/?version=latest + :target: http://cryptoconditions.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + +Crypto Conditions +================= + +Python implementation of **Crypto-Conditions**. See draft of specification at +`draft-thomas-crypto-conditions-02 `_. + +The RFC is also on github under +`rfcs/crypto-conditions `_. + +The Crypto-Conditions specification is part of the +`Interledger Protocol (ILP) `_. + + +Motivation +---------- + +We would like a way to describe a signed message such that multiple actors in a +distributed system can all verify the same signed message and agree on whether +it matches the description. + +This provides a useful primitive for distributed, event-based systems since we +can describe events (represented by signed messages) and therefore define +generic authenticated event handlers. + + +Installation +------------ +To install latest release that is on PyPI: + +.. code-block:: bash + + $ pip install cryptocondtions + +Or install from source: + +.. code-block:: bash + + $ pip install git+https://github.com/bigchaindb/cryptoconditions.git + + +Simple Usage +------------ +*Yet to be documented.* + +Documentation +------------- +http://cryptoconditions.readthedocs.io/ diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 0000000..e582053 --- /dev/null +++ b/docs/contributing.rst @@ -0,0 +1 @@ +.. include:: ../CONTRIBUTING.rst diff --git a/docs/examples.rst b/docs/examples.rst new file mode 100644 index 0000000..5a9934f --- /dev/null +++ b/docs/examples.rst @@ -0,0 +1,20 @@ +Examples +======== + +Preimage Sha 256 +---------------- + +.. code-block:: python + + >>> from cryptoconditions import PreimageSha256 + + >>> secret = b'Beware! Trying to understand crypto can lead to knowledge intoxications.' + + >>> fulfillment = PreimageSha256(preimage=secret) + + >>> fulfillment.condition_uri + 'ni:///sha-256;xumt48hVcQEXuUx2p2GqVgO4mpq9O_FIYmjb258CkZM?fpt=preimage-sha-256&cost=72' + + >>> fulfillment.condition_binary + b'\xa0%\x80 \xc6\xe9\xad\xe3\xc8Uq\x01\x17\xb9Lv\xa7a\xaaV\x03\xb8\x9a\x9a\xbd;\xf1Hbh\xdb\xdb\x9f\x02\x91\x93\x81\x01H' + diff --git a/docs/index.rst b/docs/index.rst index 18a4330..6ce63ed 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,19 +1,13 @@ -.. cryptoconditions documentation master file, created by - sphinx-quickstart on Tue Nov 1 16:28:51 2016. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to cryptoconditions's documentation! -============================================ - -Contents: +.. include:: ../README.rst .. toctree:: :maxdepth: 1 installation + usage + examples libref - + contributing Indices and tables diff --git a/docs/libref.rst b/docs/libref.rst index 2f9dd1d..3fd842f 100644 --- a/docs/libref.rst +++ b/docs/libref.rst @@ -34,59 +34,51 @@ Base Modules .. automodule:: cryptoconditions.exceptions -Types Modules -============= +Schemas Modules +=============== -``base_sha256`` ---------------- -.. automodule:: cryptoconditions.types.base_sha256 +``condition`` +------------- +.. automodule:: cryptoconditions.schemas.condition +``fulfillment`` +--------------- +.. automodule:: cryptoconditions.schemas.fulfillment -``ed25519`` ------------ -.. automodule:: cryptoconditions.types.ed25519 - :special-members: __init__ +``fingerprint`` +--------------- +.. automodule:: cryptoconditions.schemas.fingerprint -``inverted_threshold_sha256`` ------------------------------ -.. automodule:: cryptoconditions.types.inverted_threshold_sha256 - :special-members: __init__ +Types Modules +============= -``sha256`` ----------- -.. automodule:: cryptoconditions.types.sha256 +``base_sha256`` +--------------- +.. automodule:: cryptoconditions.types.base_sha256 -``threshold_sha256`` --------------------- -.. automodule:: cryptoconditions.types.threshold_sha256 +``preimage`` +------------ +.. automodule:: cryptoconditions.types.preimage -``timeout`` ------------ -.. automodule:: cryptoconditions.types.timeout +``prefix`` +------------ +.. automodule:: cryptoconditions.types.prefix -Lib Modules -=========== +``threshold`` +------------- +.. automodule:: cryptoconditions.types.threshold -``hasher`` ----------- -.. automodule:: cryptoconditions.lib.hasher - :special-members: __init__ -``predictor`` +``rsa`` ------------- -.. automodule:: cryptoconditions.lib.predictor - :special-members: __init__ +.. automodule:: cryptoconditions.types.rsa -``reader`` ----------- -.. automodule:: cryptoconditions.lib.reader - :special-members: __init__ -``writer`` ----------- -.. automodule:: cryptoconditions.lib.writer +``ed25519`` +----------- +.. automodule:: cryptoconditions.types.ed25519 :special-members: __init__ diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 0000000..d6f2a9e --- /dev/null +++ b/docs/usage.rst @@ -0,0 +1,128 @@ +Usage +===== +*Yet to be documented.* + + +ILP Format +---------- + +Condition +^^^^^^^^^ + +Conditions are URI encoded as: + +.. code-block:: text + + ni:///sha-256;?fpt=&cost=&subtypes= + +See https://tools.ietf.org/html/draft-thomas-crypto-conditions-02#section-9.1 +for details. + +Conditions are binary encoded as: + +.. code-block:: text + + Crypto-Conditions DEFINITIONS AUTOMATIC TAGS ::= BEGIN + + -- Conditions + + Condition ::= CHOICE { + preimageSha256 [0] SimpleSha256Condition, + prefixSha256 [1] CompoundSha256Condition, + thresholdSha256 [2] CompoundSha256Condition, + rsaSha256 [3] SimpleSha256Condition, + ed25519Sha256 [4] SimpleSha256Condition + } + + SimpleSha256Condition ::= SEQUENCE { + fingerprint OCTET STRING (SIZE(32)), + cost INTEGER (0..4294967295) + } + + CompoundSha256Condition ::= SEQUENCE { + fingerprint OCTET STRING (SIZE(32)), + cost INTEGER (0..4294967295), + subtypes ConditionTypes + } + + ConditionTypes ::= BIT STRING { + preImageSha256 (0), + prefixSha256 (1), + thresholdSha256 (2), + rsaSha256 (3), + ed25519Sha256 (4) + } + + END + +See https://tools.ietf.org/html/draft-thomas-crypto-conditions-02#section-7 +for details. + +Fulfillment +^^^^^^^^^^^ +There are no URI encoding rules for fulfillments. + +Fulfillments are binary encoded as: + +.. code-block:: text + + Crypto-Conditions DEFINITIONS AUTOMATIC TAGS ::= BEGIN + + -- Fulfillments + + Fulfillment ::= CHOICE { + preimageSha256 [0] PreimageFulfillment , + prefixSha256 [1] PrefixFulfillment, + thresholdSha256 [2] ThresholdFulfillment, + rsaSha256 [3] RsaSha256Fulfillment, + ed25519Sha256 [4] Ed25519Sha512Fulfillment + } + + PreimageFulfillment ::= SEQUENCE { + preimage OCTET STRING + } + + PrefixFulfillment ::= SEQUENCE { + prefix OCTET STRING, + maxMessageLength INTEGER (0..4294967295), + subfulfillment Fulfillment + } + + ThresholdFulfillment ::= SEQUENCE { + subfulfillments SET OF Fulfillment, + subconditions SET OF Condition + } + + RsaSha256Fulfillment ::= SEQUENCE { + modulus OCTET STRING, + signature OCTET STRING + } + + Ed25519Sha512Fulfillment ::= SEQUENCE { + publicKey OCTET STRING (SIZE(32)), + signature OCTET STRING (SIZE(64)) + } + + END + +See https://tools.ietf.org/html/draft-thomas-crypto-conditions-02#section-7.3 +for details. + +Condition Types +--------------- +*Yet to be documented.* + +Preimage-SHA-256 +^^^^^^^^^^^^^^^^ + +Prefix-SHA-256 +^^^^^^^^^^^^^^ + +THRESHOLD-SHA-256 +^^^^^^^^^^^^^^^^^ + +RSA-SHA-256 +^^^^^^^^^^^ + +ED25519-SHA-256 +^^^^^^^^^^^^^^^