-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bug in the decoding procedure for
Vec<PartialAuthenticationPath>
The culprit was this line in `BFieldCodec`: ``` if (vec_len != 0 || mask != 0) && index == str.len() { ``` This if-statement generates an error if the predicate evaluates to true. The idea is that if the vector length (`vec_len`, number of `Option<Digest>`s in this partial authentication path) is nonzero, or if the mask (`mask`, whose bits indicate whether the option is `Some(..)` or `None`) is nonzero, then we should be expecting at least one digest to follow; and so in this case the index cannot point to the end of the string. The logic is flawed because the vector length can nonzero with no following digests. This occurs in partial authentication paths consisting entirely of `None`s. The `mask` variable will be zero, thus triggering the predicate erroneously. The fix is to change the offending line to this: ``` if vec_len != 0 && mask != 0 && index == str.len() { ``` In other words, we are only expecting to read another digest if a) the vector has nonzero length, _and_ b) the mask is nonzero. Also, remove profiling from test. Use the benchmark for profiling.
- Loading branch information
1 parent
cc15b18
commit e7fd6cc
Showing
2 changed files
with
72 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters