Skip to content

Instantly share code, notes, and snippets.

View calvinchengx's full-sized avatar
:octocat:
Focusing

Calvin Cheng calvinchengx

:octocat:
Focusing
View GitHub Profile
@calvinchengx
calvinchengx / dkg_and_dks.rs
Last active May 26, 2024 19:52
Threshold Signature Scheme
use aes::Aes256;
use block_modes::block_padding::Pkcs7;
use block_modes::{BlockMode, Cbc};
use bls_signatures::{AggregateSignature, Signature};
use pallier::Pallier;
use rand::Rng;
use rug::Integer;
type Aes256Cbc = Cbc<Aes256, Pkcs7>;
@calvinchengx
calvinchengx / experiment.sh
Last active May 4, 2022 08:33
L610 linux driver experiment
#!/bin/bash
sudo apt install git bc bison flex libssl-dev make
git clone --depth=1 https://github.com/raspberrypi/linux
# Launch dmesg -wT and connect the modem to iBlocker (via USB cable)
# Result: usb 1-1.3: New USB device found, idVendor=1782, idProduct=4d12, bcdDevice= 0.00
# Check that below line in L610_linux_driver.sh contains correct idVendor and idProduct
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
rustup default nightly
# linux build, with openssl
sudo apt update && sudo apt install pkg-config libssl-dev
cargo build --release --lib
@calvinchengx
calvinchengx / android.sh
Last active May 11, 2022 23:24
Install android sdk, ndk in headless ubuntu
#!/bin/bash
rm commandlinetools-*.zip
sudo apt-get install libc6-dev-i386 lib32z1 openjdk-8-jdk build-essential --yes
wget https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip
unzip commandlinetools-linux-8092744_latest.zip
export ANDROID_HOME=$HOME/Android
pragma solidity ^0.4.21;
contract SimpleERC20Token {
// Track how many tokens are owned by each address.
mapping (address => uint256) public balanceOf;
string public name = "Simple ERC20 Token";
string public symbol = "SET";
uint8 public decimals = 18;
@calvinchengx
calvinchengx / install.sh
Last active July 14, 2021 01:38
Installing cryptography and friends with poetry
#!/bin/bash
# initialise and configure a pyproject.toml file (similar to Cargo.toml)
poetry init
# python's cryptography package requires openssl and rust
brew install openssl rust
env LDFLAGS="-L$(brew --prefix [email protected])/lib" CFLAGS="-I$(brew --prefix [email protected])/include" poetry add cryptography
# then the rest
const feedbackMachine = Machine({
id: 'feedback',
initial: 'question',
states: {
question: {
on: {
CLICK_GOOD: 'thanks',
CLICK_BAD: 'form',
CLOSE: 'closed'
}
@calvinchengx
calvinchengx / machine.js
Last active June 28, 2021 05:11
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@calvinchengx
calvinchengx / config.yml
Last active November 1, 2021 15:08
Example deploy using vercel token (.circleci/config.yml and .now/linkproject.sh)
defaults: &defaults
docker:
- image: circleci/node:12.14
working_directory: ~/tmp/circleci-now
version: 2
jobs:
checkout:
<<: *defaults
steps: