Skip to content

This repo contains the submission for the A.A. 2020-2023 Network Security and Cryptography course @ PoliMI

Notifications You must be signed in to change notification settings

AstroWLAN/CryptoConditions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Crypto Conditions

Project for the Network Security and Cryptography course A.Y. 2022/2023 @Polimi

Author 👨🏼‍💻 Link 🌍 Colaboratory 🧫 Version 📐 Language 🐍
Dario Crippa Paper Open In Colab 1.0.2 Python

Abstract 💭

Crypto conditions define a set of encoding formats and data structures used to describe conditions and fulfillments

Method for combining signature mechanisms and hash functions to create sophisticated signature arrangements that can self-validate based on specific conditions

These schemes are often adopted in the realm of blockchain and cryptocurrencies to create rules and standards for conducting transactions or manage smart contracts

Crypto conditions enable the definition of requirements that must be met before an operation or a transaction can be considered valid

Primitives like SHA256 or signature schemes such as Ed25519 can be used as logic gates to build intricate boolean circuits that can later be used as composite signatures

The term circuit refers to a set of logical and cryptographic operations that determine whether a given condition is satisfied

Condition 🔦

A condition $C$ represents the fingerprint of a particular circuit

In most cases it is the hash digest of the data that represents the condition

Agents can define a condition that must be satisfied in order for a particular action or transaction to occur

Each condition identifies a circuit composed of one or more logic gates that will be evaluated by validating a signature or checking the digest of an hash function

Condition ::= CHOICE {
   PreimageSHA256     [0]  SimpleSHA256Condition 
   PrefixSHA256       [1]  CompoundSHA256Condition
   ThresholdSHA256    [2]  CompoundSHA256Condition
   RSASHA256          [3]  SimpleSHA256Condition 
   Ed25519SHA256      [4]  SimpleSHA256Condition 
}

SimpleSHA256Condition 
Condition ::= SEQUENCE {
   fingerprint    OCTET STRING (size(32))
   cost           INTEGER
}

CompoundSHA256Condition 
Condition ::= SEQUENCE {
   fingerprint    OCTET STRING (size(32))
   cost           INTEGER
   subtypes       ConditionTypes
}

ConditionTypes ::= BIT STRING {
   PreimageSHA256     (0)
   PrefixSHA256       (1)
   ThresholdSHA256    (2)
   RSASHA256          (3)
   Ed25519SHA256      (4)
}

Fulfillment 📦

The fulfillment $F$ represents the input given to a circuit

Data structure that holds the information required to satisfy a condition

It constitutes the cryptographic proof or evidence provided to validate the condition

The internal structure depends on the crypto condition format chosen

Fulfillment ::= CHOICE {
    preimageSha256     [0]    PreimageFulfillment
    prefixSha256       [1]    PrefixFulfillment
    thresholdSha256    [2]    ThresholdFulfillment
    rsaSha256          [3]    RsaSha256Fulfillment
    ed25519Sha256      [4]    Ed25519Sha256Fulfillment
}

# EXAMPLES

PreimageSHA256
PreimageSHA256Fulfillment ::= SEQUENCE {
    preimage    OCTET STRING
}

ThresholdSHA256
ThresholdSHA256Fulfillment ::= SEQUENCE {
    subfulfillments    SET of fulfillments
    subconditions      SET of conditions
}

Ed25519SHA256
Ed25519Sha256Fulfillment ::= SEQUENCE {
    publicKey    OCTET STRING (size(32))
    signature    OCTET STRING (size(64))
}

Validation 🔑

A provided fulfillment is considered valid if it matches the fingerprint and if the circuit output is TRUE

Sometimes the circuit provides a signature mechanism and an input message must be included for evaluating the whole fulfillment

Acceptance of a fulfillment is dependent on it meeting the specified condition

Validation : Validate(C,F,optional : M) -> Boolean

Experiments 🧪

The Jupyter notebook contains some practical experiments done with various types of crypto conditions

About

This repo contains the submission for the A.A. 2020-2023 Network Security and Cryptography course @ PoliMI

Topics

Resources

Stars

Watchers

Forks