Skip to content

Instantly share code, notes, and snippets.

View WietseWind's full-sized avatar
⌨️
Focusing

Wietse Wind WietseWind

⌨️
Focusing
View GitHub Profile
@WietseWind
WietseWind / index.mjs
Created June 9, 2024 22:16
DH secp256k1 nodejs
import { createECDH } from 'crypto'
import elliptic from 'elliptic'
import { deriveAddress } from 'ripple-keypairs'
const curve = 'secp256k1'
const secp256k1 = elliptic.ec(curve)
const bytesToHex = a => a.map(byteValue => ('0' + byteValue.toString(16)).slice(-2)).join('')
const getPublic = echdObj => bytesToHex(secp256k1.keyFromPrivate(echdObj.getPrivateKey()).getPublic().encodeCompressed())
@WietseWind
WietseWind / hook.ts
Last active June 4, 2024 13:19
Sample JS Hook - using @xahau/hooks@1.0.7
import {
enableEmit,
getState,
setState,
prepareEmit,
doEmit,
log,
AnyJson,
} from '@xahau/hooks'
@WietseWind
WietseWind / index.mjs
Created June 3, 2024 09:45
256 bits, ED25519 keypair & XRPL account using 10-face dice roll, numbers 0-9 (78 throws)
import accountlib from 'xrpl-accountlib'
import assert from 'assert'
const requiredBits = 256
const requiredThrows = Math.ceil(requiredBits / Math.log2(10))
// Adapted from validator keypair dice tool by RichardAH
// https://github.com/RichardAH/validator-keys-from-dice/blob/main/dice.js
// Random (BAD RANDOM! BAD BAD BAD RANDOM! DO NOT EVER USE THIS!! TESTING PURPOSES ONLY!)
@WietseWind
WietseWind / gen.mjs
Created June 3, 2024 09:29
XRPL Account Generator (ED25519) with 78x 10-face Dice roll
import accountlib from 'xrpl-accountlib'
import elliptic from 'elliptic'
import assert from 'assert'
const ec = new elliptic.eddsa('ed25519')
// Adapted from validator keypair dice tool by RichardAH
// https://github.com/RichardAH/validator-keys-from-dice/blob/main/dice.js
// Random (BAD RANDOM! BAD BAD BAD RANDOM! DO NOT EVER USE THIS!! TESTING PURPOSES ONLY!)
const dicerolls = Array(78).fill().map(r => Math.floor(Math.random() * 10))
@WietseWind
WietseWind / sign-and-submit.mjs
Created May 29, 2024 22:00
Sign & Submit transactions on XRPL and Xahau (testnet, mainnet, multiple nodes)
import { derive, utils, prefilledSignAndSubmit, XrplClient } from "xrpl-accountlib"
const sample = 'xahauTestnet'
const sampleValues = {
xahauTestnet: {
account: derive.familySeed('sstWn1vCjnf6vFT87QHoYJpzYrdu9'),
nodes: [
new XrplClient('wss://xahau-test.net'),
new XrplClient('wss://hooks-testnet-v3.xrpl-labs.com'),
@WietseWind
WietseWind / index.html
Created May 25, 2024 00:40
WASI versions of ESBuild & QuickJS compiler for JS Hooks - fully client side
<! -- Demo here: https://zoq4jb3.dlvr.cloud/index.html -->
<html>
<head>
<style>
pre {
border: 1px solid red;
padding: 10px;
margin: 10px;
}
</style>
@WietseWind
WietseWind / patch.sh
Last active May 10, 2024 14:50
Detect CVE-2024-2961 and mitigage (tested: Ubuntu & Debian & Proxmox hosts) - Host / Docker containers
#!/bin/bash
# Detect CVE-2024-2961 and mitigage (tested: Ubuntu & Debian & Proxmox hosts)
# Wietse Wind 10-05-2024
# Based on the idea from https://raw.githubusercontent.com/mattaperkins/FIX-CVE-2024-2961/main/fix.sh
# ^^ Changes I made: auto detect file (several files eligible instead of one) & create back up of patched file
# Finds the right file and patches
# Safely run again to verify patch
# Run on host:
# curl https://gist.githubusercontent.com/WietseWind/9fe2eda3fece426bf873a4aeb15c4267/raw/patch.sh | bash
@WietseWind
WietseWind / update.sh
Last active April 24, 2024 17:31
Upate Xahaud node running xahaud natively (without Docker)
update=2024.4.21-release+858
cd /opt/xahaud/downloads/ && \
wget https://build.xahau.tech/"$update" && \
cd /opt/xahaud/bin && \
service xahaud stop && \
rm xahaud && \
ln -s ../downloads/$update ./xahaud && \
chmod +x ./xahaud && service xahaud start
@WietseWind
WietseWind / update.sh
Last active April 24, 2024 02:28
Xahaud RPC Mainnet Node (in Docker) binary update
update=2023.12.29-release+689
container=$(docker ps -a |grep xahau|cut -d " " -f 1)
build=$(docker exec -it $container /opt/xahaud/bin/xahaud -q --version|rev|cut -d "+" -f 1|rev|sed 's/[^0-9]*//g')
docker exec -it $container sh -c "curl https://build.xahau.tech/$update > /opt/xahaud/bin/new"
docker exec -it $container chmod +x /opt/xahaud/bin/new
newbuild=$(docker exec -it $container /opt/xahaud/bin/new -q --version|rev|cut -d "+" -f 1|rev|sed 's/[^0-9]*//g')
if [[ "$newbuild" -lt "$build" ]]; then
echo "Not OK, $build gt $newbuild"
@WietseWind
WietseWind / racadm.bash
Last active April 10, 2024 15:03
Install racadm on Ubuntu 20.04 / 18.04
wget http://archive.ubuntu.com/ubuntu/pool/universe/s/sblim-cmpi-devel/libcmpicppimpl0_2.0.3-0ubuntu2_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/multiverse/s/sblim-sfcb/sfcb_1.4.9-0ubuntu5_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/s/sblim-sfc-common/libsfcutil0_1.0.1-0ubuntu4_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/multiverse/c/cim-schema/cim-schema_2.48.0-0ubuntu1_all.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/o/openwsman/openwsman_2.6.5-0ubuntu3_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/s/sblim-sfcc/libcimcclient0_2.2.8-0ubuntu2_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/o/openwsman/libwsman-server1_2.6.5-0ubuntu3_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/o/openwsman/libwsman1_2.6.5-0ubuntu3_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/o/openwsman/libwsman-client4_2.6.5-0ubuntu3_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/o/openwsman/libwsman-curl-client-trans