<?xml version="1.0" encoding="utf-8"?>
  <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
  <!-- generated by https://github.com/cabo/kramdown-rfc2629 version  -->

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC3447 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3447.xml">
<!ENTITY RFC4648 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4648.xml">
<!ENTITY I-D.draft-irtf-cfrg-eddsa-04 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml3/reference.I-D.draft-irtf-cfrg-eddsa-04.xml">
<!ENTITY RFC2119 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC3110 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3110.xml">
<!ENTITY RFC4871 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4871.xml">
]>

<?rfc toc="yes"?>
<?rfc sortrefs="yes"?>
<?rfc symrefs="yes"?>
<?rfc comments="yes"?>

<rfc docName="draft-thomas-crypto-conditions-00" category="std">

  <front>
    <title>Crypto-Conditions</title>

    <author initials="S." surname="Thomas" fullname="Stefan Thomas">
      <organization>Ripple</organization>
      <address>
        <postal>
          <street>300 Montgomery Street</street>
          <city>San Francisco</city>
          <region>CA</region>
          <code>94104</code>
          <country>US</country>
        </postal>
        <phone>-----------------</phone>
        <email>stefan@ripple.com</email>
        <uri>http://www.ripple.com</uri>
      </address>
    </author>

    <date year="2016" month="July" day="08"/>

    <area>security</area>
    
    

    <abstract>


<t>Crypto-conditions provide a mechanism 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 event-based systems that are distributed on the Internet since we can describe events in a standard deterministic manner (represented by signed messages) and therefore define generic authenticated event handlers.</t>



    </abstract>


    <note title="Feedback">


<t>This specification is a part of the <eref target="https://interledger.org/">Interledger Protocol</eref> work. Feedback related to this specification should be sent to <eref target="mailto:public-interledger@w3.org">public-interledger@w3.org</eref>.</t>


    </note>


  </front>

  <middle>


<section anchor="intro" title="Introduction">
<t>This specification describes a message format for defining distributable event descriptions (crypto-conditions) and the cryptographically verifiable event messages (fulfillments) that can be used to prove that the event occurred.</t>

<t>The specification defines both binary and string-based encoding for the messages.</t>

<section anchor="terminology" title="Terminology">
<t>The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in <xref target="RFC2119"></xref>.</t>

<t>Within this specification, the term “condition” refers to the hash of a description of a signed message.</t>

<t>The term “fulfillment” refers to a description of a signed message and a signed message that matches the description.</t>

<t>The description can be hashed and compared to a condition. If the message matches the description and the hash of the description matches the condition, we say that the fulfillment fulfills the condition.</t>

<t>A “hashlock” is a tuple consisting of a bytestring and its hash where the hash is published first and the publication of the corresponding bytestring acts as a one-bit, one-time signature. <!-- Q: What does this mean by "one-bit"? --></t>

</section>
<section anchor="features" title="Features">
<t>Crypto-conditions are a simple multi-algorithm, multi-level, multi-signature standard format for expressing conditions and fulfillments.</t>

<section anchor="multi-algorithm" title="Multi-Algorithm">
<t>Crypto-conditions can support several different signature and hash algorithms and support for new ones can be added in the future.</t>

<t>Implementations can state their supported algorithms simply by providing a bitmask. It is easy to verify that a given implementation will be able to verify the fulfillment to a given condition, by verifying that all bits that are set in the condition’s bitmask are also set in the implementation’s supported features bitmask.</t>

<t>Any new high bit can redefine the meaning of any existing lower bits when it is set. This can be used to remove obsolete algorithms.</t>

<t>The bitmask is encoded as a varint to minimize space usage.</t>

<t>By evaluating the bitmask of a condition actors in the system can establish, even before a fulfillment is published, if they will be able to verify the fulfilment.</t>

</section>
<section anchor="multi-signature" title="Multi-Signature">
<t>Crypto-conditions can abstract away many of the details of multi-sign. When a party provides a condition, other parties can treat it opaquely and do not need to know about its internal structure. That allows parties to define arbitrary multi-signature setups without breaking compatibility.</t>

<t>Protocol designers can use crypto-conditions as a drop-in replacement for public key signature algorithms and add multi-signature support to their protocols without adding any additional complexity.</t>

</section>
<section anchor="multi-level" title="Multi-Level">
<t>Basic multi-sign is single-level and does not support more complex trust relationships such as “I trust Alice and Bob, but only when Candice also agrees”. In single level 2-of-3 Alice and Bob could sign on their own, without Candice’s approval.</t>

