Skip to content

Instantly share code, notes, and snippets.

Succinct Open Source Challenge

Working with variable length computations in a circuit is tricky because of the requirement to have a fixed computational graph. This challenge is to implement variable length SHA256 as a circuit. The circuit should have a public input called input_bytes: a fixed size array of size 10 with 32 byte entries. The other public input should be length: how many of the array entries should be hashed. The circuit output should be the sha256 hash of the first length entries in the array. You should only hash length * 32 bytes, and do not hash any extra zero bytes (this is the tricky part to figure out)! Golang pseudocode below:

func VariableLengthHash(input_bytes [10][32]byte, length int) [32]byte {
	// Concatenate the bytes
	var concatenatedBytes []byte
	for i := 0; i < length; i++ {
 concatenatedBytes = append(concatenatedBytes, input_bytes[i]...)
{
"status": "OK",
"data": [
{
"aggregationbits": "0xffffffffffffffffffffffffffffffffffffffffffffffff3f",
"beaconblockroot": "0xce57b5c0e875a284df571fa91e85ab48a65810dfab101e299e509e1c09ed2021",
"block_index": 0,
"block_root": "0x2377b2a309484ed006d39c6ff8b2905b93fb7c329d22eb63deede6a5059e9ca4",
"block_slot": 4235152,
"committeeindex": 47,
➜ build git:(main) ✗ /usr/local/bin/g++-11 -I. -I../src -I../depends/ffiasm/c -I../depends/json/single_include -I/usr/local/include ../src/main_prover.cpp ../src/binfile_utils.cpp ../src/zkey_utils.cpp ../src/wtns_utils.cpp ../src/logger.cpp ../depends/ffiasm/c/misc.cpp ../depends/ffiasm/c/naf.cpp ../depends/ffiasm/c/splitparstr.cpp ../depends/ffiasm/c/alt_bn128.cpp fq.cpp fq.o fr.cpp fr.o -o prover -fmax-errors=5 -std=c++17 -pthread -lgmp -lsodium -O3 -fopenmp
../src/binfile_utils.cpp: In constructor 'BinFileUtils::BinFile::BinFile(std::string, std::string, uint32_t)':
../src/binfile_utils.cpp:28:68: error: 'MAP_POPULATE' was not declared in this scope; did you mean 'MAP_PRIVATE'?
28 | void *addrmm = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE | MAP_POPULATE, fd, 0);
| ^~~~~~~~~~~~
| MAP_PRIVATE
../src/logger.cpp: In constructor 'CPlusPlusLogging::Logger:
@puma314
puma314 / merkle.py
Created December 18, 2021 22:26
A sample implementation of a Merkle tree in Python
'''
A sample implementation of a Merkle tree in Python.
'''
DEPTH = 3
def simple_hash(*arr):
body = ','.join(sorted(arr))
return '({})'.format(body)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import itertools
# line = map(int, raw_input().split(" "))
# n = line[0]
# m = line[1]
n = 8
m = 3
hplaces = 0
mplaces = 0
i = 0
f = open('3.in')
i = f.readline()
f.close()
dic = {}
def ways(s):
if s in dic.keys():