Skip to content

Commit

Permalink
Merge pull request #191 from o1-labs/feat/LCL-LSR-gadget
Browse files Browse the repository at this point in the history
Add left shift and right shift to finite field lib
  • Loading branch information
MartinMinkov authored Nov 2, 2023
2 parents 2a60a9b + e176602 commit 49c3f0f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crypto/finite_field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,12 @@ function createField(p: bigint, t: bigint, twoadicRoot: bigint) {
}
return BigInt('0b' + binary.reverse().join(''));
},
leftShift(x: bigint, bits: number, maxBitSize: number = 64) {
let shifted = x << BigInt(bits);
return shifted & ((1n << BigInt(maxBitSize)) - 1n);
},
rightShift(x: bigint, bits: number) {
return x >> BigInt(bits);
},
};
}

0 comments on commit 49c3f0f

Please sign in to comment.