<t>Crypto-conditions add that flexibility elegantly, by applying thresholds not just to signatures, but to conditions which can be signatures or further conditions. That allows the creation of an arbitrary threshold boolean circuit of signatures. <!-- Q: "boolean circuit of signatures"? --></t>

</section>
</section>
</section>
<section anchor="format" title="Format">

<section anchor="binary-encoding" title="Binary Encoding">

<t>An description of crypto-conditions is provided in this document using Abstract Syntax Notation One (ASN.1) as defined in <xref target="itu.X680.2015"></xref>. Implementations of this spec MUST support encoding and decoding using Octet Encoding Rules (OER) as defined in <xref target="itu.X696.2015"></xref>.</t>

</section>
<section anchor="string-types" title="String Types">

<t><list style="hanging">
  <t hangText='BASE10'>
  Variable-length integer encoded as a base-10 (decimal) number. Implementations MUST reject encodings that are too large for them to parse. Implementations MUST be tested for overflows.</t>
  <t hangText='BASE16'>
  Variable-length integer encoded as a base-16 (hexadecimal) number. Implementations MUST reject encodings that are too large for them to parse. Implementations MUST be tested for overflows. No leading zeros.</t>
  <t hangText='BASE64URL'>
  Base64-URL encoding. See <xref target="RFC4648"></xref> , Section 5.</t>
</list></t>

</section>
<section anchor="bitmask" title="Bitmask">
<t>Any system accepting crypto-conditions must be able to state its supported algorithms. It must be possible to verify that all algorithms used in a certain condition are indeed supported even if the fulfillment is not available yet.</t>

<t>In order to meet these design goals, we define a bitmask to express the supported primitives.</t>

<t>Each bit represents a different suite of features. Each type of condition depends on one or more feature suites. If an implementation supports all feature suites that a certain type depends on, the implementation MUST support that condition type. The list of known types and feature suites is the IANA maintained <xref target="crypto-conditions-type-registry">Crypto-Condition Type Registry</xref> .</t>

<t>Conditions contain a bitmask of types which they require the implementation to support. Implementations provide a bitmask of types they support.</t>

</section>
<section anchor="condition-format" title="Condition">
<t>Below are the string and binary encoding formats for a condition. In both, the featureBitmask is the boolean OR of the feature suite bitmasks of the top-level condition type and all subcondition types, recursively.</t>

<section anchor="string-condition-format" title="String Format">

<t>Conditions are ASCII encoded as:</t>

<figure><artwork><![CDATA[
"cc:" BASE16(type) ":" BASE16(featureBitmask) ":"
    BASE64URL(fingerprint) ":" BASE10(maxFulfillmentLength)
]]></artwork></figure>

</section>
<section anchor="binary-condition-format" title="Binary Format">

<t>Conditions are binary encoded as:</t>

<figure><artwork><![CDATA[
Condition ::= SEQUENCE {
  type ConditionType,
  featureBitmask OCTET STRING,
  fingerprint OCTET STRING,
  maxFulfillmentLength INTEGER (0..MAX)
}

ConditionType ::= INTEGER {
  preimageSha256(0),
  rsaSha256(1),
  prefixSha256(2),
  thresholdSha256(3),
  ed25519(4)
} (0..65535)
]]></artwork></figure>

</section>
<section anchor="condition-format-fields" title="Fields">

<t><list style="hanging">
  <t hangText='type'>
  is the numeric type identifier representing the condition type.</t>
  <t hangText='featureBitmask'>
  is an octet string encoding the set of feature suites an implementation must support in order to be able to successfully parse the fulfillment to this condition.</t>
  <t hangText='fingerprint'>
  is an octet string uniquely representing the condition with respect to other conditions of the same type. Implementations which index conditions MUST use the entire string or binary encoded condition as the key, not just the fingerprint - as different conditions of different types may have the same fingerprint. The length and contents of the fingerprint are defined by the condition type. For most condition types, the fingerprint is a cryptographically secure hash of the data which defines the condition, such as a public key.</t>
  <t hangText='maxFulfillmentLength'>
  is the maximum length of the fulfillment payload that can fulfill this condition. When a crypto-condition is submitted to an implementation, this implementation MUST verify that it will be able to process a fulfillment with a payload of size maxFulfillmentLength.</t>
