Longfellow ZK 0290cb32

Loading...
Searching...
No Matches
mdoc_constants.h
1// Copyright 2025 Google LLC.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef PRIVACY_PROOFS_ZK_LIB_CIRCUITS_MDOC_MDOC_CONSTANTS_H_
16#define PRIVACY_PROOFS_ZK_LIB_CIRCUITS_MDOC_MDOC_CONSTANTS_H_
17
18#include <stddef.h>
19#include <stdint.h>
20
21 namespace proofs {
22
23/* Max number of SHA blocks to process. */
24 constexpr static const size_t kMaxSHABlocks = 35;
25
26/* Number of bits in CBOR index. Must be large enough to index into MDOC.*/
27 constexpr static const size_t kCborIndexBits = 12;
28
29// This is the prefix added to the D8... mdoc encoding to produce
30// a COSE1 encoding that is ready to be hashed.
31 static constexpr uint8_t kCose1Prefix[18] = {
32 0x84, 0x6A, 0x53, 0x69, 0x67, 0x6E, 0x61, 0x74, 0x75,
33 0x72, 0x65, 0x31, 0x43, 0xA1, 0x01, 0x26, 0x40, 0x59,
34};
35 static constexpr size_t kCose1PrefixLen = 18;
36
37/* Max size of an MSO that hashes using < MAX SHA blocks. */
38 constexpr static const size_t kMaxMsoLen =
39 kMaxSHABlocks * 64 - 9 - kCose1PrefixLen;
40
41 static constexpr size_t kValidityInfoLen = 12;
42 static constexpr size_t kValidFromLen = 9;
43 static constexpr size_t kDeviceKeyLen = 9;
44 static constexpr size_t kDeviceKeyInfoLen = 13;
45 static constexpr size_t kValidUntilLen = 10;
46 static constexpr size_t kValueDigestsLen = 12;
47 static constexpr size_t kOrgLen = 17;
48
49 static constexpr uint8_t kTag32[] = {0x58, 0x20};
50 static constexpr size_t kIdLen = 32;
51 static constexpr size_t kValueLen = 64;
52
53 static constexpr uint8_t kValidityInfoID[kValidityInfoLen] = {
54 'v', 'a', 'l', 'i', 'd', 'i', 't', 'y', 'I', 'n', 'f', 'o'};
55
56 static constexpr uint8_t kValidFromID[kValidFromLen] = {'v', 'a', 'l', 'i', 'd',
57 'F', 'r', 'o', 'm'};
58
59 static constexpr uint8_t kValidUntilID[kValidUntilLen] = {
60 'v', 'a', 'l', 'i', 'd', 'U', 'n', 't', 'i', 'l'};
61
62 static constexpr uint8_t kDeviceKeyID[kDeviceKeyLen] = {'d', 'e', 'v', 'i', 'c',
63 'e', 'K', 'e', 'y'};
64
65 static constexpr uint8_t kDeviceKeyInfoID[kDeviceKeyInfoLen] = {
66 'd', 'e', 'v', 'i', 'c', 'e', 'K', 'e', 'y', 'I', 'n', 'f', 'o'};
67
68 static constexpr uint8_t kValueDigestsID[kValueDigestsLen] = {
69 'v', 'a', 'l', 'u', 'e', 'D', 'i', 'g', 'e', 's', 't', 's'};
70
71 static constexpr uint8_t kOrgID[kOrgLen] = {'o', 'r', 'g', '.', 'i', 's',
72 'o', '.', '1', '8', '0', '1',
73 '3', '.', '5', '.', '1'};
74
75} // namespace proofs
76
77#endif // PRIVACY_PROOFS_ZK_LIB_CIRCUITS_MDOC_MDOC_CONSTANTS_H_