Zig comptime is such a powerful built-in feature
I have been following the development of Zig for a while now. I like the idea of a systems programming language that is simple to learn and use, yet powerful and expressive. With Rust, I can get the powerful and expressive part, but the learning curve is a bit steep, and some parts of the language are complex and hard to understand. For example async/await (specially if you have to deal with Streams and Pins); and the macro domain-specific language (DSL). ...
Von Neumann
Von Neumann's wartime Los Alamos ID badge photo Warning: This post has KaTeX enabled, so if you want to view the rendered math formulas, you’ll have to unfortunately enable JavaScript. John von Neumann was a Hungarian-American mathematician. But to define him as a simple mathematician would be an understatement. He is a fucking legend and one of my heroes! He single-handedly: proposed an axiomatization of set theory along with a definition of cardinality that remains the standard one in mathematics today. Funny enough he started working on solving the paradoxes of set theory while he was only 11 years old! laid the mathematical foundations of quantum mechanics. made the atomic bomb possible by conceptualizing and designing the explosive lenses that were needed to compress the plutonium core of the Fat Man weapon that was later dropped on Nagasaki. He also invented the term “kiloton” of TNT as a unit of energy released in a nuclear explosion. invented the modern computer. Yes, I know, Alan Turing came up with the idea while trying to solve the halting problem, but it was von Neumann that recognized the true potential of computing machines and designed the first computers. We even have the von Neumann architecture that pretty much underlies in every working universal Turing machine in the world. created the field of game theory, along with the most important game theory’s theorem: the minimax theorem. co-invented the Monte Carlo method while trying to solve the problem of neutron diffusion. created the field of cellular automata and paved the way for the discovery of DNA. The list above is just a quick summary of his achievements. Everywhere you look in mathematics, physics, computer science, and even biology and economics, you’ll find von Neumann’s fingerprints. ...
Zero-Knowledge Proofs
Zero-Knowledge Proofs and the Meaning of Life Warning: This post has KaTeX and mermaid.js enabled, so if you want to view the rendered math formulas, and diagrams, you’ll have to unfortunately enable JavaScript. Lately, I’ve been diving a little into the world of Zero-Knowledge Proofs. The idea is to prove that you know something without revealing what you know. More specifically, a Zero-Knowledge Proof is a cryptographic protocol that allows a prover to convince a verifier that a statement is true without revealing any information beyond the validity of the statement. In essence, by the end of the protocol, the verifier is convinced that the prover knows the secret, and the verifier hasn’t learned anything (zero-knowledge) about the secret. ...
Shamir's Secret Sharing
The Polynomial king and he can do anything! Warning: This post has KaTeX enabled, so if you want to view the rendered math formulas, you’ll have to unfortunately enable JavaScript. In this post, we’ll talk about Shamir’s Secret Sharing (SSS), a cryptographic algorithm that allows us to split a secret into multiple parts, called shares, in such a way that the secret can only be reconstructed if a certain number of shares are combined. ...
Sherlock Holmes Final Letter: A Simple Dead Man's Switch in Rust
Sherlock Holmes fights Moriarty at the Reichenbach Falls Got state secrets? Or maybe 50 BTC? Don’t trust your government or lawyers? And you want to make sure that if you die, your secrets are passed on? Don’t worry, I got you covered. In this post, I’ll introduce you to a simple no-bullshit dead man’s switch written in Rust. Dead Man’s Switch According to Wikipedia: ...
Seed Phrases and Entropy
Warning: This post has KaTeX enabled, so if you want to view the rendered math formulas, you’ll have to unfortunately enable JavaScript. In this post, let’s dive into a topic that is very important for anyone who uses the internet: passwords. We’ll cover what the hell is Entropy, good password practices, and how it relates to Bitcoin “seed phrases”1. Entropy Before we go into passwords, I’ll introduce the concept of Entropy. ...
Cryptography Basics
Euclid’s one-way function Warning: This post has KaTeX enabled, so if you want to view the rendered math formulas, you’ll have to unfortunately enable JavaScript. This is the companion post to the cryptography workshop that I gave at a local BitDevs. Let’s explore the basics of cryptography. We’ll go through the following topics: One-way functions Hash functions Public-key cryptography DSA Schnorr Why we don’t reuse nonces? Why we can combine Schnorr Signatures and not DSA? One-way functions A one-way function is a function that is easy to compute on every input, but hard to invert given the image1 of a random input. For example, imagine an omelet. It’s easy to make an omelet from eggs, but it’s hard to make eggs from an omelet. In a sense we can say that the function $\text{omelet}$ is a one-way function ...
Fullstack and Progressive Web Apps in Rust: A Tale of a Sudoku Spyware
It all started when I had to accompany my mom to the hospital. It was just a routine checkup, but I had to wait for a few hours. I brought my laptop with me, since they have good WiFi and I could work on my projects. Then I realized that my mom was playing a Sudoku1 game on her phone. I couln’t help but notice that the game was full of ads and it was asking for a lot of permissions, like location and sensor data. So I decided to make a Sudoku game for her, without ads or using any permission. It wouldn’t even need to ask for the blessing of Google or Tim Apple since it was a Progressive Web App (PWA) and it would work offline. ...
htmx: an Oasis in a Desert of Soy
Warning: This post has mermaid.js enabled, so if you want to view the rendered diagrams, you’ll have to unfortunately enable JavaScript. I love to learn new things and I’m passionate about Stoic philosophy. So, when I acquired the domain stoicquotes.io1, I’ve decided to give htmx a try. What is htmx? htmx is a small JavaScript library that allows you to enhance your HTML with attributes to perform AJAX (Asynchronous JavaScript and XML) without writing JavaScript2. It focuses on extending HTML by adding custom attributes that describe how to perform common dynamic web page behaviors like partial page updates, form submission, etc. htmx is designed to be easy to use, requiring minimal JavaScript knowledge, so that you can add interactivity3 to web pages with just HTML. ...
Testing Bayesian Models with Nix and GitHub Actions
I have an open access and open source1 graduate-level course on Bayesian statistics. It is available in GitHub through the repo storopoli/Bayesian-Statistics. I’ve taught it many times and every time was such a joy. It is composed of: a set of 300+ slides2 covering the theoretical part Stan3 models Turing.jl4 models Now and then I receive emails from someone saying that the materials helped them to understand Bayesian statistics. These kind messages really make my day, and that’s why I strive to keep the content up-to-date and relevant. ...