</list></t>

</section>
</section>
<section anchor="fulfillment-format" title="Fulfillment">
<t>Below are the string and binary encoding formats for a fulfillment.</t>

<section anchor="string-fulfillment-format" title="String Format">

<t>Fulfillments are ASCII encoded as:</t>

<figure><artwork><![CDATA[
"cf:" BASE16(type) ":" BASE64URL(payload)
]]></artwork></figure>

</section>
<section anchor="binary-fulfillment-format" title="Binary Format">

<t>Fulfillments are binary encoded as:</t>

<figure><artwork><![CDATA[
Fulfillment ::= SEQUENCE {
  type ConditionType,
  payload OCTET STRING
}
]]></artwork></figure>

</section>
<section anchor="fulfillment-format-fields" title="Fields">

<t><list style="hanging">
  <t hangText='type'>
  is the numeric type identifier representing the condition type. For some condition types the fulfillment will contain further subfulfillments, however the type field always represents the outermost, or top-level, type.</t>
  <t hangText='payload'>
  The payload is an octet string whose internal format is defined by each of the types.</t>
</list></t>

</section>
</section>
</section>
<section anchor="feature-suites" title="Feature Suites">
<t>The following feature suites are defined in this version of the specification. New feature suites may be defined in the future and will be registered in the IANA maintained <xref target="crypto-conditions-type-registry">Crypto-Condition Type Registry</xref></t>

<t>Support for a condition type MUST depend on one or more feature suites. Future versions of this spec MAY introduce new feature bits and condition types. However, all new condition types MUST depend on at least one of the new feature suites. This ensures that all previously created implementations correctly recognize that they do not support the new type.</t>

<t>Feature suites are chosen such that they represent reasonable clusters of functionality. For instance, it is reasonable to require that an implementation which supports SHA-256 in one context MUST support it in all contexts, since it already needed to implement the algorithm.</t>

<t>An implementation which supports a certain set of feature suites MUST accept all condition types which depend only on that set or any subset of feature suites.</t>

<section anchor="sha-256-feature-suite" title="SHA-256">
<t>SHA-256 is a hashing algorithm and is assigned the feature bit 2^0 = 0x01.</t>

</section>
<section anchor="preimage-feature-suite" title="PREIMAGE">
<t>PREIMAGE refers to hashlock conditions and is assigned the feature bit 2^1 = 0x02.</t>

<t>A preimage condition is the hash of its own fulfillment. In order to fulfill a preimage condition, a valid preimage must be provided.</t>

<t>Preimage conditions can be used as a so-called hashlock. Since cryptographically secure hashing functions are preimage-resistant, only the original creator of a preimage condition can feasibly produce the preimage if it contains a large amount of random entropy.</t>

</section>
<section anchor="prefix-feature-suite" title="PREFIX">
<t>PREFIX is a structural condition and is assigned the feature bit 2^2 = 0x04.</t>

<t>A prefix condition condition contains exactly one subcondition. When validated it simply prepends the message to be validated with a constant string before passing it on to the subcondition’s validation function.</t>

</section>
<section anchor="threshold-feature-suite" title="THRESHOLD">
<t>THRESHOLD is a structural condition and is assigned the feature bit 2^3 = 0x08.</t>

<t>Threshold conditions provide a way to create m-of-n threshold combinations of other conditions such that m of the n subconditions have to be fulfilled in order for the threshold condition to be fulfilled.</t>

<t>Weights are also supported which allow one subcondition to count as multiple fulfilled subconditions towards the threshold.</t>

</section>
<section anchor="rsa-pss-feature-suite" title="RSA-PSS">
<t>RSA-PSS is a signature algorithm and is assigned the feature bit 2^4 = 0x10.</t>

</section>
<section anchor="ed25519-feature-suite" title="ED25519">
<t>ED25519 is a signature algorithm and is assigned the feature bit 2^5 = 0x20.</t>

<t>ED25519 is a compact elliptic curve based signature algorithm.</t>

</section>
</section>
<section anchor="condition-types" title="Condition Types">
<t>The following condition types are defined in this version of the specification. New types may be defined in the future and will be registered in the IANA maintained <xref target="crypto-conditions-type-registry">Crypto-Condition Type Registry</xref></t>

