Skip to content

Commit

Permalink
mastic: Add test vectors, fix remaining bugs
Browse files Browse the repository at this point in the history
Add test vectors for Mastic and fix the bugs they encounter:

* Add domain separation to the payload check hash.
* Truncate the weights prior to aggregation.
* Adjust the order of the binder parts in the eval proof computation.
* vidpf: Align public share encoding with the draft.
* vidpf: Adjust index encoding in node proof.
* vidpf: Align a few variable names with the spec.

The test vectors were generated after making some changes to the spec
based on our implementation experience here:
jimouris/draft-mouris-cfrg-mastic#101
  • Loading branch information
cjpatton committed Jan 3, 2025
1 parent 6a7a916 commit bd26971
Show file tree
Hide file tree
Showing 10 changed files with 1,482 additions and 120 deletions.
2 changes: 1 addition & 1 deletion src/flp/szk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl<F: FieldElement + Decode, const SEED_SIZE: usize> ParameterizedDecode<(bool
}

/// A tuple containing the state and messages produced by an SZK query.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
pub struct SzkQueryShare<F: FieldElement, const SEED_SIZE: usize> {
joint_rand_part_opt: Option<Seed<SEED_SIZE>>,
pub(crate) flp_verifier: Vec<F>,
Expand Down
434 changes: 387 additions & 47 deletions src/vdaf/mastic.rs

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions src/vdaf/test_vec/mastic/04/MasticCount_0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"agg_param": "000000000002008001",
"agg_result": [
0,
1
],
"agg_shares": [
"b7f9921c929a6d97e6dcde35a90237a34ad73fa33cefc5223b1354b6afbebcad",
"4a066de36c6592681b2321ca55fdc85cb828c05cc2103addc7ecab494f414352"
],
"ctx": "736f6d65206170706c69636174696f6e",
"prep": [
{
"input_shares": [
"000102030405060708090a0b0c0d0e0f18e4527f6e16e586819caa63d4a3b11ca35ae9cba1bac0edd99ecf422a9233e9223000eb26fe45b8",
"101112131415161718191a1b1c1d1e1f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f"
],
"measurement": [
[
true,
false
],
true
],
"nonce": "000102030405060708090a0b0c0d0e0f",
"out_shares": [
[
"b7f9921c929a6d97",
"e6dcde35a90237a3",
"4ad73fa33cefc522",
"3b1354b6afbebcad"
],
[
"4a066de36c659268",
"1b2321ca55fdc85c",
"b828c05cc2103add",
"c7ecab494f414352"
]
],
"prep_messages": [
""
],
"prep_shares": [
[
"8fbf7bd1e6d11830692bd828041433ff60905d220dd23f1e4d9809e3b38276a5ccfbe6874465df6b13c091772d6cb8ff1dc268ab0e2591b0def6e33ffdb5a834",
"8fbf7bd1e6d11830692bd828041433ff60905d220dd23f1e4d9809e3b38276a535041978ba9a2094ff3ae157f12d9afe90008d6ef8ae35298a5adc89a5f1fffa"
]
],
"public_share": "0b40eac2eab18af3ac91184d5f466dc0fe1e9b00a994e6abffb9486a9d48a9623b3101fa6350e7a9831bfb7cf323506e335d928f520ed8fbfe0056b2dbdc41b30abc9bfeb20525cc0ce8771086a16c39a00aa20a65d67590d601d29a78e295828074afb0c0c610f3d0139e2c7e5f1762a72cc1bd0036307bce53dc15c49d419ac4",
"rand": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f"
}
],
"shares": 2,
"verify_key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"vidpf_bits": 2
}
56 changes: 56 additions & 0 deletions src/vdaf/test_vec/mastic/04/MasticCount_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"agg_param": "000100000002004001",
"agg_result": [
0,
0
],
"agg_shares": [
"b747157958114cc62e1d497271c7270d8dc52279cde66d98155fe5f1b3762097",
"4ab8ea86a6eeb339d3e2b68d8d38d8f2743add8631199267eca01a0e4b89df68"
],
"ctx": "736f6d65206170706c69636174696f6e",
"prep": [
{
"input_shares": [
"000102030405060708090a0b0c0d0e0f18e4527f6e16e586819caa63d4a3b11ca35ae9cba1bac0edd99ecf422a9233e9223000eb26fe45b8",
"101112131415161718191a1b1c1d1e1f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f"
],
"measurement": [
[
true,
false
],
true
],
"nonce": "000102030405060708090a0b0c0d0e0f",
"out_shares": [
[
"b747157958114cc6",
"2e1d497271c7270d",
"8dc52279cde66d98",
"155fe5f1b3762097"
],
[
"4ab8ea86a6eeb339",
"d3e2b68d8d38d8f2",
"743add8631199267",
"eca01a0e4b89df68"
]
],
"prep_messages": [
""
],
"prep_shares": [
[
"ac13211f48dcf0c9201df67ebc4979661b9a705d18ea377bf940d7c40895df80ccfbe6874465df6bcef64f43dd61f5661d79048f5c8f6e8e89270f2007e119ac",
"ac13211f48dcf0c9201df67ebc4979661b9a705d18ea377bf940d7c40895df8035041978ba9a2094c5edb5255d1187395e03bc1b36416ce932d8e39152ce8955"
]
],
"public_share": "0b40eac2eab18af3ac91184d5f466dc0fe1e9b00a994e6abffb9486a9d48a9623b3101fa6350e7a9831bfb7cf323506e335d928f520ed8fbfe0056b2dbdc41b30abc9bfeb20525cc0ce8771086a16c39a00aa20a65d67590d601d29a78e295828074afb0c0c610f3d0139e2c7e5f1762a72cc1bd0036307bce53dc15c49d419ac4",
"rand": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f"
}
],
"shares": 2,
"verify_key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"vidpf_bits": 2
}
182 changes: 182 additions & 0 deletions src/vdaf/test_vec/mastic/04/MasticHistogram_0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
{
"agg_param": "000100000002004001",
"agg_result": [
[
0,
0,
0,
1
],
[
0,
0,
1,
0
]
],
"agg_shares": [
"ab1c50b07a82e8740b6de7b72526a391220e88edfd85b4d621194410bd64c7cff6406f5b055ec5b7c908282cb836d447af43eee8d094f516ed6d619972dff19cf6a2d05fac19e06d96c2a17be84e839088374fa7a42ebaa035cbce842d1160dda40e01f0f310673d6d07ea8491058ac3c7b972088bcc17e036bee46055af4c513e37668f73b4dd64e2d0bb4060050afac4db2c15c86a679b58271187378cd75a",
"57e3af4f857d178bd8921848dad95c6edff17712027a4b29c2e6bbef429b38300bbf90a4faa13a481af7d7d347c92bb852bc11172f6b0ae9f6919e668d200e630c5d2fa053e61f924d3d5e8417b17c6f7ac8b0585bd1455fae34317bd2ee9f225df1fe0f0cef98c276f8157b6efa753c3a468df77433e81fad411b9faa50b3aec4c899708c4b229b012f44bf9ffaf5053d24d3ea379598648bd8ee78c87328a5"
],
"chunk_length": 2,
"ctx": "736f6d65206170706c69636174696f6e",
"length": 4,
"prep": [
{
"input_shares": [
"000102030405060708090a0b0c0d0e0f17e4527f6f16e586809caa63d4a3b11ce77f155f4fd6f965eae9970c93ceb0f1b47610e26294d48cedd439b1d009292aa84677c59741edf744a9ebeaf13ea6a54e42774c74967c7062fc82c171ad3446b7a940866ca84ea18ce30397738b78d4f0dbc8d29b6283f1ae142a45b7535d673c9c61fd78e7e8139142546326a877edc37200858122fcd3858edddd92b6e4bd1072429a8d2135e05af4c2455246a14b1a42e6f353c630f001d709fcc145ab47606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f70b6ba6a7095a4af8d54c0e0e16d345ed923e68c626589488ab4390920ec2341",
"101112131415161718191a1b1c1d1e1f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f87e5e50e23e85a5fe50bdcc0b908f6b0a1a1099c49c5e6c9bc965215adeff296"
],
"measurement": [
[
true,
false
],
1
],
"nonce": "000102030405060708090a0b0c0d0e0f",
"out_shares": [
[
"b847157958114cc6101d497272c7270d",
"41f91e1991b9333e8f87a10d64484c61",
"ff31ebc96df78d002724a8bc3705b448",
"24a003aa37e86fd228c2634a36c50473",
"57ec5d99b72ed656ab837615e6baab33",
"8dc52279cde66d98155fe5f1b3762097",
"00e16804881eff1023da897ff4824b77",
"9591bd1cbdd52983a1550aef8da45f22",
"fe3dd9950eef3bedf31a3699bf8d8a60",
"e22af0a9246c0ddf5d39e47b93332208"
],
[
"49b8ea86a7eeb339d3e2b68d8d38d8f2",
"c006e1e66e46ccc154785ef29bb7b39e",
"02ce1436920872ffbcdb5743c8fa4bb7",
"dd5ffc55c817902dbb3d9cb5c93afb8c",
"aa13a26648d129a9387c89ea194554cc",
"743add8632199267cea01a0e4c89df68",
"011f97fb77e100efc02576800b7db488",
"6c6e42e3422ad67c42aaf510725ba0dd",
"03c2266af110c412f0e4c9664072759f",
"1fd50f56db93f22086c61b846cccddf7"
]
],
"prep_messages": [
"a2039299a848b33fd14b9d48635993986af272075a8e66101c22f6250a40fe88"
],
"prep_shares": [
[
"badb8be5e28509757d7331affb9d323453ec5505ae56b525ad2c04b8d872269d87e5e50e23e85a5fe50bdcc0b908f6b0a1a1099c49c5e6c9bc965215adeff2960ce24cdf87197fe9882388ceed94c2e7125d831a3d8ff81b89a982fc341f64891552a935eebb4d55cbc5793ea9d24189c22972229024776188faf35f3f59596c42019350277327672d160354b7a527487b60df81a77c2b4e2914e78f21aa2baf",
"badb8be5e28509757d7331affb9d323453ec5505ae56b525ad2c04b8d872269d70b6ba6a7095a4af8d54c0e0e16d345ed923e68c626589488ab4390920ec2341f51db32078e680165bdc7731126b3d18b967249f3b307df8055076122ea7428085f18fcf635f613399edc22069702ada6bb14284dc36e343ed5ed1d475af1597f67fcb6f497664db45fa95346edef4460f8fed3c3fc256d81d48eb3d0f4e7d8e"
]
],
"public_share": "0b40eac2eab18af3ac91184d5f466dc0fe1e9b00a994e6abffb9486a9d48a9623b3001fa6351e7a9831bfb7cf323506e336a041d0b1eea4d694486884d91de700413c2257b5d446ba6a7236cbf8dc1246c46561fe9c6ce88757649ffeff995adfd7ae2c7a023c379f93ac0d6dd72c7d99b5d928f520fd8fbfee155b2dbdd41b30ad22234ba51abe53e2bac55027a1e925777f0e3cd6cac3cb7886346d56fff420adfff3984005c273473dd8d3686af3686db3b488ab613bea4a1dc3e9c923856d8bc9bfeb20525cc0ce8771086a16c39a00aa20a65d67590d601d29a78e295828074afb0c0c610f3d0139e2c7e5f1762a72cc1bd0036307bce53dc15c49d419ac4",
"rand": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f"
},
{
"input_shares": [
"000102030405060708090a0b0c0d0e0f17e4527f6f16e586809caa63d4a3b11ce77f155f4fd6f965eae9970c93ceb0f1b47610e26294d48cedd439b1d009292aa84677c59741edf744a9ebeaf13ea6a5f1f281a27c355c1da1a795043173b8a97064f08a88f24f7f2ebd3ecf876dbccd4c2bf9987044143961c571e4980d1dfc3c9c61fd78e7e8139142546326a877ed20c2f52e79831c2747e3ca9ad3f0605a57b7929571d73302b91a880d3e645d52bff2b52d7fe49fa83326c25ce08bebb2606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7fbfc91c62236af16cd2a83f902500111705c359a9bfdd58faaf3d4022485e11dd",
"101112131415161718191a1b1c1d1e1f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f596be1556854daf1c28a12ba3ff4a85ff68b16b41da609657ddc266b137cafe9"
],
"measurement": [
[
false,
true
],
2
],
"nonce": "000102030405060708090a0b0c0d0e0f",
"out_shares": [
[
"796a9d1b91384e57fd27cfa259af3d42",
"718a346a3666404cbb4851812c8e3db7",
"7c07c2c84bb39b5b43f2bf37c018907f",
"c651759f4cd64222d4d57e271e8df694",
"4f5b39637af5848b759f153301ca6b2e",
"31fd99cb39d14c36d533948a68bdad5f",
"f43c92bf096d47097f1edc818d8a3edc",
"aa348577f2b5246bf725ea1f720824c9",
"01761be1da2c7e34a6717ff95d6df3ac",
"574a49e41e7522bada812b814c540102"
],
[
"889562e46ec7b1a8e6d7305da650c2bd",
"9075cb95c999bfb328b7ae7ed371c248",
"85f83d37b44c64a4a00d40c83fe76f80",
"3bae8a60b329bddd0f2a81d8e172096b",
"b2a4c69c850a7b746e60eaccfe3594d1",
"d1026634c62eb3c90ecc6b75974252a0",
"0dc36d40f692b8f664e1237e7275c123",
"57cb7a880d4adb94ecd915e08df7db36",
"018ae41e25d381cb3d8e8006a2920c53",
"aab5b61be18add45097ed47eb3abfefd"
]
],
"prep_messages": [
"a5e601484d107482d3b52a8a85d89b2cd878e8153f977de4670ac8b4cd73abfe"
],
"prep_shares": [
[
"24e237dfc478f7784fd0c55144d6b88bdc52345fe469ed2283db11ef4e575da9596be1556854daf1c28a12ba3ff4a85ff68b16b41da609657ddc266b137cafe91f39aac5a6c7976f1714b8ab12c6c9e0591142d30a3a5aeae9dbe26b9ca05c2dea23b4aa38dd43551e12e229f8f667ea60c908053914d42f62ea28f86060928652d3bf96d4d55b2909f1fb4f3fe61c4d9c21ff3343b6c8e5b08b1aae5410101e",
"24e237dfc478f7784fd0c55144d6b88bdc52345fe469ed2283db11ef4e575da9bfc91c62236af16cd2a83f902500111705c359a9bfdd58faaf3d4022485e11dde2c6553a59386890cceb4754ed39361f751a2877034bd5fd6ab69ba41c948e55ca5dae0a9aa75ee4485e3a69009a68d96d8afae51e289aa7a86d9763a3fa666244139456627984df7757c3a65f97fe480f8fed3c3fc256d81d48eb3d0f4e7d8e"
]
],
"public_share": "0cfe948733e8abb0c8d8614ea90a159563bab5b3fb27db24b52744c7d7daf017e1a8930260961679081b2daf72f3195bb8ec7ecbbafb8b9fce046dfd466cf5b32e74e915792f57adab6e13c281af554d9b710479c1695940eb8441eb6070530e43b0ddca6e9358298707dd8cb25194fc52409894a45c20b02fbbf8d129b822799ffd8d9a76b09a19cb174512acb3dd097a05acadd1d1b4cfa141afcc3b7b9788dd98c0e67c7ee39c6278722daeb7776b052c56f8b928b8cca4e79d07834d0003accbd84d9b5607a7494f9995614aa3dd1cb065d58131a088e21ba6c87c4cc795ef1562ce16676335aa194125a674d8709b78e1b9382e44b462574de20b7305bfdd",
"rand": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f"
},
{
"input_shares": [
"000102030405060708090a0b0c0d0e0f17e4527f6f16e586809caa63d4a3b11ce77f155f4fd6f965eae9970c93ceb0f1b47610e26294d48cedd439b1d009292aa84677c59741edf744a9ebeaf13ea6a50474bc1b96ee5b85c27b4e9b70bc454e07f93d812ac19406a6c185e4493d139c568584b2f37cfa7013fca1060261a4ea3c9c61fd78e7e8139142546326a877ed0d41bbb55fca1cbf250f120494a7d3b5c022459fcf08ef7a411641f87b940684b5982a14fcabb97081ef913a773864c4606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7fbfc91c62236af16cd2a83f902500111705c359a9bfdd58faaf3d4022485e11dd",
"101112131415161718191a1b1c1d1e1f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5fdd114721b24ba6d16fd08b695c6f506f0da608eea60ae71f53c14f9f8d4bf970"
],
"measurement": [
[
false,
false
],
3
],
"nonce": "000102030405060708090a0b0c0d0e0f",
"out_shares": [
[
"7a6a9d1b91384e57fd27cfa259af3d42",
"718a346a3666404cbb4851812c8e3db7",
"7c07c2c84bb39b5b43f2bf37c018907f",
"c651759f4cd64222d4d57e271e8df694",
"505b39637af5848b759f153301ca6b2e",
"cb7492629d76ffd12e38550811dd91e6",
"b1f0052c62852023af0e84830ff8ff6f",
"89f32f74db40c9f18142f0515502c965",
"408371188a9823432c4406ae420a8cec",
"8b66f38684893702206c018a5704b450"
],
[
"889562e46ec7b1a8e6d7305da650c2bd",
"9075cb95c999bfb328b7ae7ed371c248",
"85f83d37b44c64a4a00d40c83fe76f80",
"3bae8a60b329bddd0f2a81d8e172096b",
"b2a4c69c850a7b746e60eaccfe3594d1",
"368b6d9d6289002eb5c7aaf7ee226e19",
"500ffad39d7adfdc34f17b7cf0070090",
"780cd08b24bf360e62bd0faeaafd369a",
"c17c8ee77567dcbcb7bbf951bdf57313",
"76990c797b76c8fdc393fe75a8fb4baf"
]
],
"prep_messages": [
"2f9a1a0b3c2eee55e5f9b61a7fb99a5405939d5340f030ba589dceba4b62e3fc"
],
"prep_shares": [
[
"14fd7bfa087d451cf3b5df70cba717db3edf07cc82f1659d57522ee10d4ba780dd114721b24ba6d16fd08b695c6f506f0da608eea60ae71f53c14f9f8d4bf9701f39aac5a6c7976f1714b8ab12c6c9e0b8094d0edea07625dcaa2ecd4d78e766d0e58afab77350a41b5502f611a9038a9c40b5a080b2b5f3fe84892f92401ef96c11e946553f4fda0baedb83253481ad70236b40ae1c482675fade4549ecbce4",
"14fd7bfa087d451cf3b5df70cba717db3edf07cc82f1659d57522ee10d4ba780bfc91c62236af16cd2a83f902500111705c359a9bfdd58faaf3d4022485e11dde2c6553a59386890cceb4754ed39361f13bb5aab9a1effeeb24eca41154ebfa2ca5dae0a9aa75ee4485e3a69009a68d96fca5d62f089e52c756c4e0c1b375b6244139456627984df7757c3a65f97fe480f8fed3c3fc256d81d48eb3d0f4e7d8e"
]
],
"public_share": "00fe948733e8abb0c8d8614ea90a1595630a50514ca8f19ef156afb335dcb1ee26a8930260961679081b2daf72f3195bb8ec7ecbbafb8b9fce046dfd466cf5b32e74e915792f57adab6e13c281af554d9b700479c1695940eb8441eb6070530e43b1ddca6e9358298707dd8cb25194fc52da0f8d3bc0c562cb30fd92a760425d26ba410ee308b3f2e44735baad354bcb0de46a58ceba3f7428cccbd26d5e912d7ad8cd3cb42d4f4271fe44b4629c1404456072a25c8ecce1ec2c88dd8b58b0b5facbd84d9b5607a7494f9995614aa3dd1cb065d58131a088e21ba6c87c4cc795ef22c376bd8f303ec420aad19361730e832916aac966b7345e93c94482a0e96e9a",
"rand": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f"
}
],
"shares": 2,
"verify_key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"vidpf_bits": 2
}
Loading

0 comments on commit bd26971

Please sign in to comment.