Skip to content

Commit ec90c7e

Browse files
committed
Added seed based MLKEM test vectors
These are from C2SP#194 -- all I did was convert them to a JSON schema.
1 parent e3c37e9 commit ec90c7e

12 files changed

+14379
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
"type": "object",
3+
"properties": {
4+
"algorithm": {
5+
"enum": [
6+
"ML-KEM"
7+
]
8+
},
9+
"header": {
10+
"type": "array",
11+
"items": {
12+
"type": "string"
13+
},
14+
"description": "additional documentation"
15+
},
16+
"notes": {
17+
"$ref": "common.json#/definitions/Notes"
18+
},
19+
"numberOfTests": {
20+
"type": "integer",
21+
"description": "the number of test vectors in this test"
22+
},
23+
"schema": {
24+
"enum": [
25+
"mlkem_decaps_seed_test_schema.json"
26+
]
27+
},
28+
"testGroups": {
29+
"type": "array",
30+
"items": {
31+
"$ref": "#/definitions/MLKEMDecapsTestGroup"
32+
}
33+
}
34+
},
35+
"required": [
36+
"algorithm",
37+
"numberOfTests",
38+
"schema",
39+
"testGroups"
40+
],
41+
"additionalProperties": false,
42+
"definitions": {
43+
"MLKEMDecapsTestGroup": {
44+
"type": "object",
45+
"description": "A test for Decaps using seed format private key",
46+
"properties": {
47+
"type": {
48+
"enum": [
49+
"MLKEMDecaps"
50+
]
51+
},
52+
"source": {
53+
"$ref": "common.json#/definitions/Source"
54+
},
55+
"parameterSet": {
56+
"enum": [
57+
"ML-KEM-512",
58+
"ML-KEM-768",
59+
"ML-KEM-1024"
60+
]
61+
},
62+
"tests": {
63+
"type": "array",
64+
"items": {
65+
"type": "object",
66+
"properties": {
67+
"tcId": {
68+
"type": "integer",
69+
"description": "Identifier of the test case"
70+
},
71+
"comment": {
72+
"type": "string",
73+
"description": "A brief description of the test case"
74+
},
75+
"seed": {
76+
"type": "string",
77+
"format": "HexBytes",
78+
"description": "The d || z seed format private key"
79+
},
80+
"c": {
81+
"type": "string",
82+
"format": "HexBytes",
83+
"description": "The input ciphertext"
84+
},
85+
"K": {
86+
"type": "string",
87+
"format": "HexBytes",
88+
"description": "The expected shared secret"
89+
},
90+
"result": {
91+
"type": "string",
92+
"description": "Test result",
93+
"enum": [
94+
"valid",
95+
"invalid",
96+
"acceptable"
97+
]
98+
},
99+
"flags": {
100+
"type": "array",
101+
"items": {
102+
"type": "string"
103+
},
104+
"description": "A list of flags"
105+
}
106+
},
107+
"required": [
108+
"tcId",
109+
"seed",
110+
"c",
111+
"K",
112+
"result"
113+
],
114+
"additionalProperties": false
115+
}
116+
}
117+
},
118+
"required": [
119+
"type",
120+
"source",
121+
"parameterSet",
122+
"tests"
123+
],
124+
"additionalProperties": false
125+
}
126+
}
127+
}
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
{
2+
"type": "object",
3+
"properties": {
4+
"algorithm": {
5+
"enum": [
6+
"ML-KEM"
7+
]
8+
},
9+
"header": {
10+
"type": "array",
11+
"items": {
12+
"type": "string"
13+
},
14+
"description": "additional documentation"
15+
},
16+
"notes": {
17+
"$ref": "common.json#/definitions/Notes"
18+
},
19+
"numberOfTests": {
20+
"type": "integer",
21+
"description": "the number of test vectors in this test"
22+
},
23+
"schema": {
24+
"enum": [
25+
"mlkem_encaps_seed_test_schema.json"
26+
]
27+
},
28+
"testGroups": {
29+
"type": "array",
30+
"items": {
31+
"$ref": "#/definitions/MLKEMEncapsTestGroup"
32+
}
33+
}
34+
},
35+
"required": [
36+
"algorithm",
37+
"numberOfTests",
38+
"schema",
39+
"testGroups"
40+
],
41+
"additionalProperties": false,
42+
"definitions": {
43+
"MLKEMEncapsTestGroup": {
44+
"type": "object",
45+
"description": "A test for Encaps",
46+
"properties": {
47+
"type": {
48+
"enum": [
49+
"MLKEMEncaps"
50+
]
51+
},
52+
"source": {
53+
"$ref": "common.json#/definitions/Source"
54+
},
55+
"parameterSet": {
56+
"enum": [
57+
"ML-KEM-512",
58+
"ML-KEM-768",
59+
"ML-KEM-1024"
60+
]
61+
},
62+
"tests": {
63+
"type": "array",
64+
"items": {
65+
"type": "object",
66+
"properties": {
67+
"tcId": {
68+
"type": "integer",
69+
"description": "Identifier of the test case"
70+
},
71+
"comment": {
72+
"type": "string",
73+
"description": "A brief description of the test case"
74+
},
75+
"ek": {
76+
"type": "string",
77+
"format": "HexBytes",
78+
"description": "The encapsulation key"
79+
},
80+
"m": {
81+
"type": "string",
82+
"format": "HexBytes",
83+
"description": "The ML-KEM.Encaps_internal m input (randomness)"
84+
},
85+
"c": {
86+
"type": "string",
87+
"format": "HexBytes",
88+
"description": "The expected ciphertext"
89+
},
90+
"K": {
91+
"type": "string",
92+
"format": "HexBytes",
93+
"description": "The expected shared secret"
94+
},
95+
"result": {
96+
"type": "string",
97+
"description": "Test result",
98+
"enum": [
99+
"valid",
100+
"invalid",
101+
"acceptable"
102+
]
103+
},
104+
"flags": {
105+
"type": "array",
106+
"items": {
107+
"type": "string"
108+
},
109+
"description": "A list of flags"
110+
}
111+
},
112+
"required": [
113+
"tcId",
114+
"ek",
115+
"m",
116+
"c",
117+
"K",
118+
"result"
119+
],
120+
"additionalProperties": false
121+
}
122+
}
123+
},
124+
"required": [
125+
"type",
126+
"source",
127+
"parameterSet",
128+
"tests"
129+
],
130+
"additionalProperties": false
131+
}
132+
}
133+
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
"type": "object",
3+
"properties": {
4+
"algorithm": {
5+
"enum": [
6+
"ML-KEM"
7+
]
8+
},
9+
"header": {
10+
"type": "array",
11+
"items": {
12+
"type": "string"
13+
},
14+
"description": "additional documentation"
15+
},
16+
"notes": {
17+
"$ref": "common.json#/definitions/Notes"
18+
},
19+
"numberOfTests": {
20+
"type": "integer",
21+
"description": "the number of test vectors in this test"
22+
},
23+
"schema": {
24+
"enum": [
25+
"mlkem_keygen_seed_test_schema.json"
26+
]
27+
},
28+
"testGroups": {
29+
"type": "array",
30+
"items": {
31+
"$ref": "#/definitions/MLKEMKeyGenTestGroup"
32+
}
33+
}
34+
},
35+
"required": [
36+
"algorithm",
37+
"numberOfTests",
38+
"schema",
39+
"testGroups"
40+
],
41+
"additionalProperties": false,
42+
"definitions": {
43+
"MLKEMKeyGenTestGroup": {
44+
"type": "object",
45+
"description": "A test for KeyGen using seed format",
46+
"properties": {
47+
"type": {
48+
"enum": [
49+
"MLKEMKeyGen"
50+
]
51+
},
52+
"source": {
53+
"$ref": "common.json#/definitions/Source"
54+
},
55+
"parameterSet": {
56+
"enum": [
57+
"ML-KEM-512",
58+
"ML-KEM-768",
59+
"ML-KEM-1024"
60+
]
61+
},
62+
"tests": {
63+
"type": "array",
64+
"items": {
65+
"type": "object",
66+
"properties": {
67+
"tcId": {
68+
"type": "integer",
69+
"description": "Identifier of the test case"
70+
},
71+
"comment": {
72+
"type": "string",
73+
"description": "A brief description of the test case"
74+
},
75+
"seed": {
76+
"type": "string",
77+
"format": "HexBytes",
78+
"description": "The d || z seed for key generation"
79+
},
80+
"ek": {
81+
"type": "string",
82+
"format": "HexBytes",
83+
"description": "The expected encapsulation key"
84+
},
85+
"dk": {
86+
"type": "string",
87+
"format": "HexBytes",
88+
"description": "The expected expanded decapsulation key"
89+
},
90+
"result": {
91+
"type": "string",
92+
"description": "Test result",
93+
"enum": [
94+
"valid",
95+
"invalid",
96+
"acceptable"
97+
]
98+
},
99+
"flags": {
100+
"type": "array",
101+
"items": {
102+
"type": "string"
103+
},
104+
"description": "A list of flags"
105+
}
106+
},
107+
"required": [
108+
"tcId",
109+
"seed",
110+
"ek",
111+
"dk",
112+
"result"
113+
],
114+
"additionalProperties": false
115+
}
116+
}
117+
},
118+
"required": [
119+
"type",
120+
"source",
121+
"parameterSet",
122+
"tests"
123+
],
124+
"additionalProperties": false
125+
}
126+
}
127+
}

0 commit comments

Comments
 (0)