Skip to content

Commit

Permalink
Fix challenge serialization for BE codecs
Browse files Browse the repository at this point in the history
  • Loading branch information
davxy committed Jul 8, 2024
1 parent e742d26 commit 56edd4c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 6 additions & 6 deletions data/secp256_sha256_tai_ietf_vectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"h": "02ce0d7db4edd23b99b3736443c53ad12b133266c45646be3902a854606672e6ef",
"gamma": "0298b844148e41d128a2f2d49eb208618039cd9ece62d0fc2659461ebe2c7df2ac",
"beta": "92fd1eff9ddb4173ee87c45476b1c43486da7c20efd7a3c5b88891cf99bcd680",
"proof_c": "000000000000000000000000000000007b331610072248bd15c7aef0832ae2f9",
"proof_c": "7b331610072248bd15c7aef0832ae2f9",
"proof_s": "d30c63494b5e087f26bca7e3b57dd4876f6d01597e9ac272f33c7ac48f11a5b8"
},
{
Expand All @@ -22,7 +22,7 @@
"h": "0242336b14ccf0f101b64a1cca4b08f72f6be851f717dc56c07262500a84071e06",
"gamma": "03b2ae579ccf850038d9ba6b94a87646e8ecdec789639aab4c1492f11b114e6515",
"beta": "f30b3d4fb257c287cf423d044796ce1eaf6ec9c9d42ae4305274dad9a2fbd4dd",
"proof_c": "00000000000000000000000000000000230bcb8e6ff67f15e2aa27a7e570e743",
"proof_c": "230bcb8e6ff67f15e2aa27a7e570e743",
"proof_s": "8fdd6585e6ca4e09ada872c09c2ccacaa60df0cd919b10c4e2a68285ba236105"
},
{
Expand All @@ -35,7 +35,7 @@
"h": "03b90c05c10ddbfdafda6a964012946641737f888b90c930abdd2454c568f73d70",
"gamma": "03c572767b190538c104182dfac985cd58430074f0db24305f4006d896c93b96c7",
"beta": "d06d1139d2f0199b36d48b8d4980421e3d98504442e475c1760dcbbd19d27543",
"proof_c": "000000000000000000000000000000004b5b11f3b418095a5d02f835a283cc99",
"proof_c": "4b5b11f3b418095a5d02f835a283cc99",
"proof_s": "78bd588629d7dbfa7909384fc55590443f7d72996655ca933bf5979ccf342e14"
},
{
Expand All @@ -48,7 +48,7 @@
"h": "02bca955248372984158e0f9bf7d8d9bb1ee87f188cf27e93647a967a0f9b09535",
"gamma": "0323c860bdba4ceccc28ebed9283dc6f74b4e16c94ffe566f49318b955458c20e3",
"beta": "cd9444669432a6b5ca8ad3a4adcd8152fb8a76e327877ea876e6bf3e761b6e13",
"proof_c": "00000000000000000000000000000000c209c08df735f0a15e6318fcb7158693",
"proof_c": "c209c08df735f0a15e6318fcb7158693",
"proof_s": "9db4909d8cab16e9e79004fc74fc66eb3560debbad9aaa01f61e4077f893f1f7"
},
{
Expand All @@ -61,7 +61,7 @@
"h": "039edace829d35ef117e135c8b81b5b00a0d3c9f24a349761fc07a7503bf048966",
"gamma": "02d7b9b206af6fae3a6225ef09701e965e5387a22eca8e1bc71c167cd53f66903a",
"beta": "0f4965be7ec48d075a0035d5d1874a05328cb9f1cbe6b4066813ebb38e46b101",
"proof_c": "00000000000000000000000000000000ebc773f07f5a559bf176f57f83d5d80d",
"proof_c": "ebc773f07f5a559bf176f57f83d5d80d",
"proof_s": "e0f386d45474ea6eb40ebf59e4c7e6695813b6bf4b7984db868e415d1d3432e9"
},
{
Expand All @@ -74,7 +74,7 @@
"h": "029d367ea8eaf47bdb453f836c0c6afe9e5540c33adf4b20e1ecdf96c45f07ed1f",
"gamma": "0288734131a4dddb3a69e0ff346bd6afa5fcf29a328f1a4f7fa00c512127960e33",
"beta": "0a53ce69bc69cf00fc7f42a74717d8271fb6f7124351697e64e006e1e77733ba",
"proof_c": "000000000000000000000000000000007a1041d32a0e043ab11822977b6108b9",
"proof_c": "7a1041d32a0e043ab11822977b6108b9",
"proof_s": "b46c510a1bd8605aaf76d61407ea94a1158244b9b513a1653dfd347e2ea33847"
}
]
12 changes: 8 additions & 4 deletions src/ietf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,15 @@ pub mod testing {
}

fn to_map(&self) -> common::TestVectorMap {
let buf = utils::encode_scalar::<S>(&self.c);
let proof_c = if S::Codec::BIG_ENDIAN {
let len = buf.len();
&buf[len - S::CHALLENGE_LEN..]
} else {
&buf[..S::CHALLENGE_LEN]
};
let items = [
(
"proof_c",
hex::encode(&utils::encode_scalar::<S>(&self.c)[..S::CHALLENGE_LEN]),
),
("proof_c", hex::encode(&proof_c)),
("proof_s", hex::encode(utils::encode_scalar::<S>(&self.s))),
];
let mut map = self.base.to_map();
Expand Down

0 comments on commit 56edd4c

Please sign in to comment.