ZK-SecreC Documentation

2024.09

Module IsFromFirst

Function is_from_first

pub fn is_from_first [ N : Nat ] ( x : list[uint[N] $post @verifier] $pre @public, y : list[uint[N] $post @prover] $pre @public, ref sizeasserter : SizeAsserter[N, $post, @prover] $pre @public ) -> list[bool[N] $post @prover] $pre @public
where
  Field[N],
  Challenge[N]

The concatenation of the given two lists, with all elements replaced with booleans indicating if the element occurs in the first given list. Fails if either argument list contains an element that is not representable using the number of bits specified in the given SizeAsserter object.

Function is_prefixed_by_last

pub fn is_prefixed_by_last [ N : Nat, $S, @D ] ( xs : list[uint[N] $S @D] $pre @public, lens : list[uint[N] $S @D] $pre @public, maxlen : uint[18446744073709551616] $pre @public ) -> list[bool[N] $S @D] $pre @public
where
  Field[N]

The first argument list, each element having been replaced with a boolean indicating if the previous element is a prefix of this element, where the original elements are interpreted as strings that evaluate to them via the String::eval_string function. Assumes that the strings consist of 8-bit characters and their lengths are given in the second argument list. The third argument is assumed to be an upper bound of all the lengths.

Function is_prefixed_from_first

unchecked eff [*] -> [*] -> [*] -> [*] -> * -> [,,[*]] -> [*] ! <@public>
pub fn is_prefixed_from_first [ N : Nat ] ( xs : list[uint[N] $post @verifier] $pre @public, ys : list[uint[N] $post @prover] $pre @public, xlens : list[uint[N] $post @verifier] $pre @public, ylens : list[uint[N] $post @prover] $pre @public, maxlen : uint[18446744073709551616] $pre @public, ref sizeasserter : SizeAsserter[N, $post, @prover] $pre @public ) -> list[bool[N] $post @prover] $pre @public
where
  Field[N],
  Challenge[N]

The concatenation of the first two argument lists, with all elements replaced with booleans indicating if the element has a prefix occurring in the first given list, where the original elements are interpreted as strings that evaluate to them via the String::eval_string function. Assumes that the strings consist of 8-bit characters and their lengths are given as the third and the fourth argument list. The fifth argument is assumed to be an upper bound of all the lengths. Fails if either of the first two lists contains an element that is not representable using the number of bits specified in the given SizeAsserter object.

Function string_is_from_first

pub fn string_is_from_first [ N : Nat ] ( instances : list[String[$post, @verifier, N] $pre @public] $pre @public, witnesses : list[String[$post, @prover, N] $pre @public] $pre @public, ref sizeasserter : SizeAsserter[N, $post, @prover] $pre @public ) -> list[bool[N] $post @prover] $pre @public
where
  Field[N],
  Challenge[N]

The concatenation of the given two lists, with all elements replaced with booleans indicating if the element occurs in the first given list. Assumes that all String objects in the given lists consist of 8-bit characters and evaluate (via the String::eval_string function) to a number less than the modulus. Fails if either argument list contains a String object whose value is not representable using the number of bits specified in the given SizeAsserter object.