Skip to content

Instantly share code, notes, and snippets.

View YHTerrance's full-sized avatar
🎯
Focusing

Terrance Chen YHTerrance

🎯
Focusing
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@YHTerrance
YHTerrance / verifier.sol
Created May 29, 2022 10:42
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
//
// Copyright 2017 Christian Reitwiessner
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FRO
@YHTerrance
YHTerrance / calculator-p.zok
Last active June 1, 2022 13:48
2022 DeFi - Zokrates Calculator
// -- Parameters --
const u32 MAX_OPS = 16
const u32 MAX_STACK_ = 8
// workaround for not having short-circuit in the branch
const u32 STACK_OFFSET = 8
const u32 MAX_STACK = MAX_STACK_ + STACK_OFFSET
const u32 MAX_OPS_ = MAX_OPS + 1
// --- OPs ---
const field OP_PUSH = 42 // push next value into the stack
@YHTerrance
YHTerrance / 0rollup.zok
Created May 29, 2022 13:42
2022 DeFi - Zokrates P2PKH
from "./common" import u8_to_bools, u8_to_field
from "./vm" import vm, emptyInitialStack, Context, MAX_STACK, MAX_OPS
/*
Sample argument for computing witness
118 170 76 184 85 21 15 28 0 104 44 142 218 184 158 115 6 120 21 76 202 167 81 100 214 76 30 125 210 94 123 21 40 125 59 47 136 172 76 38 179 111 37 50 120 145 7 219 194 188 19 95 33 104 143 170 119 14 53 228 164 173 121 166 166 81 237 54 0 123 36 76 0 205 79 77 188 55 22 128 25 145 43 31 216 144 86 220 184 236 189 91 137 174 83 36 112 66 142 122 170 17 236 175 76 9 83 22 81 252 204 173 20 37 221 161 14 122 87 32 252 42 111 154 66 109 144 10 228 43 38 189 94 122 178 241 176 76 4 8 82 119 222 136 35 12 91 99 146 114 97 181 165 210 192 99 82 145 104 59 46 208 76 119 79 188 61 243 148 130 124 213 43 70 108 216 146 69 24 240 113 114 192 248 198 149 198 76 15 119 193 19 87 180 97 215 135 239 49 134 74 22 63 57 149 723058736 1843701591 1072936076 3036496655 3339662838 129684144 3842486204 1060083354 1719969981 2671094214 3733828187 23882685 1040072389 249589
[
{
"inputs": [
{
"components": [
{
"components": [
{
"internalType": "uint256",
"name": "X",
package main
import (
"fmt"
"github.com/shirou/gopsutil/cpu"
"time"
)
type TimesStat struct {
CPU string json:"cpu"
@YHTerrance
YHTerrance / Solver.sol
Created November 13, 2022 00:59
This is the solver for FinTech 2022 Homework 4 Problem 4
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract Solver {
bytes32[] public hashes;
bytes32[] public proof;
constructor() {