\documentclass{article} \usepackage{geometry} \usepackage{amsmath} \usepackage{amssymb} \usepackage{algpseudocode} \usepackage{algorithm} \usepackage{textcomp} \algrenewcommand\textproc{\texttt} \newcommand{\textapprox}{\raisebox{0.5ex}{\texttildelow}} \begin{document} The set of ASCII printable characters consists of the characters starting from the space character (‘ ’, $\mathtt{0x20}$) to the tilde character (‘\texttt{\textapprox}’, $\mathtt{0x7E}$). This set contains all digits, upper and lower case characters and some punctuation characters. A mapping is to be designed that takes 6 or 8 ASCII printable character password as input and generates, in total, 13 integers from $\mathbb{Z} \cap [10, 99]$ in two groups of length $m$ and $n$. Each group of integers is a combination of integers from the aforementioned set such that all integers of the group are distinct and uniformly generated from the set in accordance to the given password. Every integer thus generated is unique within the group it belongs to but need not be so for the other group. Such a mapping is performed by a procedure described in the following pseudocode: \begin{algorithm} \begin{algorithmic}[1] \Procedure{map\_to\_values}{$\texttt{word}: \mathsf{List}[\mathbb{Z}/2^{8}\mathbb{Z}], m: \mathbb{Z}, n: \mathbb{Z}$}${} \to (\mathbb{Z} \cap [10, 99])^m \times (\mathbb{Z} \cap [10, 99])^n$ \Statex \textbf{Require: } $m + n = 13$ \textbf{and} $\forall c \in \texttt{word}$: $c$ is ASCII printable \Statex \State $\texttt{chrs} \gets [c - \mathtt{0x20} \mathbin{|} c \in \texttt{word}]$ \Comment{Map each letter from $[\mathtt{0x20}, \mathtt{0x7E}]$ to $[0, 94]$} \State $b_{\mathsf{dom}} \gets \mathtt{0x7E} - \mathtt{0x20} + 1$ \Comment{The cardinality of the set of ASCII printable characters} \State $b_{\mathsf{cod}} \gets 99 - 10 + 1$ \Comment{The cardinality of $\mathbb{Z} \cap [10, 99]$} \State $v \gets {}$\Call{from\_digits}{$\texttt{chrs}, b_{\mathsf{dom}}$} \State $\mathtt{T} \gets {}$\Call{to\_digits}{$v, b_{\mathsf{cod}}$} \State $\mathtt{T_{rev}} \gets $ reverse of $\mathtt{T}$ \State \textbf{return} (\Call{get\_comb}{$\mathtt{T_{rev}}, m$}, \Call{get\_comb}{$\mathtt{T}, n$}) \EndProcedure \end{algorithmic} \end{algorithm} The following procedures aid in the calculations done in the above procedure: The \texttt{from\_digits} and \texttt{to\_digits} perform conversion from the digits to the integer represented by the digits in the given base and the other way around, respectively. Endianness here denotes the position of most and least significant digit in the list of digits representing the integer. Big (or little) endian order has the most (least) significant digit at the beginning of the list and the least (most) significant digit at the end. \begin{algorithm} \begin{algorithmic}[1] \Procedure{from\_digits}{$\texttt{digits}: \mathsf{List}[\mathbb{Z}/b\mathbb{Z}], b: \mathbb{Z}$}${}\to \mathbb{Z}$ \Statex \textbf{Note:} the digits taken as input are considered to be in big-endian order. \Statex \State $v \gets 0$, $i \gets 0$, $n \gets {}$the length of the list \texttt{digits} \While{$i < n$} \State $v \gets v \times \texttt{base} + \texttt{digits} [i]$, $i \gets i + 1$ \EndWhile \State \textbf{return} $v$ \EndProcedure \end{algorithmic} \end{algorithm} \begin{algorithm} \begin{algorithmic}[1] \Procedure{to\_digits}{$v: \mathbb{Z}, b: \mathbb{Z}$}${}\to \mathsf{List}[\mathbb{Z}/b\mathbb{Z}]$ \Statex \textbf{Note: } the digits returned are in little-endian order. \Statex \State $\texttt{digits} \gets \texttt{[]}$ \Comment{Initialised with an empty list.} \While{$v \neq 0$} \State $\texttt{digit} \gets v \bmod b$, $v \gets \left\lfloor v / b \right\rfloor $ \State Append \texttt{digit} to \texttt{digits} \Comment{Prepend to obtain big-endian order.} \EndWhile \State \textbf{return} \texttt{digits} \EndProcedure \end{algorithmic} \end{algorithm} The \texttt{pick\_uniform} procedure uniformly picks a value from the given list and removes it from the list before returning the value and modified list. The uniformity is ensured by calculating the index from the digit with an offset of $\frac{i \times n}{z + 1}$, the $i$th point out of $z$ points within the list. The removing of value is performed to ensure uniqueness of the values picked from the list. The \texttt{get\_comb} procedure chooses $z$ values from the set $s$ of integers in $[10, 99]$ in an uniform manner in accordance with the list of digits given to it. If the digits are insufficient, more values are uniformly picked from the set. \begin{algorithm} \begin{algorithmic}[1] \Procedure{pick\_uniform}{$s: \mathsf{List}[\mathbb{Z}/b_{\mathsf{cod}} \mathbb{Z}], z: \mathbb{Z}, i: \mathbb{Z}, \texttt{digit}: \mathbb{Z}$}${}\to(\mathbb{Z}, \mathsf{List}[\mathbb{Z}/b_{\mathsf{cod}} \mathbb{Z}])$ \State $n \gets {}$the length of the list $s$, $\delta \gets \frac{n}{z+1}$ \State $\texttt{index} \gets \mathsf{round}(\texttt{digit} + i\times\delta) \bmod n$ \State $v \gets \texttt{s}[\texttt{index}]$ \State Remove $v$ at $\texttt{index}$ from the list $s$ \State \textbf{return} $v$, $s$ \EndProcedure \end{algorithmic} \end{algorithm} \begin{algorithm} \begin{algorithmic}[1] \Procedure{get\_comb}{${\texttt{digits}: \mathsf{List}[\mathbb{Z}/b_{\mathsf{cod}} \mathbb{Z}]}, z: \mathbb{Z}$}${}\to (\mathbb{Z} \cap [10, 99])^z$ \State $s \gets {}$a list of integers in the range $[10, 99]$ \State $i \gets 1$, $\texttt{comb} \gets \texttt{[]}$ \For{\textbf{each} \texttt{digit} from \texttt{digits}} \Comment{Iterate over \texttt{digits} in the order it appears in the list.} \State $v, s \gets {}$\Call{pick\_uniform}{$s, z, i, \texttt{digit}$} \State Append $v$ to \texttt{comb} \State $i \gets i + 1$ \State \textbf{break if} $i > z$ \EndFor \While{$i \leq z$} \State $v, s \gets {}$\Call{pick\_uniform}{$s, z, i, 0$} \State Append $v$ to \texttt{comb} \State $i \gets i + 1$ \EndWhile \State \textbf{return} \texttt{comb} \EndProcedure \end{algorithmic} \end{algorithm} The domain of this mapping is all possible strings of ASCII printable characters. The number of ASCII printable characters is $\mathtt{0x7F} - \mathtt{0x20} = \mathtt{0x5F} = 95_{10}$. Thus the domain has cardinality $95^k$ for a string of length $k$. The codomain is the (seperate) combination of $m$ and $n$ values from $\mathbb{Z} \cap [10, 99]$, so the cardinality is ${}^{90}C_{m} \times {}^{90}C_{n}$. The value 90 here is the cardinality of $\mathbb{Z} \cap [10, 99]$. These procedures are deterministic, thus producing the same output given the same input. It may generate the same values for different inputs, the probability would be higher for larger domains. % Please change the text according to the terminologies and notations used in the original paper. Please use appropriate notation where Z has been used, here only non-negative integers were considered. \end{document}