Skip to content

Instantly share code, notes, and snippets.

View kushti's full-sized avatar

Alexander Chepurnoy kushti

View GitHub Profile
package sigmastate
import scorex.crypto.hash.Sha256
object LotteryWinner extends App {
val participantsRaw =
"""_jonwel_
504_Saints
a_atapin
object MptBench extends App {
val dbPath = Files.createTempDirectory("testdb").toAbsolutePath.toString
val dataSource = LevelDBDataSource(new LevelDbConfig {
override val verifyChecksums: Boolean = false
override val paranoidChecks: Boolean = false
override val createIfMissing: Boolean = true
override val path: String = dbPath
})
try {
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)
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)
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::*;
@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).
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 / ThresholdLoggerFilter.scala
Created August 3, 2015 13:15
Threshold + Logger filter for Logback in Scala
package smartcontract.utils
import ch.qos.logback.classic.Level
import ch.qos.logback.classic.spi.ILoggingEvent
import ch.qos.logback.core.filter.Filter
import ch.qos.logback.core.spi.FilterReply
/**
* Code rewritten from Java source
@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.
@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