Skip to content

Instantly share code, notes, and snippets.

View kushti's full-sized avatar

Alexander Chepurnoy kushti

View GitHub Profile

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea

@chriseth
chriseth / BinarySearch.sol
Last active August 3, 2022 19:22
Verified binary search in sorted array
contract BinarySearch {
///@why3
/// requires { arg_data.length < UInt256.max_uint256 }
/// requires { 0 <= to_int arg_begin <= to_int arg_end <= arg_data.length }
/// requires { forall i j: int. 0 <= i <= j < arg_data.length -> to_int arg_data[i] <= to_int arg_data[j] }
/// variant { to_int arg_end - to_int arg_begin }
/// ensures {
/// to_int result < UInt256.max_uint256 -> (to_int arg_begin <= to_int result < to_int arg_end && to_int arg_data[to_int result] = to_int arg_value)
/// }
/// ensures {
@benjiqq
benjiqq / local.md
Last active August 29, 2015 14:05
blockchains and local information

Blockchains and local information

GHOST [1] proposes sub-trees for Bitcoin transaction processing. Here I will argue that Sompolinsky & Zohar misunderstand the role of latency and the global view problem (variant of Byzantine General's problem). Essentially all nodes in the P2P network have to operate on an equal basis in terms of spacial distribution. The topic is little discussed, but was one essential ingredient for creating the first network. In the following I will assume that all miners have equal hashing-power (no problem of centralization in terms of hashing-power). The nodes (N) are a P2P network, but I will specifically look at the role of geo-location. This relates to the first studies by Lamport on the topic of time and partial orders [2]. The Bitcoin blockchain implements Lamport's partial order (what Szabo called logical broadcast), of course with the crucial connection to property.

Assume that some sub-section of miners (S), of all miners (N) have an advantage over othe

@benjiqq
benjiqq / exchanges.md
Last active August 29, 2015 14:05
exchanges, centralization and P2P

Exchanges and blockchain P2P networks

In the cryptocurrency community there has been a lot of interest in the potential for decentral exchanges for various financial instruments (futures, stocks, etc.). This short article points on some crucial issues with regards to moving from a digital cash system to a more complete global economic network (econet).

Blockchains and transaction order

Blockchain based P2P networks allows for unordered transactions (Tx). The transactions have a partial order as described by Lamport in 1978 in [1]. The blockchain can be seen as creating this partial order. While transactions in one block don't have an order, the blocks of tx themselves are ordered. The Bitcoin blockchain realizes Lamport's partial order, combining it with a undestructable datastore (see also [2]).

@doctorevil
doctorevil / review.md
Last active February 13, 2021 15:30
NXT Crypto Review of Curve25519.java & Crypto.java

Crypto Review of Curve25519.java & Crypto.java

By DoctorEvil on Nextcoin.org

Sponsored by MSIN on BitcoinTalk.org

TL;DR

NXT's Crypto.java and Curve25519.java look kosher aside from a signing bug that is currently being worked around.

General Methodology

@karlgluck
karlgluck / Hash Ladders for Shorter Lamport Signatures.md
Last active March 31, 2024 17:53
I describe a method for making Lamport signatures take up less space. I haven't seen anyone use hash chains this way before, so I think it's pretty cool.

What's this all about?

Digital cryptography! This is a subject I've been interested in since taking a class with Prof. Fred Schneider back in college. Articles pop up on Hacker News fairly often that pique my interest and this technique is the result of one of them.

Specifically, this is about Lamport signatures. There are many signature algorithms (ECDSA and RSA are the most commonly used) but Lamport signatures are unique because they are formed using a hash function. Many cryptographers believe that this makes them resistant to attacks made possible by quantum computers.

How does a Lamport Signature work?