Skip to content

Instantly share code, notes, and snippets.

View oleganza's full-sized avatar

Oleg Andreev oleganza

View GitHub Profile
@oleganza
oleganza / bulletproofs_battleships.md
Last active October 8, 2018 22:10
Bulletproofs Battleships

Bulletproofs battleships

Rules

  1. Each player has a board of 10x10 slots.
  2. Each player has to place 5 ships, sizes of 1, 2, 3, 4 and 5 slots.
  3. Ships can be oriented vertically or horizontally.
  4. Ships cannot overlap.

Goal

Exchanges and web wallets do not need "cold" and "hot" storage. They need 2-of-3 multisig lock.
1. User's funds are locked on 2-of-3 multisig transaction (P2SH or directly, does not matter).
2. Key A belongs to user (similarly to Blockchain.info, service may backup the encrypted key, but user loses key when forgets the password).
3. Key B is stored on web server, unencrypted.
4. Key C belongs to technical staff of the service. This key is encrypted by staff's password and only stored on personal computers of the staff.
@oleganza
oleganza / sign.c
Created April 8, 2017 00:01
NaCl 20110221
#include "api.h"
#include "crypto_sign.h"
#include "crypto_hash_sha512.h"
#include "randombytes.h"
#include "crypto_verify_32.h"
#include "ge25519.h"
int crypto_sign_keypair(
unsigned char *pk,
@oleganza
oleganza / impulse_review.md
Last active January 23, 2016 06:24
Impulse Review

(That's my attempt to understand what problem Impulse solves and how. I am not a designer/developer of this scheme.)

Problem

Regular Bitcoin transactions are not guaranteed until mined sufficiently deep in the blockchain. Unconfirmed transactions can be observed nearly instantly, but they cannot be trusted (could drop out because of insufficient fees, or double-spent).

Impulse Overview

[Author: garyrowe https://bitcointalk.org/index.php?topic=89772.msg988857#msg988857]
Your post advocates a
( ) technical ( ) legislative ( ) market-based ( ) vigilante
approach to stopping Bitcoin. Your idea will not work. Here is why it won't work. One or more of the following may apply to your particular idea, and it may have other flaws which vary from country to country due to their own legal systems:
( ) Scammers can easily use it to bilk unsuspecting consumers/merchants
( ) Merchants and other legitimate businesses would be adversely affected
Future of Bitcoin mining is specialized factories plugging chips in right after baking them.
These factories would work on the same profit margin as any other stable business.
Motivation to play honestly whould be right there: the value of produced bitcoins
is in their fungibility. Any censorship by the miners will be hurting them first.
And misbehaving miners are too easy to ostracize and drive out of business completely.
// I'd like Clang to compile this:
self.view.frame.origin.x = 0;
// Into this:
{
UIView* v = self.view;
CGRect f = [v frame];
f.origin.x = 0;
@oleganza
oleganza / bitcoin-wtf.txt
Created August 24, 2013 19:56
Some WTF moments when reading BitcoinQT source code. It's not to insult people, but to help others quickly understand why some things are done in some way.
1. CheckSig function and a dozen other pass around nHashType argument which means nothing - the nHashType is always read from the last byte of the signature. Nowhere in the code non-zero value is passed and even if it was passed, it must match the last byte.
if (nHashType == 0)
nHashType = vchSig.back();
else if (nHashType != vchSig.back())
return false;
2. OP_CODESEPARATOR cannot be meaningfully used, but we have to account for it till the end of times when computing a portion of a script for signature verification.
@oleganza
oleganza / tinkoff
Last active December 20, 2015 20:59
1. Человек А подделывает договор с человеком Б и идет к хорошо вооруженному человеку Ц
чтобы тот, доверяя подделке, отобрал деньги силой у человека Б.
2. Человек Б идет к хорошо вооруженному человеку Ц и просит не только не отбирать у него деньги,
но и затолкать человека А силой в клетку.
3. Люди X, Y и Z начинают симпатизировать человеку А и ругают человека Б за то,
что он угрожает человеку А.
4. Человек Б начинает хамить всем, кто недоволен его поведением.
If you tinkered with Info.plist trying to make your document type *actually* display your icon and open in your app, you probably fucked up your machine (restart won't help).
1. Go and remove your types from ~/Library/Preferences/com.apple.LaunchServices.plist
2. Restart LaunchServices: $ /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user
3. Check if your types are removed: $ defaults read com.apple.LaunchServices LSHandlers | grep mytype
If they are not removed yet, wait a minute and check again. LS takes time to actually reload.
Clean up your Xcode build and try again. This time created file should get proper association with your app and display a right icon.