Skip to content

matcher

Thomas Fossati edited this page Jan 18, 2024 · 1 revision

Musings on pattern-matching Evidence

The Verifier's main function is to find patterns in Evidence that match known-good-values or known-bad-values, or some specific "state" that can be associated with metadata related to the Attester (i.e., CoRIM's endorsed values).

To "pattern match" Evidence, the Verifier needs:

  • A way to identify which Evidence claim needs to be matched
  • The comparison logic to be used in matching
  • The value(s) to compare against

It makes sense to encapsulate all that into a basic matcher object that can become a building block of higher-level constructs.

Given the variability of Evidence, such matcher needs to be assisted by an "attestation scheme"-specific function that identifies the claim in the Evidence Claims-Set that this matcher is describing.

matcher = [
    cmp: cmp
    values: values
]

claim-id = text / int

cmp = "in-set"   ; any
    / "in-range" ; sortable types
    / "masked"   ; bytes
    / "regexp"   ; text

values = [ + any ]

ref-value = [
    + matcher
]

end-value = [
    + matcher ; condition
    values ; endorsed-values
]
def match(ClaimsSet, RV, CTX)
    for rv in RV:
        tbcClaim = CTX.profile.claim_lookup(ClaimsSet, rv.cid)
        if not rv.cmp(tbcClaim, rv.vals):
            return false
    return true

Examples

CCA Realm

Single matcher, infinite combinations:

{
    "rim": {
        "cmp": "in-set",
        "values": [
            "3q0=",
            "vq8="
        ]
    },
    "rem": {
        "cmp": "in-set",
        "values": [
            [ "3q0=", "vq8=", "AAA=", "AAA=" ],
            [ "AAA=", "AAA=", "AAA=", "AAA=" ]
        ]
    },
    "perso": {
        "cmp": "regexp",
        "values": [
            "^coco-*$"
        ]
    }
}

SVN

{
    "svn": {
        "cmp": "in-range",
        "values": [
            { "min": 0, "max": 10 }
        ]
    }
}

Raw value

{
    "raw-value": {
        "cmp": "masked",
        "values": [
            {
                "bytes": "AAE=",
                "mask": "AQE="
            }
        ]
    }
}

Single value, memcmp(3)-like

{
    "rim": "3q0=",
    "rem": [ "AAA=", "AAA=", "AAA=", "AAA=" ]
}

RV

rv = { + claim-id => matcher }