Skip to content

Instantly share code, notes, and snippets.

View recmo's full-sized avatar

Remco Bloemen recmo

View GitHub Profile

Merkle Tree

https://en.wikipedia.org/wiki/Merkle_tree

image

A Merkle tree is a binary tree where each node's value is calculated by concatenating and hashing both of it's child leaves: sha256(left_child + right_child). Uninitialized leafs should have the value of a hash of an empty string: sha256('').

Example

@Haseeb-Qureshi
Haseeb-Qureshi / snargs.md
Created October 10, 2018 19:51
Transaprent Succinct Arguments @ CESC

Transparent Succinct Arguments

Alessandro Chiesa (UC Berkeley, Starkware, Zcash)

What are succinct arguments?

  • Proofs of computational integrity
  • Game between prover and verifier
  • Prover knows an input to a F(x) that would make it return y
  • Prover could trivially prove this by providing x
    • This convinces the verifier for sure!
  • Being able to convince the verifier of a true claim is the property of completeness
@pdyraga
pdyraga / benchmark.md
Last active May 18, 2022 16:16
Parity benchmarks (24 Sep 2018)

About the benchmarks

The Parity client benchmarks are based on the work of Martin Holst Swende done 21 July 2018 for Constantinopole. The new benchmarks have been done for 2.1.1-beta version released 20 September 2018 as well as for master branch (branch as of 25 Oct - 5a1dc3e) with bn dependency pointing to version before and after the optimalisations by Andre Silva

If we compare pre- and post- benchmarks we see there is a significant performance boost justifying reduction of gas prices for ecmul and ecadd operations. Also, pairing is ~2.82 times faster when we compare Martin's benchmark and version 2.1.1-beta what also suggests that pairing gas cost can be reduced.

Martin's benchmark (21 Jul)

Name Gascost Time (ns) MGas/S Gascost for 10MGas/S Gascost for ECDSA eq
/**
* @dev OpcodeChecker processes contract code to generate a bitmap of used opcodes.
*
* DO NOT USE: See the vulnerability identified by Recmo below. A patch will be provided soon.
*
* The generated bitmap can be used to enforce whitelisting and blacklisting on contract code.
* Bit n of the bitmap is set iff opcode n is used. For instance, the presence of the STOP opcode
* will result in bit 0 of the bitmap being set.
*
* A best-effort attempt is made to skip over unreachable data, but there may be false positives.
@chriseth
chriseth / snarktest.solidity
Last active December 3, 2023 07:03
zkSNARKs test code
// This file is MIT Licensed.
//
// 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 FROM, OUT OF O
@VictorTaelin
VictorTaelin / ethereum_delayed_computations.md
Last active April 12, 2018 16:42
Make Ethereum massively scalable today with delayed computations

Make Ethereum massively scalable today with delayed computations

Suppose you're writing a contract which involves a huge amount of participants. As an example, think of an online, blockchain-based Trading-Card Game with tournaments. How would you program a playCard function? You might be thinking of something like this:

function playCard(uint player, uint card){
    ...
    else if (card == PROFESSOR_OAK){
        // shuffles the player's hand on his deck
 shuffleHand(player)
@TUSF
TUSF / Valbli Orthography.md
Last active May 3, 2024 06:34
A draft for a block writing system, designed for Lojban.

https://tusf.page/valbli

(Note: This is a draft, and subject to change.)

Many writing systems have been proposed for Lojban. Hangul is the writing system used in Korean, and potentially a great option to use for Lojban. It's a featural writing system, meaning that most of its symbols are chosen for a reason, and not just arbitrarily. The most attractive feature of Hangul is the syllable-blocks that well compress the language.

/**
* Base contract that all upgradeable contracts should use.
*
* Contracts implementing this interface are all called using delegatecall from
* a dispatcher. As a result, the _sizes and _dest variables are shared with the
* dispatcher contract, which allows the called contract to update these at will.
*
* _sizes is a map of function signatures to return value sizes. Due to EVM
* limitations, these need to be populated by the target contract, so the
* dispatcher knows how many bytes of data to return from called functions.