more removal

This commit is contained in:
cwaldron97 2019-07-17 14:47:45 -05:00
parent 87f6300082
commit ab29c0cc8f
4 changed files with 0 additions and 58 deletions

View File

@ -1,61 +1,12 @@
package org.bitcoins.core.crypto
import org.bitcoinj.core.Sha256Hash
import org.bitcoins.testkit.core.gen.CryptoGenerators
import org.bitcoins.testkit.util.BitcoinSUnitTest
import org.scalatest.prop.PropertyChecks
import org.scalatest.{FlatSpec, MustMatchers}
import scodec.bits._
class ECPublicKeyTest extends BitcoinSUnitTest {
"ECPublicKey" must "verify that a arbitrary piece of data was signed by the private key corresponding to a public key" in {
val privateKeyHex =
"180cb41c7c600be951b5d3d0a7334acc7506173875834f7a6c4c786a28fcbb19"
val key: ECPrivateKey = ECPrivateKey(privateKeyHex)
val hash = DoubleSha256Digest(ByteVector(Sha256Hash.ZERO_HASH.getBytes))
val signature: ECDigitalSignature = key.sign(hash)
val isValid: Boolean =
key.publicKey.verify(ByteVector(Sha256Hash.ZERO_HASH.getBytes), signature)
isValid must be(true)
}
it must "fail to verify a piece of data if the wrong public key is given" in {
val privateKeyHex =
"180cb41c7c600be951b5d3d0a7334acc7506173875834f7a6c4c786a28fcbb19"
val key: ECPrivateKey = ECPrivateKey(privateKeyHex)
val hash = DoubleSha256Digest(ByteVector(Sha256Hash.ZERO_HASH.getBytes))
val signature: ECDigitalSignature = key.sign(hash)
val wrongPublicKey = ECPublicKey.freshPublicKey
val isValid: Boolean = wrongPublicKey.verify(hash, signature)
isValid must be(false)
}
it must "verify a piece of data signed with a bitcoinj private key" in {
val bitcoinjPrivKey = new org.bitcoinj.core.ECKey
val bitcoinjSignature = bitcoinjPrivKey.sign(Sha256Hash.ZERO_HASH)
val bitcoinsSignature =
ECDigitalSignature(ByteVector(bitcoinjSignature.encodeToDER()))
val bitcoinsPublicKey = ECPublicKey(ByteVector(bitcoinjPrivKey.getPubKey))
bitcoinsPublicKey.verify(ByteVector(Sha256Hash.ZERO_HASH.getBytes),
bitcoinsSignature) must be(true)
}
it must "verify a piece of data was signed with a bitcoins private key inside of bitcoinj" in {
val bitcoinsPrivKey = ECPrivateKey.freshPrivateKey
val hash = DoubleSha256Digest(ByteVector(Sha256Hash.ZERO_HASH.getBytes))
val bitcoinsSignature = bitcoinsPrivKey.sign(hash)
val bitcoinjPublicKey = org.bitcoinj.core.ECKey
.fromPublicOnly(bitcoinsPrivKey.publicKey.bytes.toArray)
bitcoinjPublicKey.verify(Sha256Hash.ZERO_HASH.getBytes,
bitcoinsSignature.bytes.toArray) must be(true)
}
it must "be able to decompress keys" in {
val uncompressed =
ECPublicKey(

View File

@ -18,8 +18,6 @@ import scala.util.Try
class TransactionSignatureSerializerTest extends FlatSpec with MustMatchers {
private def logger = BitcoinSLogger.logger
val scriptPubKey =
BitcoinjConversions.toScriptPubKey(BitcoinJTestUtil.multiSigScript)
"TransactionSignatureSerializer" must "correctly serialize an input that is being checked where another input in the same tx is using SIGHASH_ANYONECANPAY" in {
//this is from a test case inside of tx_valid.json
//https://github.com/bitcoin/bitcoin/blob/master/src/test/data/tx_valid.json#L91

View File

@ -1,6 +1,5 @@
package org.bitcoins.core.util
import org.bitcoinj.core.DumpedPrivateKey
import org.bitcoins.core.crypto.ECPrivateKey
/**
@ -9,9 +8,6 @@ import org.bitcoins.core.crypto.ECPrivateKey
trait CryptoTestUtil {
def privateKeyBase58 = "cVLwRLTvz3BxDAWkvS3yzT9pUcTCup7kQnfT2smRjvmmm1wAP6QT"
def bitcoinjDumpedPrivateKey =
new DumpedPrivateKey(BitcoinJTestUtil.params, privateKeyBase58)
def bitcoinjPrivateKey = bitcoinjDumpedPrivateKey.getKey
def privateKey = ECPrivateKey.fromWIFToPrivateKey(privateKeyBase58)
}

View File

@ -61,9 +61,6 @@ object Deps {
object Test {
val async = "org.scala-lang.modules" %% "scala-async" % V.asyncV % "test" withSources () withJavadoc ()
val bitcoinj = ("org.bitcoinj" % "bitcoinj-core" % "0.14.4" % "test")
.exclude("org.slf4j", "slf4j-api")
val junitInterface = "com.novocode" % "junit-interface" % V.junitV % "test" withSources () withJavadoc ()
val logback = Compile.logback % "test"
val scalacheck = Compile.scalacheck % "test"