ZK-SecreC Documentation

2024.09

Module Bitextract

Function bitextract

unchecked eff * -> * -> [*] ! <$S>
pub fn bitextract [ $S, @D, N : Nat ] ( x : uint[N] $S @D, bw : uint[18446744073709551616] $pre @public ) -> list[bool[N] $S @D] $pre @public
where
  Field[N]

Little-endian binary representation of the integer given as the first argument, using the number of digits given as the second argument. If this number of digits is not enough, the digits of higher units are omitted.

Function bitextract_list

pub fn bitextract_list [ @D, N : Nat ] ( xs : list[uint[N] $post @D] $pre @public, bw : uint[18446744073709551616] $pre @public ) -> list[list[bool[N] $post @D] $pre @public] $pre @public
where
  Field[N]

The list of little-endian binary representations of all elements of the given list, using always the number of digits given as the second argument. If this number of digits is not enough, the digits of higher units are omitted. Equivalent to applying bitextract to every element of the given list.

Function bitextract_pre

pub fn bitextract_pre [ @D, N : Nat ] ( x : uint[N] $pre @D, bw : uint[18446744073709551616] $pre @public ) -> list[bool[N] $pre @D] $pre @public

Little-endian binary representation of the integer in the stage $pre given as the first argument, using the number of digits given as the second argument. If this number of digits is not enough, the digits of higher units are omitted.

Function bits_to_uint

pub fn bits_to_uint [ N : Nat, $S, @D ] ( bits : list[bool[N] $S @D] $pre @public ) -> uint[N] $S @D
where
  Field[N]

The integer whose little-endian binary representation is given.

Function bytes_to_uints

pub fn bytes_to_uints [ $S, @D, N : Nat ] ( bytes : list[list[bool[N] $S @D] $pre @public] $pre @public ) -> list[uint[N] $S @D] $pre @public
where
  Field[N]

The list of integers whose little-endian binary representations are in the given list, in the same order. Equivalent to applying bitsToUInt to every element of the given list.

Function bytextract_pre

pub fn bytextract_pre [ @D, N : Nat ] ( x : uint[N] $pre @D, byt_width : uint[18446744073709551616] $pre @public, byt_val : uint $pre @public ) -> list[uint[N] $pre @D] $pre @public

Little-endian representation of the integer in the stage $pre given as the first argument on base given as the third argument, using the number of digits given as the second argument. If this number of digits is not enough, the digits of higher units are omitted.

Function byts_to_uint

pub fn byts_to_uint [ N : Nat, $S, @D ] ( byts : list[uint[N] $S @D] $pre @public, byt_val : uint $pre @public ) -> uint[N] $S @D
where
  Field[N]

The integer whose little-endian representation on base given as the second argument is given as the first argument.

Function pow

pub fn pow [ $S, @D, N : Nat ] ( g : uint[N] $S @D, e : uint[N] $S @D, ebw : uint[18446744073709551616] $pre @public ) -> uint[N] $S @D
where
  Field[N]

The integer given as the first argument raised to the power given as the second argument. A variant of the fast exponentiation algorithm is used for computation. The third argument is the public length of bits to fit the binary representation of the exponent.

Function pow’

pub fn pow’ [ $S, @D, N : Nat ] ( g : uint[N] $S @D, e : list[bool[N] $S @D] $pre @public, ebw : uint[18446744073709551616] $pre @public ) -> uint[N] $S @D

The integer given as the first argument raised to the power whose little-endian binary representation is given as the second argument. The length of the significant initial part of the binary representation is given as the third argument.