Randomness Can Improve Efficiency
- Given two -dimensional vectors  and , deterministic comparison of the vectors will always require communicating all  characters and have perfect soundness.
- That's communication cost before factoring in the size of the character set.
 
 - Probabilistic comparison can be done with constant communication at the expense of a soundness error that is proportional to the size of the field over which the low degree extensions of the vectors are defined.
 - Probabilistic comparison of the vectors can be done by creating unique low degree extension polynomials of the vectors over the domain   and comparing evaluations of the unique low degree extensions  and  for some random 
- Pick and where is the size of the character set for and .
 - The low degree extensions will have degree .
 - Two field elements are transmitted, and , resulting in constant communication.
 - The soundness error (probability that the evaluations will be the same for different vectors) is
 
 - The trivial comparison requires transmitting all characters, each with possible values. Each character requires bits to represent, so the communication cost would be .
 - In the probabilistic approach two field elements are transmitted. The field has order , so there are possible values requiring bits each to represent. If the order of the field is a constant power of , then and the communication cost is .
 - We pick such that and . It is likely that is the term that decides how large should be, but if the messages were very short but each character had a high number of possible values, the field could be defined to the be the same size as . Then we would have bits being transmitted and a communication cost of .
 
Low Degree Extensions and Fingerprints
- Pick a prime number such that where is the length of the message being encoded and where is the size of the character set for the message.
 - Interpret each entry in the message as an element in .
 - The unique low degree extension of an -length message  is a polynomial of degree  or lower
 - Each evaluation of the low degree extension at a field element can be thought of as a hash or fingerprint. For each element , there is a hash function  representing evaluation of the extension at the element .
 - The family of hash functions  is the set of all hash functions for all elements in 
 - The hash function  for  applied to the message  is the low degree extension   evaluated at 
 - Rather than comparing -length messages  and  directly, we can compare their hashes , or equivalently, we can compare the evaluations of their low degree extensions  for 
 
Message Comparison
- Given two -length messages  and , if the messages are identical, their hashes  and  will be the same for all  because their low degree extension polynomials will be the same. If  then .
 - If the messages differ, their hashes will differ with high probability over .
- The extension polynomials and will have degree by definition, so if they are different polynomials they will intersect at no more than points.
 - Two distinct polynomials and of degree will intersect at or fewer points because is an or lower degree polynomial with roots at each point where and intersect. If and intersect at more than points, is an or lower degree polynomial with more than roots which would violate the fundamental theorem of algebra.
 - There are  points in , so there is an  chance of agreement at a random point
 
 
Discussion
- The vector  has an error corrected encoding (, and  for  is a random entry in the encoding.
- Alternatively, the set of all evaluations is the error corrected encoding of
 
 - There are other encoding protocols, all that is required is a family of hashes such that for , is low
 - The algebraic structure of Reed-Solomon fingerprinting makes it useful for probabilistic proofs.
 
Implementation
/**
 * Evaluates a low degree extension polynomial derived from the Reed Solomon encoding of an ASCII message at a given field element `r`.
 *
 * This function interprets the given ASCII message as coefficients of a polynomial over the finite field F.
 * It constructs the polynomial as a linear transformation over the standard monomial basis:
 *   P(x) = c₀ + c₁·x + c₂·x² + ... + cₙ₋₁·xⁿ⁻¹
 * where each coefficient cᵢ is the field representation of the ASCII code of the i-th character of message.
 *
 * @param message - The ASCII string message to encode.
 * @param r - The field element at which to evaluate the polynomial.
 * @returns The field element P(r), the evaluation of the polynomial at r.
 * @throws Error if the message is empty.
 */
function getReedSolomon(message: string, r: Field): Field {
  if (message.length === 0) {
    throw new Error("Message cannot be empty.");
  }
  // Accumulator for summation  
  let result = Field(0);
  // Current power of the field element `r` (r⁰=1 initially)  
  let currentPower = Field(1);
  // Sum over each character in the message to construct and evaluate the polynomial  
  for (let i = 0; i < message.length; i++) {
    // Convert the ASCII character to its numeric representation  
    const coefficient = Field(asciiToNumber(message[i]));
    // Add the current term (coefficient * r^i) to the result  
    result = result.add(coefficient.mul(currentPower));
    // Update the current power of `r` for the next term (r^(i+1))  
    currentPower = currentPower.mul(r);
  }
  return result;
}
/**
 * Converts an ASCII character to its numeric ASCII code. * * @param char - The ASCII character to convert.
 * @returns The numeric ASCII code of the character.
 * @throws Error if the character is not a valid ASCII character (code between 0 and 127).
 */
export function asciiToNumber(char: string): number {
  const num = char.charCodeAt(0);
  if (num < 0 || num > 127) {
    throw new Error("Input must be a valid ASCII character (0-127).");
  }
  return num;
}