diff --git a/src/lib/field.ts b/src/lib/field.ts index 284d5dc761..e5767a89b0 100644 --- a/src/lib/field.ts +++ b/src/lib/field.ts @@ -1007,35 +1007,6 @@ class Field { .seal(); } - /** - * Create a new {@link Field} element from the first `length` bits of this {@link Field} element. - * - * The `length` has to be a multiple of 16, and has to be between 0 and 255, otherwise the method throws. - * - * As {@link Field} elements are represented using [little endian binary representation](https://en.wikipedia.org/wiki/Endianness), - * the resulting {@link Field} element will equal the original one if it fits in `length` bits. - * - * @param length - The number of bits to take from this {@link Field} element. - * - * @return A {@link Field} element that is equal to the `length` of this {@link Field} element. - */ - rangeCheckHelper(length: number) { - checkBitLength('Field.rangeCheckHelper()', length); - if (length % 16 !== 0) - throw Error( - 'Field.rangeCheckHelper(): `length` has to be a multiple of 16.' - ); - let lengthDiv16 = length / 16; - if (this.isConstant()) { - let bits = Fp.toBits(this.toBigInt()) - .slice(0, length) - .concat(Array(Fp.sizeInBits - length).fill(false)); - return new Field(Fp.fromBits(bits)); - } - let x = Snarky.field.truncateToBits16(lengthDiv16, this.value); - return new Field(x); - } - /** * **Warning**: This function is mainly for internal use. Normally it is not intended to be used by a zkApp developer. * diff --git a/src/lib/gadgets/range-check.ts b/src/lib/gadgets/range-check.ts index a4b6161d92..ae51e53196 100644 --- a/src/lib/gadgets/range-check.ts +++ b/src/lib/gadgets/range-check.ts @@ -11,7 +11,6 @@ export { rangeCheck32, multiRangeCheck, compactMultiRangeCheck, - rangeCheckHelper, rangeCheckN, isInRangeN, rangeCheck8, @@ -239,6 +238,12 @@ function rangeCheck1Helper(inputs: { /** * Helper function that creates a new {@link Field} element from the first `length` bits of this {@link Field} element. + * + * This returns the `x` truncated to `length` bits. However, it does **not** prove this truncation or any + * other relation of the output with `x`. + * + * This only proves that the output value is in the range [0, 2^length), and so can be combined + * with the initial value to prove a range check. */ function rangeCheckHelper(length: number, x: Field) { assert(