Skip to content

Instantly share code, notes, and snippets.

View recmo's full-sized avatar

Remco Bloemen recmo

View GitHub Profile
#!/usr/bin/env rust-script
//!
//! Implements a tail-calling interpreter in Rust.
//!
// Ideally we would create a State struct to hold the state variables and pass that along,
// but the compiler won't pass it through registers. We also can't use a macro to avoid
// repeating all the registers, as this would
// We want the dispatch table, program counter and vm state to be passed in registers as
@recmo
recmo / safe-tx.ts
Created March 20, 2025 18:30
Safe transaction proposal
#!/usr/bin/env -S deno run --allow-read --allow-env --allow-net
// Note: Deno is almost self-contained, but you need to create a deno.json file to make it work.
// This file should contain `{"nodeModulesDir": "none"}`
import { MetaTransactionData, OperationType } from 'npm:@safe-global/types-kit'
import SafeApiKit from 'npm:@safe-global/api-kit'
import Safe from 'npm:@safe-global/protocol-kit'
const chainId: bigint = 480n // World Chain
const provider = 'https://worldchain-mainnet.g.alchemy.com/public'
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = [
# ]
# ///
# <https://gist.github.com/recmo/af5935fc8a40c54050a691301eaacdaa>
import random
import time
def miller_rabin(candidate, repeats=128):
@recmo
recmo / Claim.yul
Last active November 1, 2024 14:51
object "Claim" {
code {
datacopy(0, dataoffset("Runtime"), datasize("Runtime"))
return(0, datasize("Runtime"))
}
object "Runtime" {
code {
// Memory layout
// 0..192: ModExp precompile calldata
@recmo
recmo / GaloisRing.sage
Last active June 28, 2024 10:55
Implementation of Galois Rings for SageMath
# Load using the following command in SageMath:
#
# load("https://gist.githubusercontent.com/recmo/6393218cab40baa78e44766772d1ec34/raw/GaloisRing.sage")
#
# Get the latest version from https://gist.github.com/recmo/6393218cab40baa78e44766772d1ec34
from sage.structure.richcmp import richcmp
class GaloisRingElement(CommutativeRingElement):
(function(){window.renderMath=function(){renderMathInElement(document.body,{delimiters:[{left:'$$',right:'$$',display:true},{left:'$',right:'$',display:false}],throwOnError:false});};if(!window.katex){css=document.createElement('link');css.rel='stylesheet';css.href='https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css';css.crossorigin='anonymous';script=document.createElement('script');script.src='https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js';script.async=false;script.crossorigin='anonymous';copyTex=document.createElement('script');copyTex.src='https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/copy-tex.min.js';copyTex.async=false;copyTex.crossorigin='anonymous';autoRender=document.createElement('script');autoRender.src='https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js';autoRender.async=false;autoRender.onload=window.renderMath;autoRender.crossorigin='anonymous';document.head.appendChild(css);document.head.appendChild(script);document.head.appendChild(copyTe
DUP2 899407
PUSH1 718627
PUSH2 718557
ADD 686328
JUMPDEST 573198
POP 457984
JUMPI 436369
MSTORE 328876
SWAP1 326765
MLOAD 315104
@recmo
recmo / keccak-aarch64.rs
Last active October 17, 2023 23:17
Rust aarch64 FEAT_SHA3 implementation of keccak_f1600.
#![cfg(all(target_arch = "aarch64", target_feature = "sha3"))]
use core::arch::asm;
const RC: [u64; 24] = [
0x0000000000000001,
0x0000000000008082,
0x800000000000808a,
0x8000000080008000,
0x000000000000808b,
0x0000000080000001,
@recmo
recmo / attestation.txt
Created April 8, 2022 17:11
Attestation
I contributed to the Semaphore Trusted Setup Multi-Party Ceremony.
The following are my contribution signatures:
Circuit: semaphore16
Contributor # 250
Hash: c293791b 1806dea5 2b5eb5df 876a8690
1bd6fd3b 642e1193 066254c2 53932eb5
53e990b7 6dd80e26 a5b9e65e f8fd90b7
94a06997 000dc2ad 4e4032f1 a87718fc
@recmo
recmo / book.toml
Created January 21, 2021 16:59
Katex in mdbook
[book]
authors = ["Remco Bloemen"]
language = "en"
multilingual = false
src = "src"
[build]
create-missing = false
[preprocessor.html]