Skip to content

Instantly share code, notes, and snippets.

View syuhei176's full-sized avatar
🎯
Focusing

Shuhei Hiya syuhei176

🎯
Focusing
View GitHub Profile
version: '3'
services:
ganache:
image: 0xorg/ganache-cli:6.5.10
ports:
- "8545:8545"
postgres:
image: postgres:9.6
environment:
- POSTGRES_USER=api
# cairo programming exercise
%builtins output pedersen
from starkware.cairo.common.alloc import alloc
from starkware.cairo.common.cairo_builtins import HashBuiltin
# compute H(x, y)
func compute_hash(hash_ptr : HashBuiltin*, x, y) -> (
hash_ptr : HashBuiltin*, z):
@syuhei176
syuhei176 / FastFinalityPredicate.vy
Created April 27, 2019 07:53
fast finality with predicate interface
# Plasma Fast Finality Contract with predicate interface
# see https://github.com/cryptoeconomicslab/plasma-chamber/wiki/Plasma-Fast-Finality for more description.
struct Merchant:
tokenAddress: address
amount: uint256
expiredAt: uint256
struct Dispute:
recipient: address
@syuhei176
syuhei176 / oddscal.sol
Created November 22, 2018 07:26
porker
function oddsCal(bytes52 a)
internal
pure
{
bool r3 = false;
uint8 r2 = 0;
for (uint i = 0;i < 13;i++) {
uint8 r = (a & (0x8004002001 << i));
if (r >= 3) {
// 3 card
@syuhei176
syuhei176 / rsa-acc.js
Last active September 3, 2022 07:44
RSA accumulator
const primeNumberList = require('prime-number/list')
const BigNumber = require('bignumber.js');
const utils = require('ethereumjs-util');
// const primeNumberList = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47];
BigNumber.config({
DECIMAL_PLACES: 2,
ROUNDING_MODE: BigNumber.ROUND_FLOOR
})
const crypto = require('crypto');
const EC = require('elliptic').ec;
const ec = new EC('secp256k1');
/**
* @dev MerkleTree
*/
class MerkleTree {
/**
@syuhei176
syuhei176 / beginner_zk_step1.js
Last active September 25, 2018 12:28
beginner zk
function add(a, b, c) {
return (hash(hash(a) + hash(b)) == hash(c));
}
function sub(a, b, c) {
return (hash(hash(a) - hash(b)) == hash(c));
}
function hash(a) {
if(a < 0) {
PlasmaDefinitions -> PlasmaDefinition PlasmaDefinitions
PlasmaDefinition -> DepositDefinition | WithdrawDefinition | TxDefinition
DepositDefinition -> (root chain assets) TXO
WithdrawDefinition -> TXO (root chain assets)
TxDefinition -> Transition TxDefinition
Transition-> TXO Tx TXO
TXO -> status TXO
status -> type(expressions) value
Tx -> type(params) signers guard | ε
guard -> expressions
@syuhei176
syuhei176 / erc20token.sol
Last active August 24, 2018 22:20
Exitable account state version
contract StandardToken is ERC20 {
using SafeMath for uint256;
uint256 private totalSupply_;
account[uint256] private balance;
account[address] private allowed;
/**
@syuhei176
syuhei176 / atomicswap.liq
Last active August 12, 2018 23:40
atomicswap liquidity
(* atomic swap *)
[%%version 0.3]
type state =
| Empty
| Initiator
| Participant
type initiate = {