Skip to content

Commit

Permalink
Take some of @armfazh's suggestions for common conventions
Browse files Browse the repository at this point in the history
These changes are mostly for clarity, but there are a few things we had
underspecified:

* The length of the output of the little-endian and big-endian encoders
  was not specified.

* How the length of the little-endian and big-endian decoders was
  interpreted was not specified.

* the length of the output of `additive_secret_shares()` was ambiguous.
  • Loading branch information
cjpatton committed Oct 15, 2024
1 parent b0decf1 commit 118b973
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions draft-irtf-cfrg-vdaf.md
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ Type hints are used to define input and output types:
* `Self` represents the containing class of the method definition in which it
appears.

* `Sequence[T]` is either a list or tuple.
* `Sequence[T]` is either a list or tuple of values of type `T`.

This document defines several byte-string constants. When comprised of printable
ASCII characters, they are written as Python 3 byte-string literals (e.g.,
Expand All @@ -784,8 +784,8 @@ a particular encoding of that quantity as a byte string.
Some common functionalities:

* `additive_secret_share(x: list[F], num_shares: int, field: type[F]) ->
list[list[F]]` takes a vector `x` of field elements and returns multiple
vectors of the same length, such that they all add up to the input vector.
list[list[F]]` takes a vector `x` of field elements and returns `num_shares`
vectors of length `len(x)` such that they all add up to the input vector.
Note that this function is not used normatively in this document.

* `byte(x: int) -> bytes` returns the representation of the integer `x` in range
Expand All @@ -799,15 +799,18 @@ Some common functionalities:
* `concat(parts: list[bytes]) -> bytes` returns the concatenation of the input
byte strings, i.e., `parts[0] + ... + parts[len(parts)-1]`.

* `from_be_bytes(encoded: bytes) -> int` computes the inverse of
`to_be_bytes()`.
* `from_be_bytes(encoded: bytes) -> int` decodes a big-endian byte string,
i.e., returns the integer `x` for which `to_be_bytes(x, len(encoded)) ==
encoded`.

* `from_le_bytes(encoded: bytes) -> int` computes the inverse of
`to_le_bytes()`.
* `from_le_bytes(encoded: bytes) -> int` decodes a little-endian byte string,
i.e., returns the integer `x` for which `to_le_bytes(x, len(encoded)) ==
encoded`.

* `front(len: int, x: list[Any]) -> tuple[list[Any], list[Any]]` splits `x`
into two vectors, where the first vector is made up of the first `len`
elements of `x`. I.e., `(x[:len], x[len:])`.
elements of `x` and the second is made up of the remaining elements. This
function is equivalent to `(x[:len], x[len:])`.

* `gen_rand(len: int) -> bytes` returns a byte array of the requested length
(`len`) generated by a cryptographically secure pseudorandom number generator
Expand All @@ -823,14 +826,16 @@ Some common functionalities:
output values.

* `to_be_bytes(x: int, len: int) -> bytes` converts an integer `x` whose value
is in the range `[0, 2^(8*len))` to big-endian bytes.
is in the range `[0, 2^(8*len))` to a big-endian, `len`-byte string.

* `to_le_bytes(x: int, len: int) -> bytes` converts an integer `x` whose value
is in the range `[0, 2^(8*len))` to little-endian bytes.
is in the range `[0, 2^(8*len))` to a little-endian, `len`-byte string.

* `poly_eval(field: type[F], p: list[F], x: F) -> F` returns the result of
evaluating the polynomial, `p(x)`. The coefficients of polynomials are stored
in lists in ascending order of degree, starting with the constant coefficient.
in lists in ascending order of degree, starting with the constant
coefficient. The `field` parameter is the class object for `F` and is used by
the implementation to construct field elements. (See {{field}}.)

* `poly_interp(field: type[F], inputs: list[F], outputs: list[F]) -> list[F]`
returns the coefficients of the lowest degree polynomial `p` for which
Expand All @@ -847,8 +852,8 @@ Some common functionalities:
* `xor(left: bytes, right: bytes) -> bytes` returns the bitwise XOR of `left`
and `right`. An exception is raised if the inputs are not the same length.

* `zeros(len: int) -> bytes` returns an array of zero bytes of the requested
length (`len`).
* `zeros(len: int) -> bytes` returns an array of bytes of the requested
length (`len`). Each element of the array is set to zero.

# Overview

Expand Down

0 comments on commit 118b973

Please sign in to comment.