Skip to content

Commit

Permalink
mem notes
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-ozdemir committed Dec 13, 2023
1 parent a26533b commit 697c240
Show file tree
Hide file tree
Showing 16 changed files with 4,413 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/mem/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
12 changes: 12 additions & 0 deletions doc/mem/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.PHONY: main.pdf auto clean sync
main: build/main.pdf

build/main.pdf:
latexmk -pdf -halt-on-error -interaction=nonstopmode -shell-escape main.tex -outdir=build

auto:
latexmk -pvc -pdf -halt-on-error -interaction=nonstopmode -shell-escape main.tex -outdir=build

clean:
latexmk -C main.tex
rm -rf build
135 changes: 135 additions & 0 deletions doc/mem/comments.sty
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{comments}[2022/10/11 Inline and margin comments]
% Written by Alex Ozdemir
% Inspired by the peanutgallery package of Riad S. Wahby (and possibly others).

\RequirePackage{options}
\RequirePackage{xcolor}
\RequirePackage{etoolbox}

\newcounter{commentcoloruse}
\newcounter{commentcolorsave}

\newlength{\totalmargin}
\newcommand{\SaveColor}[1]{%
\expandafter\def\csname CommentColorNumber\thecommentcolorsave\endcsname{#1}%
\stepcounter{commentcolorsave}%
}
\newcommand{\GetColor}{%
\expandafter\csname CommentColorNumber\thecommentcoloruse\endcsname%
}
\newcommand{\NextColor}{%
\stepcounter{commentcoloruse}
}
\def\primerlist{}

\definecolor{BrewerQualitative0}{HTML}{1b9e77}
\definecolor{BrewerQualitative1}{HTML}{d95f02}
\definecolor{BrewerQualitative2}{HTML}{7570b3}
\definecolor{BrewerQualitative3}{HTML}{e7298a}
\definecolor{BrewerQualitative4}{HTML}{66a61e}
\definecolor{BrewerQualitative5}{HTML}{e6ab02}
\definecolor{BrewerQualitative6}{HTML}{a6761d}
\definecolor{BrewerQualitative7}{HTML}{666666}
\SaveColor{BrewerQualitative0}
\SaveColor{BrewerQualitative1}
\SaveColor{BrewerQualitative2}
\SaveColor{BrewerQualitative3}
\SaveColor{BrewerQualitative4}
\SaveColor{BrewerQualitative5}
\SaveColor{BrewerQualitative6}
\SaveColor{BrewerQualitative7}

\options{
/comments/.new family,
/comments/hide/.new toggle = false,
/comments/marginparsep/.new dim = \dimexpr1pt\relax,
/comments/marginparpush/.new dim = \dimexpr0.5em\relax,
/comments/marginparwidth/.new dim = \dimexpr0.5\totalmargin-2pt\relax,
}

\options@ProcessOptions{/comments}

\iftoggle{/comments/hide}{%
\newcommand{\InlineComment}[2]{}
\newcommand{\MarginComment}[2]{\unskip}
\newcommand{\changebars}[2]{[{\color{magenta}\em\begingroup{#1}\endgroup}][{\color{magenta}\sout{#2}}]}
}{%
\newcommand{\InlineComment}[2]{\begingroup \color{#1}{#2}\endgroup}
\newcommand{\MarginComment}[2]{\unskip{\color{#1}\vrule\vrule}{\marginpar{\raggedright\color{#1}\sffamily\selectfont\scriptsize #2}}}
\newcommand{\changebars}[2]{[{\color{magenta}\em\begingroup{#1}\endgroup}][{\color{magenta}\sout{#2}}]}
}

% \CommenterWithColor{INITIALS_ANYCASE}{COLORNAME}
\newcommand{\CommenterWithColor}[2]{
\uppercase{\def\commentcsuppercase{#1}}%
\lowercase{\def\commentcslowercase{#1}}%
\expandafter\newcommand\csname \commentcslowercase\endcsname[1]{%
\InlineComment{#2}{\uppercase{#1}: ##1}}
\expandafter\newcommand\csname \commentcsuppercase\endcsname[1]{%
\MarginComment{#2}{\uppercase{#1}: ##1}}
\expandafter\def\expandafter\primerlist\expandafter{\primerlist

\noindent\texttt{-} {\small\color{#2} \texttt{\textbackslash \lowercase{#1}\{Test\}}} creates an
inline comment:
\lowercase{\csname#1\endcsname}{Test}

\noindent\texttt{-} {\small\color{#2} \texttt{\textbackslash \uppercase{#1}\{Test\}}}
creates a margin comment:
\uppercase{\csname#1\endcsname}{Test}
}
}

\def\commentprimer{
\subsection*{Comment System}

\noindent Welcome to \texttt{comments.sty}.

\noindent Macros:

\noindent\texttt{-} {\small\texttt{\textbackslash Commenter\{AO\}}}
creates macros
{\small\texttt{\textbackslash ao}}
and
{\small\texttt{\textbackslash AO}}.

\noindent\texttt{-} {\small\texttt{\textbackslash
CommenterWithColor\{AO\}\{COLOR\_NAME\}}}
is similar.

\noindent\texttt{-} {\small\texttt{\textbackslash changebars\{new\}\{old\}}} yields
\changebars{new}{old}.

\noindent\texttt{-} {\small\texttt{\textbackslash commentprimer}}
outputs this help message.

\primerlist


\noindent Package options:

\noindent\texttt{-} \texttt{\small hide} hide all comments and apply changes

\noindent\texttt{-} \texttt{\small marginparpush=LEN} distance between comments

\noindent\texttt{-} \texttt{\small marginparsep=LEN} distance from column

\noindent\texttt{-} \texttt{\small marginparwidth=LEN} width
}

% Utility for expanding macro arguments to text before expanding the macro
\long\gdef\expandargumentsof#1#2\stopexpansion{%
\edef\tmp{\noexpand#1#2}\tmp%
}

\newcommand{\Commenter}[1]{
\expandargumentsof\CommenterWithColor{#1}{\GetColor}\stopexpansion
\NextColor
}

\AtEndPreamble{
\setlength{\totalmargin}{\dimexpr\paperwidth-\textwidth\relax}
\setlength{\marginparsep}{\option{/comments/marginparsep}}
\setlength{\marginparpush}{\option{/comments/marginparpush}}
\setlength{\marginparwidth}{\option{/comments/marginparwidth}}
}
48 changes: 48 additions & 0 deletions doc/mem/der_xgcd/dnc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python

from sage.misc.misc_c import prod
from sage.rings.finite_rings.finite_field_constructor import GF
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing

p = 31
F = GF(p)
R = PolynomialRing(F, "x")
x = R.gen(0)


def v(*xs):
if len(xs) == 1 and isinstance(xs, list):
xs = xs[0]
return prod([x - a for a in xs])


def dgcd(p):
g, s, t = p.xgcd(p.derivative())
return g, s, t, s.factor(), t.factor()


f = v(2, 5, 7)
g = v(1, 3, 8)
print("f", f)
print("g", g)
_, fg, gf = f.xgcd(g)
print("fg", fg)
print("gf", gf)
_, fF, Ff = f.xgcd(f.derivative())
print("fF", fF)
print("Ff", Ff)
_, gG, Gg = g.xgcd(g.derivative())
print("gG", gG)
print("Gg", Gg)
h = f * g
print("h", h)
print("h", h.factor())
print("H", h.derivative().factor())
_, hH, Hh = h.xgcd(h.derivative())
print("hH", hH)
print("Hh", Hh)
c = Hh.coefficients()[-1]
print(dgcd(v(-1, -2, -3, -4, -5)))
print(dgcd(v(-1, -2, -3, -4)))
print(dgcd(v(-1, -2, -3)))
print(dgcd(v(-1, -2)))
53 changes: 53 additions & 0 deletions doc/mem/macros.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
\newcommand{\xspacemm}{\ifmmode\else\xspace\fi}

\newcommand{\prover}{\ensuremath{\mathcal{P}}\xspacemm}
\newcommand{\verifier}{\ensuremath{\mathcal{V}}\xspacemm}
\newcommand{\constraints}{\ensuremath{\mathcal{C}}\xspacemm}
\newcommand{\FF}{\ensuremath{\mathbb{F}}\xspace}
\newcommand{\NN}{\ensuremath{\mathbb{N}}\xspace}
\newcommand{\zo}{\ensuremath{\{0,1\}}\xspace}
\newcommand{\ext}{\mathsf{Ext}\xspacemm}
\newcommand{\enc}{\mathsf{Enc}\xspacemm}
\newcommand{\Prove}{\mathsf{Prove}\xspacemm}
\newcommand{\Verify}{\mathsf{Verify}\xspacemm}
\newcommand{\negl}{\mathsf{negl}\xspacemm}
\newcommand{\rfrom}{\xleftarrow{\text{\$}}}

\newcommand{\MA}{\ensuremath{\mathcal{MA}}\xspacemm}
\newcommand{\NP}{\ensuremath{\mathcal{NP}}\xspacemm}
\newcommand{\ZoK}{ZoKrates\xspacemm}
\newcommand{\zkSNARK}{zkSNARK\xspacemm}
\newcommand{\zkSNARKs}{zkSNARKs\xspacemm}
\newcommand{\zsharp}{Z\#\xspacemm}

\newcommand{\pp}{\ensuremath{\mathsf{pp}}\xspacemm}
\newcommand{\bnds}{\ensuremath{\mathsf{bnds}}\xspacemm}

% Memory
\newcommand{\MemAcc}{\ensuremath{\mathsf{acc}}\xspacemm}
\newcommand{\MemWr}{\ensuremath{\mathsf{wr}}\xspacemm}
\newcommand{\MemAdr}{\ensuremath{\mathsf{adr}}\xspacemm}
\newcommand{\MemVal}{\ensuremath{\mathsf{val}}\xspacemm}
\newcommand{\MemTime}{\ensuremath{\mathsf{t}}\xspacemm}

\newcommand{\CtxElem}{\ensuremath{\mathsf{CtxElem}}\xspacemm}
\newcommand{\MsHash}{\ensuremath{{H_\text{r}}}\xspacemm}
\newcommand{\Uhf}{\ensuremath{{H_\text{c}}}\xspacemm}

% CIC/lean terms
\newcommand{\dbrk}[1]{\ensuremath{{[\![{#1}]\!]}}\xspacemm}
\newcommand{\nat}{\ensuremath{\texttt{nat}}\xspacemm}
\newcommand{\add}{\ensuremath{\texttt{add}}\xspacemm}

% Eval
\newcommand{\stdlib}{\ensuremath{\mathsf{stdlib}}\xspacemm}
\newcommand{\mathlib}{\ensuremath{\mathsf{mathlib}}\xspacemm}
\newcommand{\program}{\ensuremath{\mathsf{program}}\xspacemm}

% \let\oldvec\vec
\renewcommand{\vec}[1]{\ensuremath{\mathbf{#1}}\xspacemm}

\newcommand{\csPerA}[1]{{\color{blue}\ensuremath{#1\cdot A} constraints}}
\newcommand{\romCsPerA}[1]{{\color{purple}(ROM: \ensuremath{#1\cdot A} constraints)}}
\newcommand{\csPerN}[1]{{\color{red}\ensuremath{#1 \cdot N} constraints}}
\newcommand{\csPerT}[1]{{\color{blue}\ensuremath{#1\cdot 3A} constraints}}
134 changes: 134 additions & 0 deletions doc/mem/main.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
\documentclass[conference,compsoc]{article}
%\documentclass[conference,compsoc]{IEEEtran}
%% \BibTeX command to typeset BibTeX logo in the docs
\AtBeginDocument{%
\providecommand\BibTeX{{%
\normalfont B\kern-0.5em{\scshape i\kern-0.25em b}\kern-0.8em\TeX}}}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[normalem]{ulem}
\usepackage[]{outlines}
\usepackage[dvipsnames]{xcolor}
\usepackage{amsmath,amssymb,comment}
\usepackage[bookmarksnumbered,unicode]{hyperref}
\hypersetup{ % ...like so
pdftex,
colorlinks,
pdfborder={0 0 0},
pdfmenubar=false,
pdfpagemode=UseNone,
pdfnonfullscreenpagemode=UseNone,
bookmarksopen=false,
bookmarks=false,
breaklinks=true,
linkcolor={green!50!black},
citecolor={red!50!black},
urlcolor={blue!50!black}
}

% add `hide` to hide comments
\usepackage[]{comments}
\Commenter{EL}
\Commenter{AO}
\Commenter{DB}

\usepackage[square,comma,numbers,sort&compress]{natbib}

\usepackage{xspace}
\usepackage[htt]{hyphenat}
\usepackage{listings}
\usepackage{nicefrac}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\tikzset{>=Latex[]}
\usepackage{booktabs}
\usepackage{menukeys}
\bibliographystyle{ieeetr}
\usepackage{caption}
\usepackage{subcaption}
% \usepackage[nohead,
% left=0.625in,right=0.625in,top=0.75in,bottom=0.75in,
% %left=0.633in,right=0.633in,top=0.75in,bottom=0.75in,
% columnsep=0.25in
% ]{geometry}

\usepackage{bussproofs}
\usepackage{backnaur}

% AO: Oakland minimum is 11pt, but that's crazy.
\usepackage{leading}

\newcommand\sysname{ZkPi\xspace}
\newcommand\sys{\sysname}
\newcommand\CIC{CIC\xspace}

\input{macros}

%\usepackage[text=DRAFT\ do\ not\ distribute,fontsize=0.08\paperwidth,angle=0,vpos=0.95\paperheight]{draftwatermark}

% careful
\hyphenation{an-aly-sis}

% Eddie Kohler protect us
\frenchspacing

\begin{document}

%%
%% The "title" command has an optional parameter,
\title{
%\vspace*{-1cm}
Persistent Memory
%\vspace*{-0.25cm}
}
%\subtitle{Shared Compiler Infrastructure for Constraint Solvers and Cryptosystems}

\author{}
% \author{%
% \IEEEauthorblockN{%
% Evan Laufer\quad
% Alex Ozdemir\quad
% Dan Boneh
% }%\\
% \IEEEauthorblockA{%
% Stanford University
% }
% }


%%
%% By default, the full list of authors will be used in the page %% headers. Often, this list is too long, and will overlap %% other information printed in the page headers. This command allows
%% the author to define a more concise list
%% of authors' names for this purpose.
%\renewcommand{\shortauthors}{Trovato and Tobin, et al.}

\maketitle

\begin{abstract}
TODO
% \input{abstract}
\end{abstract}

\commentprimer

\input{persistent}
\input{sparse}
\input{volatile}

\pagebreak

\begin{flushleft}
\footnotesize
\setlength{\parskip}{0pt}
\setlength{\itemsep}{0pt}
%\bibliographystyle{abbrv}
%\bibliography{myabbrev,cryptobib/crypto,refs}
\bibliography{refs}
\end{flushleft}

%% If your work has an appendix, this is the place to put it.
% \appendices

\end{document}
\endinput
5 changes: 5 additions & 0 deletions doc/mem/models/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data.csv: gcd_uniq.py
python $< > $@



Loading

0 comments on commit 697c240

Please sign in to comment.