Skip to content

Instantly share code, notes, and snippets.

View calvinchengx's full-sized avatar

Calvin Cheng calvinchengx

View GitHub Profile
calvinchengx /
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 /
Last active May 4, 2022 08:33
L610 linux driver experiment
sudo apt install git bc bison flex libssl-dev make
git clone --depth=1
# 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 contains correct idVendor and idProduct
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
curl --proto '=https' --tlsv1.2 -sSf | 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 /
Last active May 11, 2022 23:24
Install android sdk, ndk in headless ubuntu
rm commandlinetools-*.zip
sudo apt-get install libc6-dev-i386 lib32z1 openjdk-8-jdk build-essential --yes
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 /
Last active July 14, 2021 01:38
Installing cryptography and friends with poetry
# 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 openssl@1.1)/lib" CFLAGS="-I$(brew --prefix openssl@1.1)/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 / machine.js
Last active June 28, 2021 05:11
Generated by XState Viz:
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
calvinchengx / config.yml
Last active November 1, 2021 15:08
Example deploy using vercel token (.circleci/config.yml and .now/
defaults: &defaults
- image: circleci/node:12.14
working_directory: ~/tmp/circleci-now
version: 2
<<: *defaults