Skip to content

Commit

Permalink
fix: add missing error messages to decode
Browse files Browse the repository at this point in the history
  • Loading branch information
grjte committed Nov 11, 2024
1 parent 0c75c48 commit b58e5b9
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/decoder.nr
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,22 @@ impl Base64DecodeBE {
);
// enforce Base64 padding is valid
if num_padding_chars == 2 {
assert(input[InputElements - 1] == BASE64_PADDING_CHAR);
assert(input[InputElements - 2] == BASE64_PADDING_CHAR);
let offset = InputElements - 1;
assert(
input[offset] == BASE64_PADDING_CHAR,
f"DecodeError: expected padding at offset {offset}.",
);
let offset = InputElements - 2;
assert(
input[offset] == BASE64_PADDING_CHAR,
f"DecodeError: expected padding at offset {offset}.",
);
} else if num_padding_chars == 1 {
assert(input[InputElements - 1] == BASE64_PADDING_CHAR);
let offset = InputElements - 1;
assert(
input[InputElements - 1] == BASE64_PADDING_CHAR,
f"DecodeError: expected padding at offset {offset}.",
);
}
} else {
let expected = encoded_length - num_padding_chars;
Expand Down

0 comments on commit b58e5b9

Please sign in to comment.