Skip to content

Commit

Permalink
Merge pull request #51 from input-output-hk/shared-components
Browse files Browse the repository at this point in the history
Use ScorexLogging from the Scorex-util repository
  • Loading branch information
kushti authored Aug 9, 2018
2 parents a610ce2 + f372cc7 commit cd863d2
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 287 deletions.
6 changes: 4 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ name := "scrypto"

lazy val commonSettings = Seq(
organization := "org.scorexfoundation",
version := "2.1.3-SNAPSHOT",
version := "2.1.3",
scalaVersion := "2.12.5",
resolvers += Resolver.sonatypeRepo("public"),
licenses := Seq("CC0" -> url("https://creativecommons.org/publicdomain/zero/1.0/legalcode")),
homepage := Some(url("https://github.com/input-output-hk/scrypto")),
pomExtra :=
Expand All @@ -28,7 +29,8 @@ libraryDependencies ++= Seq(
"com.typesafe.scala-logging" %% "scala-logging" % "3.+",
"ch.qos.logback" % "logback-classic" % "1.+",
"org.whispersystems" % "curve25519-java" % "+",
"org.bouncycastle" % "bcprov-jdk15on" % "1.+"
"org.bouncycastle" % "bcprov-jdk15on" % "1.+",
"org.scorexfoundation" %% "scorex-util" % "0.1.1-SNAPSHOT"
)

libraryDependencies ++= Seq(
Expand Down
3 changes: 2 additions & 1 deletion lock.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ dependencyOverrides in ThisBuild ++= Seq(
"javax.activation" % "activation" % "1.1",
"org.bouncycastle" % "bcprov-jdk15on" % "1.60",
"org.rudogma" % "supertagged_2.12" % "1.4",
"org.scorexfoundation" % "scorex-util_2.12" % "0.1.1-SNAPSHOT",
"org.slf4j" % "slf4j-api" % "1.8.0-beta1",
"org.whispersystems" % "curve25519-java" % "0.5.0"
)
// LIBRARY_DEPENDENCIES_HASH 6da534ddce5e26a47dc87a4777336311fe979572
// LIBRARY_DEPENDENCIES_HASH 566ab37b6dd750a11f55c07c094f47be1499f752
6 changes: 6 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
**2.1.3**
---------

* Always explicit encoding in .getBytes String method
* Base* and logging are moved to scorex-utils

**2.1.2**
---------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scorex.crypto.authds

import scorex.crypto.authds.legacy.treap.Level
import scorex.utils.{ScorexEncoding, ScryptoLogging}
import scorex.utils.ScorexEncoding

trait TwoPartyProofElement extends ScorexEncoding {
val bytes: Array[Byte]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package scorex.crypto.authds.avltree.batch
import com.google.common.primitives.Ints
import scorex.crypto.authds._
import scorex.crypto.hash.{Blake2b256, CryptographicHash, Digest}
import scorex.util.ScorexLogging
import scorex.utils.ByteArray

import scala.annotation.tailrec
Expand All @@ -27,7 +28,7 @@ class BatchAVLProver[D <: Digest, HF <: CryptographicHash[D]](val keyLength: Int
oldRootAndHeight: Option[(ProverNodes[D], Int)] = None,
val collectChangedNodes: Boolean = true)
(implicit val hf: HF = Blake2b256)
extends AuthenticatedTreeOps[D] with ToStringHelper {
extends AuthenticatedTreeOps[D] with ToStringHelper with ScorexLogging {

protected val labelLength = hf.DigestSize

Expand Down Expand Up @@ -354,7 +355,7 @@ class BatchAVLProver[D <: Digest, HF <: CryptographicHash[D]](val keyLength: Int
/**
*
* @param rand - source of randomness
* @return Random leaf from the tree, that is not positive or negative infinity
* @return Random leaf from the tree that is not positive or negative infinity
*/
def randomWalk(rand: Random = new Random): Option[(ADKey, ADValue)] = {
def internalNodeFn(r: InternalProverNode[D], dummy: Unit.type) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package scorex.crypto.authds.avltree.batch

import com.google.common.primitives.Longs
import scorex.crypto.authds.{ADKey, ADValue}
import scorex.utils.{ScorexEncoding, ScryptoLogging}
import scorex.utils.ScorexEncoding

import scala.util.{Failure, Success, Try}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package scorex.crypto.authds.avltree.batch

import scorex.utils.{ScorexEncoding, ScryptoLogging}
import scorex.utils.ScorexEncoding

trait ToStringHelper extends ScryptoLogging with ScorexEncoding {
trait ToStringHelper extends ScorexEncoding {
//Needed for debug (toString) only
protected def arrayToString(a: Array[Byte]): String = encoder.encode(a).take(8)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package scorex.crypto.authds.merkle

import scorex.crypto.authds.{LeafData, Side}
import scorex.crypto.hash.{CryptographicHash, Digest}
import scorex.utils.{ScorexEncoding, ScryptoLogging}
import scorex.utils.ScorexEncoding

/**
* Proof is given leaf data, leaf hash sibling and also siblings for parent nodes. Using this data, it is possible to
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/scorex/crypto/authds/merkle/MerkleTree.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package scorex.crypto.authds.merkle

import scorex.crypto.authds.{LeafData, Side}
import scorex.crypto.hash._
import scorex.utils.ScryptoLogging

import scala.annotation.tailrec
import scala.collection.mutable
Expand Down Expand Up @@ -64,7 +63,7 @@ case class MerkleTree[D <: Digest](topNode: Node[D],
}
}

object MerkleTree extends ScryptoLogging {
object MerkleTree {
val LeafPrefix: Byte = 0: Byte
val InternalNodePrefix: Byte = 1: Byte

Expand Down
71 changes: 0 additions & 71 deletions src/main/scala/scorex/crypto/encode/Base16.scala

This file was deleted.

66 changes: 0 additions & 66 deletions src/main/scala/scorex/crypto/encode/Base58.scala

This file was deleted.

13 changes: 0 additions & 13 deletions src/main/scala/scorex/crypto/encode/Base64.scala

This file was deleted.

14 changes: 0 additions & 14 deletions src/main/scala/scorex/crypto/encode/BytesEncoder.scala

This file was deleted.

14 changes: 14 additions & 0 deletions src/main/scala/scorex/crypto/encode/package.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package scorex.crypto

package object encode {

@deprecated("Use scorex.util.encode.BytesEncoder instead.", "scorex-util 0.1.1")
type BytesEncoder = scorex.util.encode.BytesEncoder

@deprecated("Use scorex.util.encode.Base16 instead.", "scorex-util 0.1.1")
val Base16 = scorex.util.encode.Base16
@deprecated("Use scorex.util.encode.Base58 instead.", "scorex-util 0.1.1")
val Base58 = scorex.util.encode.Base58
@deprecated("Use scorex.util.encode.Base64 instead.", "scorex-util 0.1.1")
val Base64 = scorex.util.encode.Base64
}
7 changes: 3 additions & 4 deletions src/main/scala/scorex/crypto/signatures/Curve25519.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package scorex.crypto.signatures

import java.lang.reflect.Constructor

import org.slf4j.LoggerFactory
import org.whispersystems.curve25519.OpportunisticCurve25519Provider
import scorex.crypto.hash.Sha256
import scorex.util.ScorexLogging

import scala.util.{Failure, Try}

object Curve25519 extends EllipticCurveSignatureScheme {
object Curve25519 extends EllipticCurveSignatureScheme with ScorexLogging {

val SignatureLength25519 = 64
val KeyLength25519 = 32
Expand Down Expand Up @@ -51,6 +52,4 @@ object Curve25519 extends EllipticCurveSignatureScheme {
override def createSharedSecret(privateKey: PrivateKey, publicKey: PublicKey): SharedSecret = {
SharedSecret @@ provider.calculateAgreement(privateKey, publicKey)
}

protected lazy val log = LoggerFactory.getLogger(this.getClass)
}
11 changes: 0 additions & 11 deletions src/main/scala/scorex/utils/ScorexEncoding.scala

This file was deleted.

12 changes: 0 additions & 12 deletions src/main/scala/scorex/utils/ScryptoLogging.scala

This file was deleted.

10 changes: 10 additions & 0 deletions src/main/scala/scorex/utils/package.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package scorex

package object utils {

@deprecated("Use scorex.util.ScorexLogging instead.", "scorex-util 0.1.0")
type ScryptoLogging = scorex.util.ScorexLogging

@deprecated("Use scorex.util.ScorexEncoding instead.", "scorex-util 0.1.1")
type ScorexEncoding = scorex.util.ScorexEncoding
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ class AVLBatchSpecification extends PropSpec with GeneratorDrivenPropertyChecks
forAll { seed: Long =>
val e1 = prover.randomWalk(new scala.util.Random(seed))
val e2 = prover.randomWalk(new scala.util.Random(seed))
e1.get._1 shouldEqual e2.get._1
e1.get._2 shouldEqual e2.get._2
e1.map(_._1) shouldEqual e2.map(_._1)
e1.map(_._2) shouldEqual e2.map(_._2)
}
}

Expand Down
5 changes: 0 additions & 5 deletions src/test/scala/scorex/crypto/encode/Base16Specification.scala

This file was deleted.

Loading

0 comments on commit cd863d2

Please sign in to comment.