{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/submission-attestation-v1.json",
  "title": "Submission Attestation Receipt, v1",
  "description": "Canonical schema for the Hive submission attestation receipt, canonical type submission.attestation. Every measurement instrument in the canon runs after an effect exists. A self reported figure in a filing, a forecast, or an interconnection request has no effect to measure yet, so nothing today fixes what was claimed at the moment it was claimed. This receipt fixes the figure set, the filer, the venue, the window the figures describe, and the declared basis of each figure, and recomputes that the submission instant fell before the window opened.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "payload_sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "sig_b64u": {
      "type": "string",
      "minLength": 1,
      "maxLength": 4096
    },
    "key_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "algorithm": {
      "type": "string",
      "const": "Ed25519"
    },
    "ts": {
      "type": "integer",
      "minimum": 0
    },
    "nonce_hex": {
      "type": "string",
      "pattern": "^[0-9a-f]{2,64}$"
    },
    "signed_body": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "receipt_type",
        "schema",
        "submission_id",
        "salt",
        "filer_ref",
        "venue_ref",
        "window",
        "submitted_at",
        "figures",
        "figure_set",
        "clock",
        "coverage",
        "verdict",
        "boundary"
      ],
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "submission.attestation"
        },
        "schema": {
          "type": "string",
          "const": "r1.0.0"
        },
        "submission_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$"
        },
        "salt": {
          "type": "object",
          "required": [
            "salt_commitment"
          ],
          "additionalProperties": false,
          "properties": {
            "salt_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          },
          "description": "Commitment to the disclosed submission salt. Filer, venue, and figure label commitments are keyed to it, so a figure label stays private until the filer discloses the salt."
        },
        "filer_ref": {
          "type": "object",
          "required": [
            "filer_commitment",
            "reference_class"
          ],
          "additionalProperties": false,
          "properties": {
            "filer_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "reference_class": {
              "type": "string",
              "enum": [
                "issuer_resolved",
                "caller_supplied",
                "asserted_without_source"
              ]
            }
          }
        },
        "venue_ref": {
          "type": "object",
          "required": [
            "venue_commitment"
          ],
          "additionalProperties": false,
          "properties": {
            "venue_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          },
          "description": "Commitment to the body the figures were submitted to."
        },
        "window": {
          "type": "object",
          "required": [
            "opens",
            "closes"
          ],
          "additionalProperties": false,
          "properties": {
            "opens": {
              "type": "object",
              "required": [
                "utc",
                "drift_seconds"
              ],
              "additionalProperties": false,
              "description": "Start of the future period the figures describe.",
              "properties": {
                "utc": {
                  "type": "string",
                  "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$"
                },
                "drift_seconds": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 86400
                }
              }
            },
            "closes": {
              "type": "object",
              "required": [
                "utc",
                "drift_seconds"
              ],
              "additionalProperties": false,
              "description": "End of the future period the figures describe.",
              "properties": {
                "utc": {
                  "type": "string",
                  "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$"
                },
                "drift_seconds": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 86400
                }
              }
            }
          }
        },
        "submitted_at": {
          "type": "object",
          "required": [
            "utc",
            "drift_seconds"
          ],
          "additionalProperties": false,
          "description": "Instant the figures were fixed and signed. Must equal the envelope signing timestamp.",
          "properties": {
            "utc": {
              "type": "string",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$"
            },
            "drift_seconds": {
              "type": "integer",
              "minimum": 0,
              "maximum": 86400
            }
          }
        },
        "figures": {
          "type": "array",
          "minItems": 1,
          "maxItems": 32,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "figure_commitment",
              "declared_value_scaled",
              "value_scale",
              "unit",
              "basis_class"
            ],
            "properties": {
              "figure_commitment": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "declared_value_scaled": {
                "type": "integer",
                "minimum": -1000000000000000,
                "maximum": 1000000000000000
              },
              "value_scale": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9
              },
              "unit": {
                "type": "string",
                "enum": [
                  "megawatt",
                  "megawatt_hour",
                  "ratio",
                  "count",
                  "month",
                  "usd_minor"
                ]
              },
              "basis_class": {
                "type": "string",
                "enum": [
                  "measured_history",
                  "engineering_estimate",
                  "third_party_study",
                  "management_forecast",
                  "unsupported"
                ]
              }
            }
          }
        },
        "figure_set": {
          "type": "object",
          "required": [
            "figures_commitment",
            "figure_count"
          ],
          "additionalProperties": false,
          "properties": {
            "figures_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "figure_count": {
              "type": "integer",
              "minimum": 1,
              "maximum": 32
            }
          }
        },
        "clock": {
          "type": "object",
          "required": [
            "anchor_class"
          ],
          "additionalProperties": false,
          "properties": {
            "anchor_class": {
              "type": "string",
              "enum": [
                "issuer_clock_only",
                "external_timestamp_anchor"
              ]
            },
            "anchor_digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        },
        "coverage": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "figure_set_relation",
            "precedence_relation",
            "basis_relation",
            "clock_relation"
          ],
          "properties": {
            "figure_set_relation": {
              "type": "string",
              "enum": [
                "reported_figures_equal_committed_set",
                "reported_figures_differ_from_committed_set"
              ]
            },
            "precedence_relation": {
              "type": "string",
              "enum": [
                "submission_before_window_open",
                "submission_after_window_open",
                "indeterminate"
              ]
            },
            "basis_relation": {
              "type": "string",
              "enum": [
                "every_figure_carries_a_supported_basis",
                "at_least_one_figure_unsupported"
              ]
            },
            "clock_relation": {
              "type": "string",
              "enum": [
                "issuer_clock_only",
                "external_timestamp_anchor"
              ]
            }
          }
        },
        "verdict": {
          "type": "string",
          "enum": [
            "attested_before_window",
            "window_already_open",
            "basis_unsupported",
            "figure_set_mismatch",
            "indeterminate"
          ]
        },
        "boundary": {
          "type": "string",
          "const": "Submission Attestation receipt. Attests that a set of self reported figures was fixed and signed at the recorded submission instant, before the window those figures describe opened, and that every figure carries a declared basis class. It does not attest that any figure is accurate, that the window later matched the figures, or that anything measured the figures, and when clock.anchor_class is issuer_clock_only the submission instant rests on the issuing service clock with no external time anchor."
        }
      }
    }
  }
}
