keri icon indicating copy to clipboard operation
keri copied to clipboard

Data model description

Open stevetodd opened this issue 4 years ago • 1 comments

In writing #86, I put together a pseudo code representation of the data model, which I will put here and then will reference there. We may want to use different notation in the spec, but this may be useful in composing kid0002:

// Notation Info
Foo(bar:int, baz:[Byte]) // data structure with bar int field and baz Byte array
Biz = Qux | Quux | Quuz // Biz is union type of Qux, Quux, Quuz
Corge(...Foo, grault:int) // Corge is composed of all the fields of Foo with the addition of grault

// Receipts
Receipt(...Message, ...EventCoordinatesWithDigest, a:EventCoordinatesWithDigest) 
// ^^^^ a:EventCoordinatesWithDigest must point to establishment event
//         (root) EventCoordinatesWithDigest point to receipted event

// Events
EstablishmentEvent(...Event, ...KeyConfig, ...WitnessConfig)
InceptionEvent(...EstablishmentEvent, c:[ConfigurationTrait])
RotationEvent(...EstablishmentEvent, a:[Seal])

DelegatedInceptionEvent(...InceptionEvent, da:EventCoordinatesWithPreviousDigest)
DelegatedRotationEvent(...RotationEvent, da:EventCoordinatesWithPreviousDigest)

KeyConfig(kt:SignatureThreshold, k:[PublicKey])
SignatureThreshold = integer | WeightedSignatureThreshold

WitnessConfig(wt:integer, w:[BasicPrefix])

ConfigurationTrait = EstablishmentEventsOnly | DoNotDelegate
Seal = Digest | MerkleTreeRoot | EventCoordinatesWithDigest

KeyEvent(...Message, ...EventCoordinatesWithPreviousDigest)

// Message
Message(v:Version, t:MessageType, signatures:[Signature])

// Common
EventCoordinatesWithDigest(...EventCoordinates, d:Digest)
EventCoordinatesWithPreviousDigest(...EventCoordinates, p:Digest)
EventCoordinates(i:Prefix, s:integer)

Prefix = BasicPrefix | SelfAddressedPrefix | SelfSignedPrefix
BasicPrefix = PublicKey
SelfAddressedPrefix = Digest
SelfSignedPrefix = Signature

Version(major:integer, minor:integer, format:Format, size:integer)

Format = JSON | CBOR | MessagePack

// Crypto Primatives
MerkleTreeRoot(rd:Digest)

Signature(algorithm:SignatureAlgorithm, data:[byte])
Digest(algorithm:DigestAlgorithm, data:[byte])

SignatureAlgorithm = ED25519|ED448|ECSECP256K1
DigestAlgorithm = BLAKE3|...(omitted)...

stevetodd avatar Jan 11 '21 19:01 stevetodd

being worked on in KID0002

chunningham avatar Mar 30 '21 15:03 chunningham