<section anchor="preimage-sha-256-condition-type" title="PREIMAGE-SHA-256">
<t>PREIMAGE-SHA-256 is assigned the type ID 0. It relies on the SHA-256 and PREIMAGE feature suites which corresponds to a feature bitmask of 0x03.</t>

<t>This type of condition is also called a hashlock. By creating a hash of a difficult-to-guess 256-bit random or pseudo-random integer it is possible to create a condition which the creator can trivially fulfill by publishing the random value. However, for anyone else, the condition is cryptgraphically hard to fulfill, because they would have to find a preimage for the given condition hash.</t>

<t>Bitcoin supports this type of condition via the OP_HASH256 operator.</t>

<section anchor="preimage-sha-256-condition-type-condition" title="Condition">
<t>The fingerprint of a PREIMAGE-SHA-256 condition is the SHA-256 hash of the preimage.</t>

</section>
<section anchor="preimage-sha-256-condition-type-fulfillment" title="Fulfillment">
<t>The fulfillment payload of a PREIMAGE-SHA-256 condition is the preimage.</t>

</section>
</section>
<section anchor="prefix-sha-256-condition-type" title="PREFIX-SHA-256">
<t>PREFIX-SHA-256 is assigned the type ID 1. It relies on the SHA-256 and PREFIX feature suites which corresponds to a feature bitmask of 0x05.</t>

<t>Prefix conditions provide a way to effective narrow the scope of other conditions. A condition can be used as the fingerprint of a public key to sign an arbitrary message. By creating a prefix subcondition we can narrow the scope from signing an arbitrary message to signing a message with a specific prefix.</t>

<t>When a prefix fulfillment is validated against a message, it will prepend the prefix to the provided message and will use the result as the message to validate against the subfulfillment.</t>

<section anchor="prefix-sha-256-condition-type-condition" title="Condition">
<t>The fingerprint of a PREFIX-SHA-256 condition is the SHA-256 digest of the fingerprint contents given below:</t>

<figure><artwork><![CDATA[
PrefixSha256FingerprintContents ::= SEQUENCE {
  prefix OCTET STRING,
  condition Condition
}
]]></artwork></figure>

<t><list style="hanging">
  <t hangText='prefix'>
  is an arbitrary octet string which will be prepended to the message during validation.</t>
  <t hangText='condition'>
  is the subcondition which the subfulfillment must match.</t>
</list></t>

</section>
<section anchor="prefix-sha-256-condition-type-fulfillment" title="Fulfillment">

<figure><artwork><![CDATA[
PrefixSha256FulfillmentPayload ::= SEQUENCE {
  prefix OCTET STRING,
  subfulfillment Fulfillment
}
]]></artwork></figure>

<t><list style="hanging">
  <t hangText='prefix'>
  is an arbitrary octet string which will be prepended to the message during validation.</t>
  <t hangText='subfulfillment'>
  is the fulfilled subcondition.</t>
</list></t>

</section>
</section>
<section anchor="threshold-sha-256-condition-type" title="THRESHOLD-SHA-256">
<t>THRESHOLD-SHA-256 is assigned the type ID 2. It relies on the SHA-256 and THRESHOLD feature suites which corresponds to a feature bitmask of 0x09.</t>

<section anchor="threshold-sha-256-condition-type-condition" title="Condition">
<t>The fingerprint of a THRESHOLD-SHA-256 condition is the SHA-256 digest of the fingerprint contents given below:</t>

<figure><artwork><![CDATA[
ThresholdSha256FingerprintContents ::= SEQUENCE {
  threshold INTEGER (0..4294967295),
  subconditions SEQUENCE OF ThresholdSubcondition
}

ThresholdSubcondition ::= SEQUENCE {
  weight INTEGER (0..4294967295),
  condition Condition
}
]]></artwork></figure>

<t>The list of conditions is sorted first based on length, shortest first. Elements of the same length are sorted in lexicographic (big-endian) order, smallest first.</t>

<t><list style="hanging">
  <t hangText='threshold'>
  threshold MUST be an integer in the range 1 … 2^32 - 1. In order to fulfill a threshold condition, the weights of the provided fulfillments MUST be greater than or equal to the threshold.</t>
  <t hangText='subconditions'>
  is the set of subconditions, each provided as a tuple of weight and condition.</t>
  <t hangText='weight'>
  is the numeric weight of this subcondition, i.e. how many times it counts against the threshold.</t>
  <t hangText='condition'>
  is the subcondition.</t>
</list></t>

