1# generated by datamodel-codegen:
2# filename: cose_schema.json
3# version: 0.26.3
4
5from __future__ import annotations
6
7from enum import Enum
8from typing import Optional
9
10from pydantic import BaseModel, ConfigDict, Field, RootModel, StrictStr
11
12
13class Algorithm(str, Enum):
14 """The hashing function used to compute the hash value"""
15
16 SHA256 = "sha256"
17
18
19class PayloadHash(BaseModel):
20 """Specifies the hash algorithm and value for the content"""
21
22 model_config = ConfigDict(
23 populate_by_name=True,
24 )
25 algorithm: Algorithm = Field(
26 ...,
27 description="The hashing function used to compute the hash value",
28 )
29 value: StrictStr = Field(..., description="The hash value for the content")
30
31
32class EnvelopeHash(BaseModel):
33 """Specifies the hash algorithm and value for the COSE envelope"""
34
35 model_config = ConfigDict(
36 populate_by_name=True,
37 )
38 algorithm: Algorithm = Field(
39 ...,
40 description="The hashing function used to compute the hash value",
41 )
42 value: StrictStr = Field(..., description="The hash value for the envelope")
43
44
45class Data(BaseModel):
46 """Information about the content associated with the entry"""
47
48 model_config = ConfigDict(
49 populate_by_name=True,
50 )
51 payload_hash: Optional[PayloadHash] = Field(
52 default=None,
53 alias="payloadHash",
54 description="Specifies the hash algorithm and value for the content",
55 )
56 envelope_hash: Optional[EnvelopeHash] = Field(
57 default=None,
58 alias="envelopeHash",
59 description="Specifies the hash algorithm and value for the COSE envelope",
60 )
61 aad: Optional[str] = Field(
62 default=None,
63 description="Specifies the additional authenticated data required to verify the signature",
64 )
65
66
67class CoseV001Schema(BaseModel):
68 """Schema for cose object"""
69
70 model_config = ConfigDict(
71 populate_by_name=True,
72 )
73 message: Optional[str] = Field(default=None, description="The COSE Sign1 Message")
74 public_key: str = Field(
75 ...,
76 alias="publicKey",
77 description="The public key that can verify the signature",
78 )
79 data: Optional[Data] = Field(
80 default=None,
81 description="Information about the content associated with the entry",
82 )
83
84
85class CoseSchema(RootModel[CoseV001Schema]):
86 model_config = ConfigDict(
87 populate_by_name=True,
88 )
89 root: CoseV001Schema = Field(..., description="COSE for Rekord objects", title="COSE Schema")