Skip to content

Instantly share code, notes, and snippets.

View samcamwilliams's full-sized avatar

Sam Williams samcamwilliams

View GitHub Profile
@samcamwilliams
samcamwilliams / rx_bitmap_sim.erl
Last active December 1, 2024 23:58
An Erlang simulator of the effectiveness of bitmap attacks on RandomX scratchpad entropy, given various parameters. It also simulates these attacks against RandomXSquared; a new algorithm that optimizes the resilience of RandomX entropy generation by mixing entropy (optionally across multiple parallel RX instances) periodically.
-module(rx_bitmap_sim).
-compile(export_all).
%%% A simple simulator for the RX and RX2 scratchpad bitmap attacks.
%%% run `rx_bitmap_sim:create_report(ProgCount, Divisions)` to see the sizes of bitmaps
%%% that would be needed in order to reconstruct the scratchpad from the
%%% bitmap for N RandomX programs, with D divisions of the programs.
% The number of RX memory cells in the scratchpad.
-define(SCRATCHPAD_CELLS, 262144).
@samcamwilliams
samcamwilliams / launch.json
Created September 7, 2024 04:59
Run rebar3 + Erlang in debug mode inside VS Code for LLDB debugging. This is useful for debugging linked-in drivers (and possibly NIFs, too). It is a ghastly construction, but it works (assuming you update the paths of course). The '--' twice is very strange but necessary. It seems that both lldb and Erlang using '--' as a signifier for their ar…
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/../otp/bin/aarch64-apple-darwin22.6.0/beam.debug.smp",
"args": [
"--", "--",
@samcamwilliams
samcamwilliams / receive-tests.lua
Created July 8, 2024 05:41
Extremely crude tests for AOS's new process+message management API.
function CreateBasicCO()
return coroutine.create(function ()
print("Coroutine started")
Send({ Target = ao.id, Action = "TestMessage" })
local msg = BasicReceive({ Target = ao.id, Action = "TestMessage" })
X = msg
print(msg)
print("Started again. Respond to stuff here.")
return msg
end)
const Arweave = require('arweave');
const arweave = Arweave.init({ host: 'arweave.net', protocol: 'https', port: 443 });
const fs = require('fs');
const deepHash = require('arweave/node/lib/deepHash');
const ArweaveBundles = require('arweave-bundles');
const deps = {
utils: Arweave.utils,
crypto: Arweave.crypto,
const fs = require('fs')
const Arweave = require('arweave/node')
const argv = require('yargs').argv
const arweave = Arweave.init({
host: argv.arweaveHost ? argv.arweaveHost : 'arweave.net',
port: argv.arweavePort ? argv.arweavePort : 443,
protocol: argv.arweaveProtocol ? argv.arweaveProtocol : 'https'
})
@samcamwilliams
samcamwilliams / Physical-Asset-NFT.js
Created January 8, 2021 03:22
A Verto-compatible SmartWeave contract for trading physical assets.
export function handle (state, action) {
const owner = state.owner
const input = action.input
const caller = action.caller
const contact = action.contact
if (input.function === 'transfer') {
const target = input.target
if (!target || (caller === target)) {
@samcamwilliams
samcamwilliams / CryptoVoxelsArchive.sh
Created November 21, 2020 02:52
Download the state of all land parcels in CryptoVoxels and deploy them to the Arweave's permaweb. Path to your Arweave keyhole must be changed in the `arweave deploy` line.
#!/bin/bash
mkdir -p CryptoVoxelsArchive/parcels
echo "Downloading map info..."
curl -s 'https://www.cryptovoxels.com/api/parcels.json' > CryptoVoxelsArchive/parcels.json
curl -s 'https://www.cryptovoxels.com/api/suburbs.json' > CryptoVoxelsArchive/suburbs.json
curl -s 'https://www.cryptovoxels.com/api/islands.json' > CryptoVoxelsArchive/islands.json
pragma solidity ^0.5.1;
contract EdLock {
address payable honeypot;
uint unlockTime;
uint payoutQty;
uint payoutQtySteal;
address payable[] payoutAddrs;
bool paidOut = false;
@samcamwilliams
samcamwilliams / keyboard_morse
Last active January 1, 2017 20:12
An Erlang script that uses morse code to send messages to @lelandbatey's keyboard.
#!/usr/bin/env escript
%%% USAGE: ./keyboard_morse STRING
%%% Uses morse code to send messages to a keyboard light that flashes
%%% when a web server request is made. See here[1] for details.
%%% This script could be modified to communicate with other kinds of
%%% devices by changing the emit_flash/0 function.
%%%
%%% [1] http://lelandbatey.com/posts/2016/12/Making-lights-blink-for-each-HTTP-request/