Crypto

object Crypto
class Object
trait Matchable
class Any
Crypto.type

Type members

Classlikes

case class PrivateKey(value: ByteVector32)

Secp256k1 private key, which a 32 bytes value We assume that private keys are compressed i.e. that the corresponding public key is compressed

Secp256k1 private key, which a 32 bytes value We assume that private keys are compressed i.e. that the corresponding public key is compressed

Value parameters:
value

value to initialize this key with

Companion:
object
Source:
Crypto.scala
object PrivateKey
Companion:
class
Source:
Crypto.scala
case class PublicKey(value: ByteVector)

Secp256k1 Public key We assume that public keys are always compressed

Secp256k1 Public key We assume that public keys are always compressed

Value parameters:
value

serialized public key, in compressed format (33 bytes)

Companion:
object
Source:
Crypto.scala
object PublicKey
Companion:
class
Source:
Crypto.scala

Value members

Concrete methods

def checkPubKeyEncoding(key: ByteVector, flags: Int, sigVersion: Int): Boolean
def decodeSignatureCompact(sig: ByteVector64): (BigInteger, BigInteger)

160 bits bitcoin hash, used mostly for address encoding hash160(input) = RIPEMD160(SHA256(input))

160 bits bitcoin hash, used mostly for address encoding hash160(input) = RIPEMD160(SHA256(input))

Value parameters:
input

array of byte

Returns:

the 160 bits BTC hash of input

Source:
Crypto.scala

256 bits bitcoin hash hash256(input) = SHA256(SHA256(input))

256 bits bitcoin hash hash256(input) = SHA256(SHA256(input))

Value parameters:
input

array of byte

Returns:

the 256 bits BTC hash of input

Source:
Crypto.scala
Value parameters:
key

serialized public key

Returns:

true if the key is valid. Please not that this performs very basic tests and does not check that the point represented by this key is actually valid.

Source:
Crypto.scala
def normalizeSignature(r: BigInteger, s: BigInteger): (BigInteger, BigInteger)
Value parameters:
privateKey

private key

Returns:

the corresponding public key

Source:
Crypto.scala
def sign(data: ByteVector, privateKey: PrivateKey): ByteVector64

Sign data with a private key, using RCF6979 deterministic signatures

Sign data with a private key, using RCF6979 deterministic signatures

Value parameters:
data

data to sign

privateKey

private key. If you are using bitcoin "compressed" private keys make sure to only use the first 32 bytes of the key (there is an extra "1" appended to the key)

Returns:

a signature in compact format (64 bytes)

Source:
Crypto.scala
def verifySignature(data: ByteVector, signature: ByteVector64, publicKey: PublicKey): Boolean
Value parameters:
data

data

publicKey

public key

signature

signature

Returns:

true is signature is valid for this data with this public key

Source:
Crypto.scala

Inherited methods

Inherited from:
CryptoPlatform (hidden)
Source:
CryptoPlatform.scala
def N: BigInteger
Inherited from:
CryptoPlatform (hidden)
Source:
CryptoPlatform.scala
Inherited from:
CryptoPlatform (hidden)
Source:
CryptoPlatform.scala
Inherited from:
CryptoPlatform (hidden)
Source:
CryptoPlatform.scala
Inherited from:
CryptoPlatform (hidden)
Source:
CryptoPlatform.scala
Value parameters:
key

serialized public key

Returns:

true if the key is valid. This check is much more expensive than its lax version since here we check that the public key is a valid point on the secp256k1 curve

Inherited from:
CryptoPlatform (hidden)
Source:
CryptoPlatform.scala
def randomBytes(length: Int): ByteVector
Inherited from:
CryptoPlatform (hidden)
Source:
CryptoPlatform.scala
def recoverPublicKey(signature: ByteVector64, message: ByteVector, recoveryId: Int): PublicKey

Recover public keys from a signature and the message that was signed. This method will return 2 public keys, and the signature can be verified with both, but only one of them matches that private key that was used to generate the signature.

Recover public keys from a signature and the message that was signed. This method will return 2 public keys, and the signature can be verified with both, but only one of them matches that private key that was used to generate the signature.

Value parameters:
message

message that was signed

signature

signature

Returns:

a recovered public key

Inherited from:
CryptoPlatform (hidden)
Source:
CryptoPlatform.scala
Inherited from:
CryptoPlatform (hidden)
Source:
CryptoPlatform.scala
Inherited from:
CryptoPlatform (hidden)
Source:
CryptoPlatform.scala
Inherited from:
CryptoPlatform (hidden)
Source:
CryptoPlatform.scala
Inherited from:
CryptoPlatform (hidden)
Source:
CryptoPlatform.scala
def sign(data: Array[Byte], privateKey: PrivateKey): ByteVector64
Inherited from:
CryptoPlatform (hidden)
Source:
CryptoPlatform.scala
def verifySignature(data: Array[Byte], signature: Array[Byte], publicKey: PublicKey): Boolean
Inherited from:
CryptoPlatform (hidden)
Source:
CryptoPlatform.scala

Concrete fields

lazy val halfCurveOrder: BigInteger