\documentclass{article} \usepackage{graphicx} % Required for inserting images \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{amsmath} \usepackage{amssymb} \usepackage{amsfonts} \usepackage{bm} \usepackage[T1]{fontenc} \usepackage{geometry} \geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2cm,rmargin=2cm} \usepackage{orcidlink} \usepackage{setspace} \AtBeginDocument{\let~=\nobreakspace} \spacing{1.5} \usepackage{lineno} \linenumbers \hypersetup{ unicode=false, % non-Latin characters in Acrobat's bookmarks pdftoolbar=true, % show Acrobat's toolbar? pdfmenubar=true, % show Acrobat's menu? pdffitwindow=false, % window fit to page when opened % pdfstartview={FitW}, % fits the width of the page to the window pdftitle={Closed-form Expression of Monero's wallet2 Decoy Selection Algorithm}, % title pdfauthor={Rucknium}, % author pdfsubject={}, % subject of the document pdfcreator={Rucknium}, % creator of the document pdfproducer={}, % producer of the document pdfkeywords={}, % list of keywords pdfnewwindow=true, % links in new window colorlinks=false, % false: boxed links; true: colored links linkcolor=red, % color of internal links citecolor=green, % color of links to bibliography filecolor=magenta, % color of file links urlcolor=cyan % color of external links } \begin{document} \title{Closed-form Expression of Monero's \texttt{wallet2}\\Decoy Selection Algorithm\\\vspace{.3cm} \large Draft v0.1\vspace{-.715cm}} \author{Rucknium\orcidlink{https://orcid.org/0000-0001-5999-8950} } \date{October 2023} \maketitle \section{Modified Log-gamma distribution} Let $G(x;\alpha,\beta)$ be the Log-gamma cumulative distribution function (CDF) \begin{equation} G(x;\alpha,\beta)=\dfrac{\gamma\left(\alpha,\beta\ln\left(x\right)\right)}{\Gamma\left(\alpha\right)} \end{equation} where $\alpha$ is the shape parameter, $\beta$ is the rate parameter, $\gamma$ is the lower incomplete gamma function, and $\Gamma$ is the gamma function. In the \texttt{wallet2} code, $\alpha=19.28$ and $\beta=1.61$. The $G(x;\alpha,\beta)$ is adjusted in the code to: \begin{enumerate} \item Eliminate the portion of the distribution that would be younger than the youngest spendable output and reallocate it to a uniform distribution in the \texttt{RECENT\_SPEND\_WINDOW}. The\texttt{ $\frac{x/v_{t}}{1800}\cdot G(1200)$} term of the expression below performs the reallocation. \item Re-scale the output index distance unit into seconds. The $x\cdot v_{t}$ term does the re-scaling. \item Eliminate the portion of the distribution that would be older than the oldest spendable output and reallocate it to the rest of the distribution. Terms with $z_{t}$ perform this reallocation. \end{enumerate} $G^{*}(x;\alpha,\beta,v_{t},z_{t})$ is the modified CDF that \texttt{wallet2} uses to randomly generate an output index: \begin{equation} G^{*}(x;\alpha,\beta,v_{t},z_{t})=\begin{cases} 0 & \textrm{if }x\cdot v_{t}<0\\ \left(G(x\cdot v_{t}+1200)-G(1200)+\frac{x\cdot v_{t}}{1800}\cdot G(1200)\right)/G\left(z_{t}\cdot v_{t}\right) & \textrm{if }0\leq x\cdot v_{t}\leq1800\\ G\left(x\cdot v_{t}+1200\right)/G\left(z_{t}\cdot v_{t}\right) & \textrm{if }1800