From b0decf175877b2f67c20e4fba22f982e5d133f03 Mon Sep 17 00:00:00 2001 From: Christopher Patton Date: Tue, 15 Oct 2024 09:09:08 -0700 Subject: [PATCH] SQUASH "vit vec" -> "bit vec" --- draft-irtf-cfrg-vdaf.md | 22 +++++++++++----------- poc/tests/test_field.py | 4 ++-- poc/vdaf_poc/field.py | 6 +++--- poc/vdaf_poc/flp_bbcggi19.py | 18 +++++++++--------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/draft-irtf-cfrg-vdaf.md b/draft-irtf-cfrg-vdaf.md index 32a34150..96c139bc 100644 --- a/draft-irtf-cfrg-vdaf.md +++ b/draft-irtf-cfrg-vdaf.md @@ -1979,7 +1979,7 @@ are used to encode measurements in some variants of Prio3 ({{prio3-instantiations}}). ~~~ python -def encode_into_vit_vec( +def encode_into_bit_vec( cls, val: int, bits: int) -> list[Self]: @@ -2002,7 +2002,7 @@ def encode_into_vit_vec( encoded.append(cls((val >> l) & 1)) return encoded -def decode_from_vit_vec(cls, vec: list[Self]) -> Self: +def decode_from_bit_vec(cls, vec: list[Self]) -> Self: """ Decode the field element from the bit representation, expressed as a vector of field elements `vec`. @@ -3865,25 +3865,25 @@ class Sum(Valid[int, int, F]): out.append(self.GADGETS[0].eval(self.field, [b])) range_check = self.offset * shares_inv + \ - self.field.decode_from_vit_vec(meas[:self.bits]) - \ - self.field.decode_from_vit_vec(meas[self.bits:]) + self.field.decode_from_bit_vec(meas[:self.bits]) - \ + self.field.decode_from_bit_vec(meas[self.bits:]) out.append(range_check) return out def encode(self, measurement: int) -> list[F]: encoded = [] - encoded += self.field.encode_into_vit_vec( + encoded += self.field.encode_into_bit_vec( measurement, self.bits ) - encoded += self.field.encode_into_vit_vec( + encoded += self.field.encode_into_bit_vec( measurement + self.offset.int(), self.bits ) return encoded def truncate(self, meas: list[F]) -> list[F]: - return [self.field.decode_from_vit_vec(meas[:self.bits])] + return [self.field.decode_from_bit_vec(meas[:self.bits])] def decode(self, output: list[F], _num_measurements: int) -> int: return output[0].int() @@ -3999,14 +3999,14 @@ class SumVec(Valid[list[int], list[int], F]): def encode(self, measurement: list[int]) -> list[F]: encoded = [] for val in measurement: - encoded += self.field.encode_into_vit_vec( + encoded += self.field.encode_into_bit_vec( val, self.bits) return encoded def truncate(self, meas: list[F]) -> list[F]: truncated = [] for i in range(self.length): - truncated.append(self.field.decode_from_vit_vec( + truncated.append(self.field.decode_from_bit_vec( meas[i * self.bits: (i + 1) * self.bits] )) return truncated @@ -4275,7 +4275,7 @@ class MultihotCountVec(Valid[list[int], list[int], F]): count_vec = meas[:self.length] weight = sum(count_vec, self.field(0)) weight_reported = \ - self.field.decode_from_vit_vec(meas[self.length:]) + self.field.decode_from_bit_vec(meas[self.length:]) weight_check = self.offset*shares_inv + weight - \ weight_reported @@ -4293,7 +4293,7 @@ class MultihotCountVec(Valid[list[int], list[int], F]): encoded = [] encoded += count_vec - encoded += self.field.encode_into_vit_vec( + encoded += self.field.encode_into_bit_vec( (self.offset + weight_reported).int(), self.bits_for_weight) return encoded diff --git a/poc/tests/test_field.py b/poc/tests/test_field.py index de32ec0f..0c3aa3a4 100644 --- a/poc/tests/test_field.py +++ b/poc/tests/test_field.py @@ -38,8 +38,8 @@ def run_field_test(self, cls: type[Field]) -> None: vals = [i for i in range(15)] bits = 4 for val in vals: - encoded = cls.encode_into_vit_vec(val, bits) - self.assertTrue(cls.decode_from_vit_vec( + encoded = cls.encode_into_bit_vec(val, bits) + self.assertTrue(cls.decode_from_bit_vec( encoded).int() == val) def run_ntt_field_test(self, cls: type[NttField]) -> None: diff --git a/poc/vdaf_poc/field.py b/poc/vdaf_poc/field.py index 99047ed9..dc04ad85 100644 --- a/poc/vdaf_poc/field.py +++ b/poc/vdaf_poc/field.py @@ -68,14 +68,14 @@ def decode_vec(cls, encoded: bytes) -> list[Self]: vec.append(cls(x)) return vec - # NOTE: The encode_into_vit_vec() and decode_from_vit_vec() + # NOTE: The encode_into_bit_vec() and decode_from_bit_vec() # methods are excerpted in the document, de-indented, as the figure # {{field-bit-rep}}. Their width should be limited to 69 columns # after de-indenting, or 73 columns before de-indenting, to avoid # warnings from xml2rfc. # =================================================================== @classmethod - def encode_into_vit_vec( + def encode_into_bit_vec( cls, val: int, bits: int) -> list[Self]: @@ -99,7 +99,7 @@ def encode_into_vit_vec( return encoded @classmethod - def decode_from_vit_vec(cls, vec: list[Self]) -> Self: + def decode_from_bit_vec(cls, vec: list[Self]) -> Self: """ Decode the field element from the bit representation, expressed as a vector of field elements `vec`. diff --git a/poc/vdaf_poc/flp_bbcggi19.py b/poc/vdaf_poc/flp_bbcggi19.py index bcae3063..b2b975c6 100644 --- a/poc/vdaf_poc/flp_bbcggi19.py +++ b/poc/vdaf_poc/flp_bbcggi19.py @@ -855,7 +855,7 @@ def eval( count_vec = meas[:self.length] weight = sum(count_vec, self.field(0)) weight_reported = \ - self.field.decode_from_vit_vec(meas[self.length:]) + self.field.decode_from_bit_vec(meas[self.length:]) weight_check = self.offset*shares_inv + weight - \ weight_reported @@ -873,7 +873,7 @@ def encode(self, measurement: list[int]) -> list[F]: encoded = [] encoded += count_vec - encoded += self.field.encode_into_vit_vec( + encoded += self.field.encode_into_bit_vec( (self.offset + weight_reported).int(), self.bits_for_weight) return encoded @@ -982,14 +982,14 @@ def encode(self, measurement: list[int]) -> list[F]: 'entry of measurement vector is out of range' ) - encoded += self.field.encode_into_vit_vec( + encoded += self.field.encode_into_bit_vec( val, self.bits) return encoded def truncate(self, meas: list[F]) -> list[F]: truncated = [] for i in range(self.length): - truncated.append(self.field.decode_from_vit_vec( + truncated.append(self.field.decode_from_bit_vec( meas[i * self.bits: (i + 1) * self.bits] )) return truncated @@ -1070,25 +1070,25 @@ def eval( out.append(self.GADGETS[0].eval(self.field, [b])) range_check = self.offset * shares_inv + \ - self.field.decode_from_vit_vec(meas[:self.bits]) - \ - self.field.decode_from_vit_vec(meas[self.bits:]) + self.field.decode_from_bit_vec(meas[:self.bits]) - \ + self.field.decode_from_bit_vec(meas[self.bits:]) out.append(range_check) return out def encode(self, measurement: int) -> list[F]: encoded = [] - encoded += self.field.encode_into_vit_vec( + encoded += self.field.encode_into_bit_vec( measurement, self.bits ) - encoded += self.field.encode_into_vit_vec( + encoded += self.field.encode_into_bit_vec( measurement + self.offset.int(), self.bits ) return encoded def truncate(self, meas: list[F]) -> list[F]: - return [self.field.decode_from_vit_vec(meas[:self.bits])] + return [self.field.decode_from_bit_vec(meas[:self.bits])] def decode(self, output: list[F], _num_measurements: int) -> int: return output[0].int()