Skip to content

Commit ed831c6

Browse files
committed
fix: use custom deserialise for ecc fuzzer to avoid throw
1 parent 3e6d4bb commit ed831c6

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

barretenberg/cpp/src/barretenberg/avm_fuzzer/harness/ecc.fuzzer.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,25 @@ struct EccFuzzerInput {
114114

115115
static EccFuzzerInput from_buffer(const uint8_t* buffer)
116116
{
117+
// Note: we cannot use AffinePoint::serialize_from_buffer() because this now throws if the point is not on the
118+
// curve. We want to test such points so have to deserialize manually:
119+
auto read_point = [](const uint8_t* src) -> AffinePoint {
120+
bool is_point_at_infinity =
121+
std::all_of(src, src + (sizeof(Fq) * 2), [](uint8_t val) { return val == 255; });
122+
if (is_point_at_infinity) {
123+
return AffinePoint::infinity();
124+
}
125+
AffinePoint result;
126+
read(src, result.x);
127+
read(src, result.y);
128+
return result;
129+
};
130+
117131
EccFuzzerInput input;
118132
size_t offset = 0;
119-
input.p = AffinePoint::serialize_from_buffer(buffer + offset);
133+
input.p = read_point(buffer + offset);
120134
offset += sizeof(AffinePoint);
121-
input.q = AffinePoint::serialize_from_buffer(buffer + offset);
135+
input.q = read_point(buffer + offset);
122136
offset += sizeof(AffinePoint);
123137
input.scalar = Fq::serialize_from_buffer(buffer + offset);
124138
offset += sizeof(Fq);

0 commit comments

Comments
 (0)