Skip to content

Commit de14a82

Browse files
Docs: Add macros
1 parent b1583a9 commit de14a82

File tree

1 file changed

+385
-0
lines changed

1 file changed

+385
-0
lines changed

macros.tex

Lines changed: 385 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,385 @@
1+
\RequirePackage{authblk,orcidlink}
2+
\RequirePackage{xspace}
3+
\RequirePackage{amsmath,amssymb,amsfonts,amsthm,thmtools,thm-restate,amsopn}
4+
\RequirePackage{hyperref}
5+
\RequirePackage{xcolor}
6+
\RequirePackage{enumitem,marvosym}
7+
\RequirePackage[most]{tcolorbox}
8+
\RequirePackage{tabularx,colortbl,ltablex,booktabs}
9+
\RequirePackage{algpseudocode,algorithm}
10+
\RequirePackage[width=\textwidth,textfont=sl]{caption}
11+
\RequirePackage[capitalize,noabbrev]{cleveref}
12+
13+
\usetikzlibrary{backgrounds,fit,automata,positioning,shapes.geometric,decorations.markings}
14+
15+
\newcommand*{\mathEnv}[1]{\ensuremath{#1}\xspace}
16+
17+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18+
% General Format
19+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20+
\newcommand{\ignore}[1]{}
21+
\newcommand{\revisedText}[1]{{\color{blue}#1}}
22+
\renewcommand{\paragraph}[1]{\medskip\noindent{\bf #1}}
23+
\providecommand*\email[1]{\href{mailto:#1}{\texttt{#1}}}
24+
25+
26+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27+
% Math
28+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29+
\newcommand*{\EX}{\mathEnv{\mathbb{E}}}
30+
\newcommand*{\Var}{\mathEnv{\mathbf{Var}}}
31+
\renewcommand*{\Pr}{\mathEnv{\mathbf{Pr}}}
32+
\newcommand*{\med}{\mathEnv{\mathsf{med}}}
33+
\newcommand*{\concat}{\mathEnv{\mathbin\Vert}}
34+
\newcommand*{\defeq}{\mathEnv{\overset{\mathrm{def}}{=}}}
35+
36+
\newcommand*{\true}{\mathEnv{\mathsf{true}}}
37+
\newcommand*{\false}{\mathEnv{\mathsf{false}}}
38+
\newcommand*{\inv}{\mathEnv{^{-1}}}
39+
40+
41+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42+
% theorem style
43+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44+
% bold note for plain and definition theoremstyle
45+
\makeatletter
46+
\def\th@plain{\thm@notefont{}\itshape}
47+
\def\th@definition{\thm@notefont{}\normalfont}
48+
\makeatother
49+
50+
\newtheorem{theorem}{Theorem}
51+
\newtheorem{lemma}[theorem]{Lemma}
52+
\newtheorem{proposition}[theorem]{Proposition}
53+
\newtheorem{corollary}[theorem]{Corollary}
54+
\newtheorem{claim}{Claim}
55+
\newtheorem*{claim*}{Claim}
56+
\newtheorem{definition}{Definition}
57+
\newtheorem{fact}{Fact}
58+
59+
\theoremstyle{remark}
60+
\newtheorem{remark}{Remark}
61+
\newtheorem{example}{Example}
62+
63+
\Crefname{lemma}{Lemma}{Lemmas}
64+
65+
66+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67+
% complexity class
68+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69+
\newcommand*{\bigO}{\mathEnv{\mathcal{O}}}
70+
\newcommand*{\poly}{\mathEnv{\mathsf{poly}}}
71+
\newcommand*{\polylog}{\mathEnv{\mathsf{polylog}}}
72+
\newcommand*{\negl}{\mathEnv{\mathsf{negl}}}
73+
\newcommand*{\NP}{\mathEnv{\mathsf{NP}}}
74+
75+
76+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77+
% Tables
78+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79+
\renewcommand{\tabularxcolumn}[1]{m{#1}}
80+
81+
82+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83+
% party/adv notations
84+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85+
\newcommand*{\party}{\mathEnv{\mathsf{P}}}
86+
\newcommand*{\adv}{\mathEnv{\mathcal{A}}}
87+
\newcommand*{\delay}{\mathEnv{\varDelta}}
88+
\newcommand*{\round}{\mathEnv{\mathtt{r}}}
89+
90+
\newcommand*{\partyset}{\mathEnv{\mathcal{P}}}
91+
\newcommand*{\honestPartySet}{\mathEnv{\mathcal{H}}}
92+
93+
94+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95+
% blockchain
96+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97+
\newcommand*{\block}{\mathEnv{\mathcal{B}}}
98+
\newcommand*{\chain}{\mathEnv{\mathcal{C}}}
99+
\newcommand*{\chainLocal}{\mathEnv{\chain_{\mathsf{loc}}}}
100+
\newcommand*{\ledger}{\mathEnv{\mathcal{L}}}
101+
102+
\newcommand*{\tx}{\mathEnv{\mathtt{tx}}}
103+
104+
\newcommand{\chainHead}[1]{\mathEnv{\mathrm{head}(#1)}}
105+
\newcommand{\timestamp}[1]{\mathEnv{\mathsf{TS}(#1)}}
106+
\newcommand{\chainPrefix}[2]{\mathEnv{#1^{\lceil{#2}}}}
107+
\newcommand{\chainLength}[1]{\mathEnv{\mathrm{len}(#1)}}
108+
109+
\newcommand*{\twoforone}{\mathEnv{2{\times}1}}
110+
111+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
112+
% Cryptograph
113+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114+
\newcommand*{\PKE}{\mathEnv{\mathsf{PKE}}}
115+
\newcommand*{\KeyGen}{\mathEnv{\mathsf{KeyGen}}}
116+
\newcommand*{\Enc}{\mathEnv{\mathsf{Enc}}}
117+
\newcommand*{\Dec}{\mathEnv{\mathsf{Dec}}}
118+
\newcommand*{\pk}{\mathEnv{\mathsf{pk}}}
119+
\newcommand*{\sk}{\mathEnv{\mathsf{sk}}}
120+
121+
\newcommand*{\SIG}{\mathEnv{\mathsf{SIG}}}
122+
\newcommand*{\Sign}{\mathEnv{\mathsf{Sign}}}
123+
\newcommand*{\Verify}{\mathEnv{\mathsf{Verify}}}
124+
\newcommand*{\NIZK}{\mathEnv{\Pi_{\mathsf{NIZK}}}}
125+
\newcommand*{\Prove}{\mathEnv{\mathsf{Prove}}}
126+
127+
\newcommand*{\fPRF}{\mathEnv{f_\mathsf{PRF}}}
128+
129+
130+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131+
% UC Framework
132+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133+
\newcommand*{\sid}{\mathEnv{\mathrm{sid}}}
134+
\newcommand*{\pid}{\mathEnv{\mathrm{pid}}}
135+
\newcommand*{\Z}{\mathEnv{\mathcal{Z}}}
136+
\newcommand*{\simulator}{\mathEnv{\mathcal{S}}}
137+
\newcommand*{\ok}{\mathEnv{\mathsf{ok}}}
138+
139+
\newcommand*{\F}{\mathEnv{\mathcal{F}}}
140+
\newcommand*{\func}{\mathEnv{\mathcal{F}}}
141+
142+
\newcommand*{\funcClock}{\mathEnv{\mathcal{G}_{\mathsf{Clock}}}}
143+
\newcommand*{\funcGRO}{\mathEnv{\mathcal{G}_{\mathsf{RO}}}}
144+
\newcommand*{\funcCRS}{\mathEnv{\F_{\mathsf{CRS}}}}
145+
\newcommand*{\funcDiffuse}{\mathEnv{\F_{\mathsf{Diffuse}}}}
146+
147+
\newcommand*{\funcLedger}{\mathEnv{\mathcal{G}_{\mathsf{Ledger}}}}
148+
\newcommand*{\funcFairLedger}{\mathEnv{\mathcal{G}^{\mathsf{Fair}}_{\mathsf{Ledger}}}}
149+
\newcommand*{\funcEnclave}{\mathEnv{\mathcal{G}_{\mathsf{att}}}}
150+
\newcommand*{\funcGrpoRO}{\mathEnv{\mathcal{G}_{\mathsf{rpoRO}}}}
151+
152+
\newcommand{\wrapper}[1]{\mathEnv{\mathcal{W}(#1)}}
153+
154+
155+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
156+
% Global Ledger
157+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158+
\newcommand*{\blockify}{\mathEnv{\mathsf{Blockify}}}
159+
\newcommand*{\ledgerTime}{\mathEnv{\tau_\ledger}}
160+
\newcommand*{\honestInputSeq}{\mathEnv{\vec{\mathcal{I}}^T_H}}
161+
\newcommand*{\state}{\mathEnv{\mathtt{state}}}
162+
\newcommand*{\st}{\mathEnv{\mathtt{st}}}
163+
\newcommand*{\pt}{\mathEnv{\mathtt{pt}}}
164+
\newcommand*{\txid}{\mathEnv{\mathrm{txid}}}
165+
\newcommand*{\timedState}{\mathEnv{\vec{\tau}_{\state}}}
166+
\newcommand*{\tauLow}{\mathEnv{\tau_{\mathsf{low}}}}
167+
\newcommand*{\BTX}{\mathEnv{\mathtt{BTX}}}
168+
\newcommand*{\txSeqProposal}{\mathEnv{\vec{N}}}
169+
\newcommand*{\txSeqProposalDefault}{\mathEnv{\txSeqProposal_{\mathrm{df}}}}
170+
171+
172+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173+
% Fair Ledger Protocol
174+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
175+
\newcommand{\protocFairLedger}{\mathEnv{\mathsf{\Pi}^{\mathsf{Fair}}_{\mathsf{Ledger}}}}
176+
177+
\newcommand*{\PB}{\mathEnv{\mathsf{PB}}}
178+
\newcommand*{\PBWindowLen}{\mathEnv{K}}
179+
\newcommand*{\CPLen}{\mathEnv{k}}
180+
\newcommand{\stringRev}[1]{\mathEnv{[#1]^{\mathsf{R}}}}
181+
\newcommand*{\buffer}{\mathEnv{\mathtt{buffer}}}
182+
\newcommand*{\txTag}{\mathEnv{\mathsf{tag}}}
183+
\newcommand*{\ticket}{\mathEnv{\mathsf{\tau}}}
184+
185+
\newcommand*{\badCP}{\mathEnv{\mathsf{BAD\text{-}CP}}}
186+
\newcommand*{\badCQ}{\mathEnv{\mathsf{BAD\text{-}CQ}}}
187+
\newcommand*{\badCG}{\mathEnv{\mathsf{BAD\text{-}CG}}}
188+
\newcommand*{\badProfile}{\mathEnv{\mathsf{BAD\text{-}PROFILE}}}
189+
\newcommand*{\badNIZK}{\mathEnv{\mathsf{BAD\text{-}NIZK}}}
190+
\newcommand*{\badDec}{\mathEnv{\mathsf{BAD\text{-}DEC}}}
191+
\newcommand*{\badTicket}{\mathEnv{\mathsf{BAD\text{-}TICKET}}}
192+
193+
194+
\tcbset{
195+
cccBox/.style={
196+
enhanced,
197+
breakable,
198+
attach boxed title to top left={yshift=-4mm,xshift=5mm},
199+
coltitle=black,
200+
boxed title style={colback=white},
201+
colback=white,
202+
top=5mm,
203+
drop fuzzy shadow,
204+
sharp corners,
205+
fontupper=\small,
206+
enlarge top by=2mm,
207+
enlarge bottom by=3mm,
208+
segmentation style = {solid, line width = .5mm}
209+
}
210+
}
211+
212+
213+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
214+
% Protocol Box
215+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
216+
\newcounter{protoccolCounter}
217+
\setcounter{protoccolCounter}{0}
218+
219+
\newtcolorbox[use counter=protoccolCounter]{protocolbox}[2]{
220+
cccBox,
221+
title={\large \textbf{Protocol} #1},
222+
label=protocol:#2
223+
}
224+
225+
\newcommand{\fboxfootprotocol}{}
226+
\newenvironment{cccProtocol}[3]{
227+
\renewcommand{\fboxfootprotocol}{#3}
228+
\begin{protocolbox}{#1}{#2}
229+
}{
230+
\tcblower
231+
Protocol~{\thetcbcounter}: {\sl \fboxfootprotocol}
232+
\end{protocolbox}
233+
}
234+
235+
\crefname{protoccolCounter}{Protocol}{Protocols}
236+
237+
238+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
239+
% Functionality Box
240+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
241+
\newcounter{functionalityCounter}
242+
\setcounter{functionalityCounter}{0}
243+
244+
\newtcolorbox[use counter=functionalityCounter]{functionalitybox}[2]{
245+
cccBox,
246+
title={\large \textbf{Functionality} #1},
247+
label=functionality:#2
248+
}
249+
250+
\newcommand{\fboxfootfunctinoality}{}
251+
\newenvironment{cccFunctionality}[3]{
252+
\renewcommand{\fboxfootfunctinoality}{#3}
253+
\begin{functionalitybox}{#1}{#2}
254+
}{
255+
\tcblower
256+
Functionality~{\thetcbcounter}: {\sl \fboxfootfunctinoality}
257+
\end{functionalitybox}
258+
}
259+
260+
\crefname{functionalityCounter}{Functionality}{Functionalities}
261+
262+
263+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
264+
% Simulator Box
265+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
266+
\newcounter{simulatorCounter}
267+
\setcounter{simulatorCounter}{0}
268+
269+
\newtcolorbox[use counter=simulatorCounter]{simulatorbox}[2]{
270+
cccBox,
271+
title={\large \textbf{Simulator} #1},
272+
label=simulator:#2
273+
}
274+
275+
\crefname{simulatorCounter}{Simulator}{Simulators}
276+
277+
278+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
279+
% Game Box
280+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
281+
\newcounter{gameCounter}
282+
\setcounter{gameCounter}{0}
283+
284+
\newtcolorbox[use counter=gameCounter]{gamebox}[2]{
285+
cccBox,
286+
title={\large \textbf{Game} #1},
287+
label=game:#2
288+
}
289+
290+
\newcommand{\fboxfootgame}{}
291+
\newenvironment{cccGame}[3]{
292+
\renewcommand{\fboxfootgame}{#3}
293+
\begin{gamebox}{#1}{#2}
294+
}{
295+
\tcblower
296+
Game~{\thetcbcounter}: {\sl \fboxfootgame}
297+
\end{gamebox}
298+
}
299+
300+
\crefname{gameCounter}{Game}{Games}
301+
302+
303+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
304+
% Program Box
305+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306+
\newcounter{programCounter}
307+
\setcounter{programCounter}{0}
308+
309+
\newtcolorbox[use counter=programCounter]{programbox}[2]{
310+
cccBox,
311+
title={\large \textbf{Program} #1},
312+
label=program:#2
313+
}
314+
315+
\newcommand{\fboxfootprogram}{}
316+
\newenvironment{cccProgram}[3]{
317+
\renewcommand{\fboxfootprogram}{#3}
318+
\begin{programbox}{#1}{#2}
319+
}{
320+
\tcblower
321+
Program~{\thetcbcounter}: {\sl \fboxfootprogram}
322+
\end{programbox}
323+
}
324+
325+
\crefname{programCounter}{Program}{Programs}
326+
327+
328+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
329+
% Algorithm Box
330+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
331+
\newcounter{algorithmCounter}
332+
\setcounter{algorithmCounter}{0}
333+
334+
\newtcolorbox[use counter=algorithmCounter]{algorithmbox}[2]{
335+
cccBox,
336+
title={\large \textbf{Algorithm} #1},
337+
label=algorithm:#2
338+
}
339+
340+
\newcommand{\fboxfootalgorithm}{}
341+
\newenvironment{cccAlgorithm}[3]{
342+
\renewcommand{\fboxfootalgorithm}{#3}
343+
\begin{algorithmbox}{#1}{#2}
344+
}{
345+
\tcblower
346+
Algorithm~{\thetcbcounter}: {\sl \fboxfootalgorithm}
347+
\end{algorithmbox}
348+
}
349+
350+
\crefname{algorithmCounter}{Algorithm}{Algorithms}
351+
352+
\makeatletter
353+
\algnewcommand{\LineComment}[1]{\Statex\hskip\ALG@thistlm{{\color{gray}$\triangleright$ #1}}}
354+
\makeatother
355+
\algrenewcommand{\algorithmiccomment}[1]{\hfill{\color{gray} $\triangleleft$ #1}}
356+
\newcommand{\oneLineIf}[2]{\State{\textbf{if} #1 \textbf{then} #2}}
357+
358+
359+
\makeatletter
360+
\newcommand*\ifcounter[1]{
361+
\ifcsname c@#1\endcsname
362+
\expandafter\@firstoftwo
363+
\else
364+
\expandafter\@secondoftwo
365+
\fi
366+
}
367+
\makeatother
368+
369+
\NewDocumentEnvironment{algorithmWithNumbering}{m}{
370+
\begin{algorithmic}[1]
371+
\ifcounter{ALG@line@#1}{}{\newcounter{ALG@line@#1}}
372+
\setcounter{ALG@line}{\value{ALG@line@#1}}
373+
}{
374+
\setcounter{ALG@line@#1}{\value{ALG@line}
375+
}
376+
\end{algorithmic}%
377+
}
378+
379+
\newenvironment{cccItemize}[1][]{
380+
\begin{enumerate}[label=\FlatSteel, leftmargin=*, #1]
381+
}{\end{enumerate}}
382+
383+
\newenvironment{cccEnum}[1][]{
384+
\begin{enumerate}[label={\arabic*.}, leftmargin=*, #1]
385+
}{\end{enumerate}}

0 commit comments

Comments
 (0)