Skip to content

Commit

Permalink
Merge pull request #1739 from o1-labs/fix-prefix
Browse files Browse the repository at this point in the history
Limit prefixToField to only accept ascii characters
  • Loading branch information
Trivo25 authored Jul 16, 2024
2 parents 745e863 + e6ac07a commit 6be263c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/provable/crypto/poseidon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ function prefixToField(prefix: string) {
// convert char to 8 bits
let bits = [];
for (let j = 0, c = char.charCodeAt(0); j < 8; j++, c >>= 1) {
if (j === 7)
assert(
c === 0,
`Invalid character ${char}, only ASCII characters are supported.`
);
bits.push(!!(c & 1));
}
return bits;
Expand Down

0 comments on commit 6be263c

Please sign in to comment.