</section>
<section anchor="threshold-sha-256-condition-type-fulfillment" title="Fulfillment">

<figure><artwork><![CDATA[
ThresholdSha256FulfillmentPayload ::= SEQUENCE {
  threshold INTEGER (0..4294967295),
  subfulfillments SEQUENCE OF ThresholdSubfulfillment
}

ThresholdSubfulfillment ::= SEQUENCE {
  weight INTEGER (0..4294967295) DEFAULT 1,
  condition Condition OPTIONAL,
  fulfillment Fulfillment OPTIONAL
}
]]></artwork></figure>

<t><list style="hanging">
  <t hangText='threshold'>
  is a number and MUST be an integer in the range 1 … 2^32 - 1. In order to fulfill a threshold condition, the weights of the provided fulfillments MUST be greater than or equal to the threshold.</t>
  <t hangText='subfulfillments'>
  is the set of subconditions and subfulfillments, each provided as a tuple of weight and condition or fulfillment.</t>
  <t hangText='weight'>
  is the numeric weight of this subcondition, i.e. how many times it counts against the threshold. It MUST be an integer in the range 1 … 2^32 - 1.</t>
  <t hangText='condition'>
  is the subcondition if this subcondition is not fulfilled.</t>
  <t hangText='fulfillment'>
  is the subfulfillment if this subcondition is fulfilled.</t>
</list></t>

</section>
</section>
<section anchor="rsa-sha-256-condition-type" title="RSA-SHA-256">
<t>RSA-SHA-256 is assigned the type ID 3. It relies on the SHA-256 and RSA-PSS feature suites which corresponds to a feature bitmask of 0x11.</t>

<t>The signature algorithm used is RSASSA-PSS as defined in PKCS#1 v2.2. <xref target="RFC3447"></xref></t>

<section anchor="rsa-sha-256-condition-type-condition" title="Condition">
<t>The fingerprint of a RSA-SHA-256 condition is the SHA-256 digest of the fingerprint contents given below:</t>

<t>The salt length for PSS is 32 bytes.</t>

<figure><artwork><![CDATA[
RsaSha256FingerprintContents ::= SEQUENCE {
  modulus OCTET STRING (SIZE(128..512))
}
]]></artwork></figure>

<t><list style="hanging">
  <t hangText='modulus'>
  is an octet string representing the RSA public modulus in big-endian byte order. The first byte of the modulus MUST NOT be zero.</t>
  <t>The corresponding public exponent e is assumed to be 65537 as recommended in <xref target="RFC4871"></xref> . Very large exponents can be a DoS vector <xref target="LARGE-RSA-EXPONENTS"></xref> and 65537 is the largest Fermat prime, which has some nice properties <xref target="USING-RSA-EXPONENT-OF-65537"></xref> .</t>
  <t>Implementations MUST reject moduli smaller than 128 bytes (1017 bits) or greater than 512 bytes (4096 bits.) Large moduli slow down signature verification which can be a denial-of-service vector. DNSSEC also limits the modulus to 4096 bits <xref target="RFC3110"></xref> . OpenSSL supports up to 16384 bits <xref target="OPENSSL-X509-CERT-EXAMPLES"></xref> .</t>
</list></t>

</section>
<section anchor="rsa-sha-256-condition-type-fulfillment" title="Fulfillment">

<figure><artwork><![CDATA[
RsaSha256FulfillmentPayload ::= SEQUENCE {
  modulus OCTET STRING (SIZE(128..512)),
  signature OCTET STRING (SIZE(128..512))
}
]]></artwork></figure>

<t><list style="hanging">
  <t hangText='modulus'>
  is an octet string representing the RSA public modulus in big-endian byte order. See <xref target="rsa-sha-256-condition-type-condition"></xref></t>
  <t hangText='signature'>
  is an octet string representing the RSA signature. It MUST be encoded in big-endian byte order with the exact same number of octets as the modulus, even if this means adding leading zeros. This ensures that the fulfillment size is constant and known ahead of time. Note that the field is still binary encoded with a length prefix for consistency.</t>
  <t>Implementations MUST verify that the signature and modulus consist of the same number of octets and that the signature is numerically less than the modulus.</t>
</list></t>

<t>The message to be signed is provided separately. If no message is provided, the message is assumed to be an octet string of length zero.</t>

