Skip to content

Instantly share code, notes, and snippets.

@LCamel
LCamel / PickOne.circom
Created February 9, 2023 14:23
PickOne
pragma circom 2.1.2;
include "circomlib/multiplexer.circom";
template PickOne(N) {
signal input in[N];
signal input sel;
signal output out;
component mux = Multiplexer(1, N);
@LCamel
LCamel / PickOneFromEachRow.circom
Created February 9, 2023 14:15
PickOneFromEachRow
pragma circom 2.1.2;
include "circomlib/multiplexer.circom";
template PickOneFromEachRow(ROWS, COLS) {
signal input in[ROWS][COLS];
signal input whichCol[ROWS];
signal output out[ROWS];
component selCol[ROWS];
@LCamel
LCamel / Mux2D.circom
Last active February 9, 2023 13:48
Mux2D
pragma circom 2.1.2;
include "circomlib/multiplexer.circom";
// get in[row][column]
template Mux2D(ROWS, COLS) {
signal input in[ROWS][COLS];
signal input row;
signal input column;
signal output out;
@LCamel
LCamel / A.sol
Created February 8, 2023 09:57
Poseidon library / contract hack
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
// HACK: PROTOTYPING ONLY: use "contract" with a fixed address to avoid compiler library settings
contract Poseidon4 {
function poseidon(uint256[4] memory) public pure returns (uint256) {}
}
// goerli: after block 8166444
Poseidon4 constant P = Poseidon4(0x3b44AA63Ac599170357dC587880fC30E506612e7);
@LCamel
LCamel / 10M_items.txt
Created January 20, 2023 15:41
HashTower Simulation
Simulation of add() 10,000,000 items:
For each add() call:
average storage read = 2.33 slots
average storage write = 2.33 slots
average hash call = 0.33 times (PoseidonT5)
lv 19 _ _ _ _
lv 18 _ _ _ _
lv 17 _ _ _ _
@LCamel
LCamel / HashTower.mjs
Last active January 18, 2023 13:31
HashTower (WIP)
"use strict";
import { poseidon } from "circomlibjs"; // for off-line computing
//import { groth16 } from "snarkjs";
//import { ethers } from "ethers";
const MAX_LEVELS = 32;
class HashTower {
constructor(hashInputCount) {
this.hashInputCount = hashInputCount;
@LCamel
LCamel / __CREATE2__CREATE__.md
Last active August 20, 2022 14:14
CREATE2 and CREATE
@LCamel
LCamel / __CREATE2__.md
Last active August 10, 2022 23:02
CREATE2 demo
@LCamel
LCamel / __INIT__.md
Last active August 10, 2022 11:52
init demo
@LCamel
LCamel / AAA.java
Created August 21, 2021 09:53
Bingo
import java.util.Arrays;
import java.util.Random;
public class AAA {
public static void main(String[] args) {
boolean[] board = new boolean[25];
int n = 0;
int N = 1000000;
for (int i = 0; i < N; i++) {
pick(board, 14);