Skip to content

Instantly share code, notes, and snippets.

View kushti's full-sized avatar

Alexander Chepurnoy kushti

View GitHub Profile
@kushti
kushti / BlockGenerator.scala
Last active August 29, 2015 14:11
QORA's BlockGenerator rewritten into Scala language
package qora
import java.math.BigDecimal
import java.math.BigInteger
import ntp.NTP
import qora.account.PrivateKeyAccount
import qora.block.Block
import qora.block.BlockFactory
import qora.crypto.Crypto
import qora.transaction.Transaction
@kushti
kushti / BitcoinJ.scala
Created December 29, 2014 13:26
BitcoinJ
package actors
import java.io.File
import java.util
import java.util.concurrent.TimeUnit
import akka.actor.Actor
import com.google.common.util.concurrent.{FutureCallback, Futures}
import org.bitcoinj.core._
import org.bitcoinj.net.discovery.DnsDiscovery
2015-01-09 21:44:40 INFO: Nxt server 1.4.7 started successfully.
2015-01-09 22:04:02 INFO: nxt.apiServerEnforcePOST = "true"
2015-01-10 08:20:06 WARNING: DOS ALERT: Request delayed=1000ms, ip=188.165.250.19, session=null, user=null
2015-01-10 08:20:06 WARNING: DOS ALERT: Request delayed=1000ms, ip=188.165.250.19, session=null, user=null
2015-01-10 08:20:06 WARNING: DOS ALERT: Request delayed=1000ms, ip=188.165.250.19, session=null, user=null
2015-01-10 08:20:06 WARNING: DOS ALERT: Request delayed=1000ms, ip=188.165.250.19, session=null, user=null
2015-01-10 14:59:32 WARNING: /nxt
java.io.IOException: java.util.concurrent.TimeoutException: Idle timeout expired: 30001/30000 ms
at org.eclipse.jetty.util.SharedBlockingCallback$Blocker.block(SharedBlockingCallback.java:234)
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:136)
@kushti
kushti / Scorex-BlockGenerator.scala
Created February 28, 2015 01:11
Scorex-BlockGenerator.scala
package scorex
import akka.actor.Actor
import com.google.common.primitives.{Bytes, Longs}
import controller.Controller
import database.{PrunableBlockchainStorage, UnconfirmedTransactionsDatabaseImpl}
import ntp.NTP
import scorex.account.PrivateKeyAccount
import scorex.block.{Block, BlockStub}
import scorex.crypto.Crypto
@kushti
kushti / flp-old.v
Created June 4, 2015 12:38
Old & failed attempt to formalize the FLP theorem
(** FLP Impossibility Proof **)
(** Made after original paper http://cs-www.cs.yale.edu/homes/arvind/cs425/doc/fischer.pdf **)
(** described more informally in the awesome blogpost http://the-paper-trail.org/blog/a-brief-tour-of-flp-impossibility/ **)
(** also constructive proofs: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.221.7907&rep=rep1&type=pdf **)
(** and http://www.cs.cornell.edu/courses/cs7412/2011sp/ConsensusRebecca.pdf **)
Require Import Arith.
Require Import List.
Require Import Coq.Arith.EqNat.
Require Import Coq.Lists.ListSet.
package scorex.newstate
import akka.actor.{Actor, ActorRef}
import scorex.api.http.ApiRoute
import scorex.serialization.BytesSerializable
import scorex.transaction.box.proposition.Proposition
import shapeless.HList
import scala.util.Try
@kushti
kushti / task.md
Created September 23, 2016 18:01

A Proof of a Product (Scala Team Test Task)

Alice knows an integer number A. Bob knows an integer number B. Both do not want to share the numbers with each other but want Carroll to compute multiplication result A * B. Both Alice and Bob do want to check that Carroll produces a correct product of the numbers given.

The parties conclude to follow the protocol below.

  1. The broker (Carroll) is starting the interaction by sending invitations to the users (Alice and Bob).
extern crate ethcore_util;
#[macro_use] extern crate log;
extern crate time;
use time::PreciseTime;
use ethcore_util::hash::*;
use ethcore_util::bytes::*;
use ethcore_util::trie::*;
def lookupTest() {
val kl = 7
val vl = 4
val p = new BatchAVLProver(keyLength = kl, valueLength = vl)
val key1 = Sha256("1").take(kl)
val key2 = Sha256("2").take(kl)
val key3 = Sha256("3").take(kl)
val key4 = Sha256("4").take(kl)
def lookupTest() {
val kl = 4
val vl = 7
val p = new BatchAVLProver(keyLength = kl, valueLength = vl)
val key1 = Sha256("1").take(kl)
val key2 = Sha256("2").take(kl)
val key3 = Sha256("3").take(kl)