</section>
<section anchor="rsa-sha-256-condition-type-implementation" title="Implementation">
<t>The recommended modulus size as of 2016 is 2048 bits <xref target="KEYLENGTH-RECOMMENDATION"></xref> . In the future we anticipate an upgrade to 3072 bits which provides approximately 128 bits of security <xref target="NIST-KEYMANAGEMENT"></xref> (p. 64), about the same level as SHA-256.</t>

</section>
</section>
<section anchor="ed25519-condition-type" title="ED25519">
<t>ED25519 is assigned the type ID 4. It relies only on the ED25519 feature suite which corresponds to a bitmask of 0x20.</t>

<t>The exact algorithm and encodings used for public key and signature are defined in <xref target="I-D.irtf-cfrg-eddsa"></xref> as Ed25519. SHA-512 is used as the hashing function.</t>

<t>Note: This document is not defining the SHA-512 versions of other condition types. In addition, the Ed25519 condition type is already uniquely identified by a corresponding Ed25519 feature suite. Therefore we intentionally do not introduce a SHA-512 feature suite in this document.</t>

<section anchor="ed25519-condition-type-condition" title="Condition">
<t>The fingerprint of a ED25519 condition is the 32 byte Ed25519 public key. Since the public key is already very small, we do not hash it.</t>

</section>
<section anchor="ed25519-condition-type-fulfillment" title="Fulfillment">

<figure><artwork><![CDATA[
Ed25519FulfillmentPayload ::= SEQUENCE {
  publicKey OCTET STRING (SIZE(32)),
  signature OCTET STRING (SIZE(64))
}
]]></artwork></figure>

<t><list style="hanging">
  <t hangText='publicKey'>
  is an octet string containing the Ed25519 public key.</t>
  <t hangText='signature'>
  is an octet string containing the Ed25519 signature.</t>
</list></t>

</section>
</section>
</section>


  </middle>

  <back>

    <references title='Normative References'>

&RFC3447;
&RFC4648;
&I-D.draft-irtf-cfrg-eddsa-04;
<reference anchor="itu.X680.2015" target="http://www.itu.int/rec/T-REC-X.680-201508-I/">
  <front>
    <title>Information technology – Abstract Syntax Notation One (ASN.1): Specification of basic notation</title>
    <author >
      <organization>International Telecommunications Union</organization>
    </author>
    <date year="n.d."/>
  </front>
</reference>
<reference anchor="itu.X696.2015" target="http://handle.itu.int/11.1002/1000/12487">
  <front>
    <title>Information technology – ASN.1 encoding rules: Specification of Octet Encoding Rules (OER)</title>
    <author >
      <organization>International Telecommunications Union</organization>
    </author>
    <date year="n.d."/>
  </front>
</reference>


    </references>

    <references title='Informative References'>

&RFC2119;
&RFC3110;
&RFC4871;
<reference anchor="LARGE-RSA-EXPONENTS" target="https://www.imperialviolet.org/2012/03/17/rsados.html">
  <front>
    <title>Imperial Violet - Very large RSA public exponents (17 Mar 2012)</title>
    <author fullname="Adam Langley">
      <organization></organization>
    </author>
    <date year="2012" month="March" day="17"/>
  </front>
</reference>
<reference anchor="USING-RSA-EXPONENT-OF-65537" target="http://crypto.stackexchange.com/questions/3110/impacts-of-not-using-rsa-exponent-of-65537">
  <front>
    <title>Cryptography - StackExchange - Impacts of not using RSA exponent of 65537</title>
    <author fullname="http://crypto.stackexchange.com/users/555/fgrieu">
      <organization></organization>
    </author>
    <date year="2014" month="November" day="18"/>
  </front>
</reference>
<reference anchor="KEYLENGTH-RECOMMENDATION" target="https://www.keylength.com/en/compare/">
  <front>
    <title>BlueKrypt - Cryptographic Key Length Recommendation</title>
    <author fullname="Damien Giry">
      <organization></organization>
    </author>
    <date year="2015" month="September" day="17"/>
  </front>
</reference>
<reference anchor="NIST-KEYMANAGEMENT" target="http://csrc.nist.gov/publications/nistpubs/800-57/sp800-57_part1_rev3_general.pdf">
  <front>
    <title>NIST - Recommendation for Key Management - Part 1 - General (Revision 3)</title>
    <author fullname="Elaine Barker">
      <organization></organization>
    </author>
    <author fullname="William Barker">
      <organization></organization>
    </author>
    <author fullname="William Burr">
      <organization></organization>
    </author>
    <author fullname="William Polk">
      <organization></organization>
    </author>
    <author fullname="Miles Smid">
      <organization></organization>
    </author>
    <date year="2012" month="July"/>
  </front>
