# Proposed DID history format
The history consists of a set of JSON-formatted arrays. Each line is in the format:
[version hash, version ID, timestamp, params, data, proofs]
Within each line the properties are as follows:
version hash
: The hash corresponding to the current line. See version hash calculation.
version ID
: An incrementing integer value corresponding to the line index. The first line is index 1.
timestamp
: A timestamp associated with the current update. This must be formatted according to ISO8601 with the timezone offset included.
params
: A JSON object containing the parameters updated by the current line. See parameters.
data
: A JSON object containing the updates to the document state. See data updates.
proofs
: An array of proofs for the current update, used to establish key ownership as well as continuity from the previous state. See proofs.
## Parameters
There is currently one supported parameter.
method
: An identifier for the document versioning method. This will establish the calculation method for the self-certifying document identifier as well as the supported proof formats.
[Potential: `"deactivated": true`, `"status": "deactivated"`, or `"moved": URI`]
The first line of the history must establish the `method` parameter.
*Example (parameters only):*
{"method": "did:webnext:1"}
## Data updates
Each data update contains one of:
value
: Establishing the full contents of the document, or
patch
: Containing a JSON patch from the previous content of the document.
*Examples (data only):*
{"value": {"@context": ["https://www.w3.org/ns/did/v1", "https://w3id.org/security/data-integrity/v2", "https://w3id.org/security/multikey/v1"], "id": "did:webnext:example.com:menetsyqymts6yhpmtfebtym", "authentication": ["did:webnext:example.com:menetsyqymts6yhpmtfebtym#kbaEzdWJd6UFDcifYo158dh2mXysTB7INj51JcgpCqg"], "verificationMethod": [{"id": "did:webnext:example.com:menetsyqymts6yhpmtfebtym#kbaEzdWJd6UFDcifYo158dh2mXysTB7INj51JcgpCqg", "type": "Multikey", "controller": "did:webnext:example.com:menetsyqymts6yhpmtfebtym", "publicKeyMultibase": "z6Mkn4z9ze2ESZhWL2HKGdQcGFdT8dH5Ht9zDnBoiPJfANyz"}]}}
{"patch": [{"op": "add", "path": "/alsoKnownAs", "value": ["did:web:example.com"]}]}
The first line of the history must contain a `value` property.
## Version hash calculation
- Take the version hash of the previous line as `last hash`. For the first line, use the empty string ("").
- Calculate the raw digest as `SHA2-256(JCS([last hash, version ID, timestamp, params, data]))`
- Output version hash = `multibase(multihash(digest, "sha2-256"), "base58btc")`
Example:
hash input: JCS([
"zQmcPRLmBy5KwV74epZ9fvoEngjbukRphUdaZS1nxqKfM16",
2,
"2024-03-19T23:39:37Z",
{},
{"patch": [{"op": "add", "path": "/controller", "value": ["did:alt:controller"]}]},
])
output: zQmSMxhxGp1CQ6SL5vi1rSCRXXfR9RMkzPTLLVF26wEAztE
## Proofs
TBD
## Full example
(With invalid hashes)
["zQmNQFTHCUc1S3iiNoZ5TzPevXQqwfT1xuiuYsC4hrc97Kz", 1, "2024-03-25T18:51:50Z", {"method": "did:webnext:1", "id": "example.com:menetsyqymts6yhpmtfebtym"}, {"value": {"@context": ["https://www.w3.org/ns/did/v1", "https://w3id.org/security/data-integrity/v2", "https://w3id.org/security/multikey/v1"], "id": "did:webnext:example.com:menetsyqymts6yhpmtfebtym", "authentication": ["did:webnext:example.com:menetsyqymts6yhpmtfebtym#kbaEzdWJd6UFDcifYo158dh2mXysTB7INj51JcgpCqg"], "verificationMethod": [{"id": "did:webnext:example.com:menetsyqymts6yhpmtfebtym#kbaEzdWJd6UFDcifYo158dh2mXysTB7INj51JcgpCqg", "type": "Multikey", "controller": "did:webnext:example.com:menetsyqymts6yhpmtfebtym", "publicKeyMultibase": "z6Mkn4z9ze2ESZhWL2HKGdQcGFdT8dH5Ht9zDnBoiPJfANyz"}]}, [{"type": "DataIntegrityProof", "cryptosuite": "eddsa-jcs-2022", "verificationMethod": "did:webnext:example.com:menetsyqymts6yhpmtfebtym#did:webnext:example.com:menetsyqymts6yhpmtfebtym#kbaEzdWJd6UFDcifYo158dh2mXysTB7INj51JcgpCqg", "created": "2024-03-25T18:51:50Z", "challenge": "zQmNWMPLDMx3QyYtiNarjELQ9RCvHm1hAMHRrrrqNQ7kbvt", "proofPurpose": "authentication", "proofValue": "z4Por1indyg8WgytdzKkHD1FqWUfzPHrKsWvr5zn4r3bn6grLMP54ahfqQ9hPdYuTjSWeqjsTRF8M9ujnK2BzqcCG"}]]
["zQmbfhXs7E8FMJNNN2Gc98hDsUatAjZ53K7gdwWEKx5ZJWs", 2, "2024-03-25T18:51:50Z", {}, {"patch": [{"op": "add", "path": "/controller", "value": ["did:webnext:example.com:menetsyqymts6yhpmtfebtym", "did:example:controller"]}, {"op": "add", "path": "/verificationMethod/1", "value": {"id": "did:example:controller#tWMK1fLzevQaBJc_bl4vJ6waLI32bQwTIcVv9BXTiGA", "type": "Multikey", "controller": "did:example:controller", "publicKeyMultibase": "z6Mks2wuUH1sgBYUxnd48LV9TxS5fACun4ZdCAGy8ujRLzJx"}}, {"op": "add", "path": "/authentication/1", "value": "did:example:controller#tWMK1fLzevQaBJc_bl4vJ6waLI32bQwTIcVv9BXTiGA"}]}, [{"type": "DataIntegrityProof", "cryptosuite": "eddsa-jcs-2022", "verificationMethod": "did:webnext:example.com:menetsyqymts6yhpmtfebtym#did:example:controller#tWMK1fLzevQaBJc_bl4vJ6waLI32bQwTIcVv9BXTiGA", "created": "2024-03-25T18:51:50Z", "challenge": "zQmbfhXs7E8FMJNNN2Gc98hDsUatAjZ53K7gdwWEKx5ZJWs", "proofPurpose": "authentication", "proofValue": "zfr2rcCyQdvsy6ixvVkjFjB14Z3ncb2GqvPEGd49zG9WgJtM96HBoQVaTbs1MwtCcWq3szY28cw63SQ8nUxPDfyY"}]]
["zQmbbT3zAxR6vWibmzN9PxhM5e6kDRDTUsbhnwnP9tiFLbU", 3, "2024-03-25T18:51:50Z", {}, {"patch": [{"op": "add", "path": "/alsoKnownAs", "value": ["did:web:example.com"]}]}, [{"type": "DataIntegrityProof", "cryptosuite": "eddsa-jcs-2022", "verificationMethod": "did:webnext:example.com:menetsyqymts6yhpmtfebtym#did:webnext:example.com:menetsyqymts6yhpmtfebtym#kbaEzdWJd6UFDcifYo158dh2mXysTB7INj51JcgpCqg", "created": "2024-03-25T18:51:50Z", "challenge": "zQmbbT3zAxR6vWibmzN9PxhM5e6kDRDTUsbhnwnP9tiFLbU", "proofPurpose": "authentication", "proofValue": "z2j9sGp6aTxFZyMX7r8xYtbNJEw5gBGktdEj7M58G6FiC4FtugVUVZHWRdr1NZHhr7DsP7uVFXuf9PRbo3fGreouG"}]]