Skip to content

Commit

Permalink
Mention that decode_from_bit_vec() is linear
Browse files Browse the repository at this point in the history
  • Loading branch information
divergentdave authored and cjpatton committed Nov 2, 2024
1 parent d007a4e commit a91d4b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions draft-irtf-cfrg-vdaf.md
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,9 @@ 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`.
This may also be used with secret shares of a bit representation,
since it is linear.
"""
bits = len(vec)
if cls.MODULUS >> bits == 0:
Expand Down Expand Up @@ -3903,6 +3906,12 @@ The circuit uses the polynomial-evaluation gadget `PolyEval` specified in
if and only if `x` is in the range `[0, 2)`. The complete circuit is specified
below:

Note that decoding a sequence of bits into an integer is a linear operation,
specifically, a linear combination with a sequence of powers of two, so it can
be done within a validity circuit using "free" affine gates. Furthermore,
decoding secret shares of a bit-encoded integer will produce secret shares of
the original integer.

~~~
class Sum(Valid[int, int, F]):
GADGETS: list[Gadget[F]] = [PolyEval([0, -1, 1])]
Expand Down
3 changes: 3 additions & 0 deletions poc/vdaf_poc/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ 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`.
This may also be used with secret shares of a bit representation,
since it is linear.
"""
bits = len(vec)
if cls.MODULUS >> bits == 0:
Expand Down

0 comments on commit a91d4b4

Please sign in to comment.