</reference>
<reference anchor="OPENSSL-X509-CERT-EXAMPLES" target="http://fm4dd.com/openssl/certexamples.htm">
  <front>
    <title>OpenSSL - X509 certificate examples for testing and verification</title>
    <author fullname="FM4DD">
      <organization></organization>
    </author>
    <date year="2012" month="July"/>
  </front>
</reference>


    </references>


<section anchor="security-considerations" title="Security Considerations">

<t>TODO</t>

</section>
<section anchor="test-values" title="Test Values">

<t>TODO</t>

</section>
<section anchor="appendix-c" title="ASN.1 Module">

<figure><artwork><![CDATA[
--<ASN1.PDU CryptoConditions.Condition, CryptoConditions.Fulfillment>--

CryptoConditions
DEFINITIONS
AUTOMATIC TAGS ::=
BEGIN

/**
* CONTAINERS
*/

Condition ::= SEQUENCE {
type ConditionType,
featureBitmask OCTET STRING,
fingerprint OCTET STRING,
maxFulfillmentLength INTEGER (0..MAX)
}

Fulfillment ::= SEQUENCE {
type ConditionType,
payload OCTET STRING
}

ConditionType ::= INTEGER {
preimageSha256(0),
rsaSha256(1),
prefixSha256(2),
thresholdSha256(3),
ed25519(4)
} (0..65535)

/**
* FULFILLMENT PAYLOADS
*/

-- For preimage conditions, the payload equals the preimage

PrefixSha256FulfillmentPayload ::= SEQUENCE {
prefix OCTET STRING,
subfulfillment Fulfillment
}

ThresholdSha256FulfillmentPayload ::= SEQUENCE {
threshold INTEGER (0..4294967295),
subfulfillments SEQUENCE OF ThresholdSubfulfillment
}

ThresholdSubfulfillment ::= SEQUENCE {
weight INTEGER (0..4294967295) DEFAULT 1,
condition Condition OPTIONAL,
fulfillment Fulfillment OPTIONAL
}

RsaSha256FulfillmentPayload ::= SEQUENCE {
modulus OCTET STRING (SIZE(128..512)),
signature OCTET STRING (SIZE(128..512))
}

Ed25519FulfillmentPayload ::= SEQUENCE {
publicKey OCTET STRING (SIZE(32)),
signature OCTET STRING (SIZE(64))
}

/**
* FINGERPRINTS
*/

-- SHA-256 hash of the fingerprint contents
Sha256Fingerprint ::= OCTET STRING (SIZE(32)) -- digest

-- 32-byte Ed25519 public key
Ed25519Fingerprint ::= OCTET STRING (SIZE(32)) -- publicKey

/**
* FINGERPRINT CONTENTS
*
* The content that will be hashed to arrive at the fingerprint.
*/

-- The preimage type hashes the raw contents of the preimage

PrefixSha256FingerprintContents ::= SEQUENCE {
prefix OCTET STRING,
condition Condition
}

ThresholdSha256FingerprintContents ::= SEQUENCE {
threshold INTEGER (0..4294967295),
subconditions SEQUENCE OF ThresholdSubcondition
}

ThresholdSubcondition ::= SEQUENCE {
weight INTEGER (0..4294967295),
condition Condition
}

RsaSha256FingerprintContents ::= INTEGER (0..MAX) -- modulus

/**
* EXAMPLES
*/

exampleCondition Condition ::=
{
type preimageSha256,
featureBitmask '03'H,
fingerprint '
E3B0C442 98FC1C14 9AFBF4C8 996FB924 27AE41E4 649B934C A495991B 7852B855
'H,
maxFulfillmentLength 2
}

exampleFulfillment Fulfillment ::=
{
type preimageSha256,
payload '00'H
}

exampleRsaSha256FulfillmentPayload RsaSha256FulfillmentPayload ::=
{
modulus '
B30E7A93 8783BABF 836850FF 49E14F87 E3F92D5C 46E33FEC A3E4F0B2 2358580B
11765995 F4B8EEA7 FB4712C2 E1E316F7 F775A953 D232216A 169D9A64 DDC00712
0A400B37 F2AFC077 B62FE304 DE74DE6A 119EC407 6B529C4F 6096B0BA AD4F533D
F0173B9B 822FD85D 65FA4BEF A92D8F52 4F69CBCA 0136BD80 D095C169 AEC0E095
'H,
signature '
48E8945E FE007556 D5BF4D5F 249E4808 F7307E29 511D3262 DAEF61D8 8098F9AA
4A8BC062 3A8C9757 38F65D6B F459D543 F289D73C BC7AF4EA 3A33FBF3 EC444044
7911D722 94091E56 1833628E 49A772ED 608DE6C4 4595A91E 3E17D6CF 5EC3B252
8D63D2AD D6463989 B12EEC57 7DF64709 60DF6832 A9D84C36 0D1C217A D64C8625
BDB594FB 0ADA086C DECBBDE5 80D424BF 9746D2F0 C312826D BBB00AD6 8B52C4CB
7D47156B A35E3A98 1C973863 792CC80D 04A18021 0A524158 65B64B3A 61774B1D
3975D78A 98B0821E E55CA0F8 6305D425 29E10EB0 15CEFD40 2FB59B2A BB8DEEE5
2A6F2447 D2284603 D219CD4E 8CF9CFFD D5498889 C3780B59 DD6A57EF 7D732620
'H
}

exampleEd25519FulfillmentPayload Ed25519FulfillmentPayload ::=
{
publicKey '
EC172B93 AD5E563B F4932C70 E1245034 C35467EF 2EFD4D64 EBF81968 3467E2BF
'H,
signature '
B62291FA D9432F8F 298B9C4A 4895DBE2 93F6FFDA 1A68DADF 0CCDEF5F 47A0C721
2A5FEA3C DA97A3F4 C03EA9F2 E8AC1CEC 86A51D45 2127ABDB A09D1B6F 331C070A
'H
}

END
]]></artwork></figure>

