Skip to content

Instantly share code, notes, and snippets.

View yongkangc's full-sized avatar
🎃
Focusing

Chia Yong Kang yongkangc

🎃
Focusing
View GitHub Profile
// *************************
// HEAP
// *************************/
// HEAP is an array of bytes (JS ArrayBuffer)
const word_size = 8
// heap_make allocates a heap of given size
// (in bytes) and returns a DataView of that,
@yongkangc
yongkangc / chatgpt.rs
Last active November 9, 2023 08:23
ChatGPT in Rust
use reqwest::header::{HeaderMap, AUTHORIZATION, CONTENT_TYPE};
use reqwest::Client;
use serde::{Deserialize, Serialize};
use std::env;
#[derive(Serialize, Deserialize, Debug)]
struct OAIRequest {
model: String,
messages: Vec<Message>,
}
@yongkangc
yongkangc / Add.sol
Created August 28, 2023 04:24
Add.sol
pragma solidity 0.6.7
contract AddOne {
uint16 private a = 3;
function aPlusOne() external view returns(uint 256) {
return a + 1;
}
@yongkangc
yongkangc / Add.sol
Last active August 28, 2023 04:52
Sample Opcode contract
pragma solidity 0.8.7;
contract AddOne {
uint16 private a = 3;
function aPlusOne() external view returns(uint 256) {
unchecked {
return a + 1;
}
}
@yongkangc
yongkangc / UniswapV3TimeLock.sol
Created July 21, 2023 05:24
UniswapV3 Liquidity Time Lock contract
// File: contracts/interfaces/UniswapInterfaces.sol
// File @uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol@v1.0.0
pragma solidity >=0.5.0;
/// @title Pool state that never changes
@yongkangc
yongkangc / TimeLock.sol
Created July 20, 2023 04:32
TimeLock Contract
// Sources flattened with hardhat v2.17.0 https://hardhat.org
// File @openzeppelin/contracts/utils/introspection/IERC165.sol@v4.9.2
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;

Feel free to copy and paste this list into a README, issue or elsewhere in your project.

Audit prep checklist (reference)

  • Documentation (A plain english description of what you are building, and why you are building it. Should indicate the actions and states that should and should not be possible)
    • For the overall system
    • For each unique contract within the system
  • Clean code
  • Fix compiler warnings

Feel free to copy and paste this list into a README, issue or elsewhere in your project.

Audit prep checklist (reference)

  • Documentation (A plain english description of what you are building, and why you are building it. Should indicate the actions and states that should and should not be possible)
    • For the overall system
    • For each unique contract within the system
  • Clean code
  • Fix compiler warnings
@yongkangc
yongkangc / circuit.circom
Last active August 31, 2022 10:10
zkSBT
pragma circom 2.0.6;
include "circomlib/poseidon.circom";
// include "https://github.com/0xPARC/circom-secp256k1/blob/master/circuits/bigint.circom";
template Example () {
signal input a;
signal input b;
signal output c;
@yongkangc
yongkangc / merkle-tree-naive.py
Last active August 22, 2022 10:04
Progression of ZK
import hashlib
from math import log2, ceil
def hash_string(s):
return hashlib.sha256(s.encode()).hexdigest()
class MerkleTree:
"""
A naive Merkle tree implementation using SHA256
"""