Skip to content

Commit

Permalink
refactor(bitwise.ts): replace Field.sizeInBits with hardcoded value 2…
Browse files Browse the repository at this point in the history
…40 in validateBitLength calls

The hardcoded value of 240 is now used instead of Field.sizeInBits when calling the validateBitLength function in the not and and functions. This change was made to avoid relying on the Field.sizeInBits property and instead use a fixed value for the maximum bit length validation. Using a hardcoded value provides more explicit control over the allowed bit length and reduces the dependency on the Field class.
  • Loading branch information
MartinMinkov committed Jul 16, 2024
1 parent ab43852 commit e62a501
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/provable/gadgets/bitwise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export {
};

function not(a: Field, length: number, checked: boolean = false) {
validateBitLength(length, Field.sizeInBits, 'not');
validateBitLength(length, 240, 'not');

// obtain pad length until the length is a multiple of 16 for n-bit length lookup table
let padLength = Math.ceil(length / 16) * 16;
Expand Down Expand Up @@ -140,7 +140,7 @@ function buildXor(a: Field, b: Field, out: Field, padLength: number) {
}

function and(a: Field, b: Field, length: number) {
validateBitLength(length, Field.sizeInBits, 'and');
validateBitLength(length, 240, 'and');

// obtain pad length until the length is a multiple of 16 for n-bit length lookup table
let padLength = Math.ceil(length / 16) * 16;
Expand Down

0 comments on commit e62a501

Please sign in to comment.