</section>
<section anchor="acknowledgements" title="Acknowledgements">

<t>The editor would like to thank the following individuals for feedback on and implementations of the specification (in alphabetical order): TODO</t>

</section>
<section anchor="appendix-e" title="IANA Considerations">

<section anchor="crypto-conditions-type-registry" title="Crypto-Condition Type Registry">

<t>The following initial entries should be added to the Crypto-Condition Type registry to be created and maintained at (the suggested URI)
<eref target="http://www.iana.org/assignments/crypto-condition-types">http://www.iana.org/assignments/crypto-condition-types</eref>:</t>

<t>The following feature suite bits are registered:</t>

<texttable title="Crypto-Condition Feature Suites" anchor="crypto-condition-feature-suites">
      <ttcol align='left'>Type Bit</ttcol>
      <ttcol align='left'>Exp.</ttcol>
      <ttcol align='left'>Hex</ttcol>
      <ttcol align='left'>Condition Types</ttcol>
      <c>1</c>
      <c>2^0</c>
      <c>0x01</c>
      <c>SHA-256</c>
      <c>10</c>
      <c>2^1</c>
      <c>0x02</c>
      <c>PREIMAGE</c>
      <c>100</c>
      <c>2^2</c>
      <c>0x04</c>
      <c>PREFIX</c>
      <c>1000</c>
      <c>2^3</c>
      <c>0x08</c>
      <c>THRESHOLD</c>
      <c>10000</c>
      <c>2^4</c>
      <c>0x10</c>
      <c>RSA</c>
      <c>100000</c>
      <c>2^5</c>
      <c>0x20</c>
      <c>ED25519</c>
</texttable>

<t>The following types are registered:</t>

<texttable title="Crypto-Condition Types" anchor="crypto-condition-types">
      <ttcol align='left'>Type ID</ttcol>
      <ttcol align='left'>Required Bitmask</ttcol>
      <ttcol align='left'>Type Name</ttcol>
      <c>0</c>
      <c>0x03</c>
      <c>PREIMAGE-SHA-256</c>
      <c>1</c>
      <c>0x05</c>
      <c>PREFIX-SHA-256</c>
      <c>2</c>
      <c>0x09</c>
      <c>THRESHOLD-SHA-256</c>
      <c>3</c>
      <c>0x11</c>
      <c>RSA-SHA-256</c>
      <c>4</c>
      <c>0x20</c>
      <c>ED25519</c>
</texttable>

</section>
</section>


  </back>
</rfc>

