package crypto
- Alphabetic
- Public
- Protected
Type Members
- trait AdaptorSign extends Sign with AsyncAdaptorSign
- sealed trait AesDecryptionException extends Exception
- case class AesEncryptedData(cipherText: ByteVector, iv: AesIV) extends NetworkElement with Product with Serializable
Represents a encrypted cipher text with it's accompanying initialization vector (IV).
Represents a encrypted cipher text with it's accompanying initialization vector (IV). Both the cipher text and the IV is needed to decrypt the cipher text.
- final case class AesIV(bytes: ByteVector) extends AnyVal with NetworkElement with Product with Serializable
Represents an initialization vector (IV) used in AES encryption.
- case class AesKey(bytes: ByteVector) extends MaskedToString with NetworkElement with Product with Serializable
Represents a encryption/decryption key.
Represents a encryption/decryption key. AES keys can be converted to SecretKeys, and have certain length requirements.
- case class AesPassword(value: String) extends MaskedToString with Product with Serializable
- final case class AesSalt(bytes: ByteVector) extends AnyVal with Product with Serializable
Represents a salt used to derive a AES key from a human-readable passphrase.
- trait AsyncAdaptorSign extends AsyncSign
- trait AsyncSign extends AnyRef
This is meant to be an abstraction for a org.bitcoins.crypto.ECPrivateKey, sometimes we will not have direct access to a private key in memory -- for instance if that key is on a hardware device -- so we need to create an abstraction of the signing process.
This is meant to be an abstraction for a org.bitcoins.crypto.ECPrivateKey, sometimes we will not have direct access to a private key in memory -- for instance if that key is on a hardware device -- so we need to create an abstraction of the signing process. Fundamentally a private key takes in a scodec.bits.ByteVector and returns a ECDigitalSignature That is what this abstraction is meant to represent. If you have a ECPrivateKey in your application, you can get it's Sign type by doing this:
val key = ECPrivateKey() val sign: scodec.bits.ByteVector => Future[ECDigitalSignature] = key.signFunction
If you have a hardware wallet, you will need to implement the protocol to send a message to the hardware device. The type signature of the function you implement must be scodec.bits.ByteVector => Future[ECDigitalSignature]
- sealed abstract class BaseECKey extends NetworkElement
Created by chris on 2/16/16.
Created by chris on 2/16/16. Represents a fully parsed and validated ECDSA private or public key.
- trait BouncycastleCryptoRuntime extends CryptoRuntime
This is an implementation of CryptoRuntime that defaults to Bouncy Castle (https://bouncycastle.org/) and java.security.
- trait CryptoBytesUtil extends AnyRef
Created by chris on 2/26/16.
- sealed trait CryptoContext extends AnyRef
- trait CryptoNumberUtil extends AnyRef
- sealed abstract class CryptoParams extends AnyRef
Created by chris on 3/29/16.
Created by chris on 3/29/16. This trait represents all of the default parameters for our elliptic curve
- trait CryptoRuntime extends AnyRef
Trait that should be extended by specific runtimes like javascript or the JVM to support crypto functions needed for bitcoin-s
- sealed trait CryptoRuntimeFactory extends AnyRef
- Attributes
- protected
- trait CryptoUtil extends CryptoRuntime
Utility cryptographic functions This is a proxy for the underlying implementation of CryptoRuntime such as LibSecp256k1CryptoRuntime.
Utility cryptographic functions This is a proxy for the underlying implementation of CryptoRuntime such as LibSecp256k1CryptoRuntime.
This is necessary so that the core module doesn't need to be refactored to add support for multiple platforms, it can keep referencing CryptoUtil
- case class CurveCoordinate(bytes: ByteVector) extends FiniteFieldMember[CurveCoordinate] with Product with Serializable
- sealed abstract class DERSignatureUtil extends AnyRef
Created by chris on 3/23/16.
- abstract class DigitalSignature extends NetworkElement
- case class DoubleSha256Digest(bytes: ByteVector) extends HashDigest with Product with Serializable
Represents the result of SHA256(SHA256())
- case class DoubleSha256DigestBE(bytes: ByteVector) extends HashDigest with Product with Serializable
The big endian version of DoubleSha256Digest
- case class ECAdaptorSignature(bytes: ByteVector) extends NetworkElement with Product with Serializable
- case class ECDigitalSignature(bytes: ByteVector) extends DigitalSignature with Product with Serializable
Created by chris on 2/26/16.
- sealed abstract class ECKeyBytes extends NetworkElement
Represents the raw bytes which are meant to represent an ECKey without deserializing.
- case class ECPrivateKey(bytes: ByteVector) extends BaseECKey with AdaptorSign with MaskedToString with Product with Serializable
Created by chris on 2/16/16.
Created by chris on 2/16/16. A valid deserialized private key.
Note that there is no notion of compressed vs. decompressed as there is in Wallet Import Format (WIF), if dealing with external wallets then ECPrivateKeyBytes may be needed.
- case class ECPrivateKeyBytes(bytes: ByteVector, isCompressed: Boolean = true) extends ECKeyBytes with MaskedToString with Product with Serializable
Represents a serialization sensitive ECPrivateKey (such as is used in WIF).
- case class ECPublicKey(bytes: ByteVector) extends BaseECKey with ECPublicKeyApi with Product with Serializable
Created by chris on 2/16/16.
Created by chris on 2/16/16. A valid deserialized ECDSA public key.
This class wraps some underlying _bytes but after checking that these _bytes are valid, all serializations (compressed and decompressed) of this public key are (lazily) computed where the decompressed version is used internally for computation and the compressed version is provided by the NetworkElement::bytes member.
Note that 0x00 is not a valid ECPublicKey but is a valid SecpPoint meaning that if you are doing computations on public key (points) that may have intermediate 0x00 values, then you should convert using toPoint, do computation, and then convert back toPublicKey in the end.
- sealed trait ECPublicKeyApi extends PublicKey
Represents any type which wraps public key bytes which can be used for ECDSA verification.
Represents any type which wraps public key bytes which can be used for ECDSA verification. Should always be instantiated with class X extends PublicKey[X].
- case class ECPublicKeyBytes(bytes: ByteVector) extends ECKeyBytes with ECPublicKeyApi with Product with Serializable
Wraps raw ECPublicKey bytes without doing any validation or deserialization (may be invalid).
- abstract class Factory[+T] extends AnyRef
Created by chris on 2/26/16.
Created by chris on 2/26/16. Trait to implement ubiquitous factory functions across our codebase
- case class FieldElement(bytes: ByteVector) extends FiniteFieldMember[FieldElement] with Product with Serializable
Represents integers modulo the secp256k1 field size: pow(2,256) - 0x1000003D1.
Represents integers modulo the secp256k1 field size: pow(2,256) - 0x1000003D1.
Supports arithmetic for these elements including +, -, *, and inverses. Supports 32 byte serialization as is needed for ECPrivateKeys.
- abstract class FiniteFieldMember[F <: FiniteFieldMember[F]] extends NetworkElement
- abstract class FiniteFieldObject[F <: FiniteFieldMember[F]] extends Factory[F]
- class HMacDSAKCalculatorWithEntropy extends DSAKCalculator
Entirely copied from HMacDSAKCalculator with an added entropy parameter as well as two lines added adding the entropy to the hash.
Entirely copied from HMacDSAKCalculator with an added entropy parameter as well as two lines added adding the entropy to the hash.
For a reference in secp256k1, see nonce_function_rfc6979 in secp256k1.c For a description of the altered part, see RFC 6979 section 3.2d here https://tools.ietf.org/html/rfc6979#section-3.2
The added lines are marked below with comments.
- sealed trait HashDigest extends NetworkElement
- sealed trait HashType extends AnyRef
Created by chris on 1/18/16.
- sealed trait KeyParity extends NetworkElement
- trait LibSecp256k1CryptoRuntime extends CryptoRuntime
This is an implementation of CryptoRuntime that defaults to libsecp256k1 (https://github.com/bitcoin-core/secp256k1) when possible.
This is an implementation of CryptoRuntime that defaults to libsecp256k1 (https://github.com/bitcoin-core/secp256k1) when possible. All unsupported functions are delegated to BouncycastleCryptoRuntime.
- trait MaskedToString extends AnyRef
Meant to provide a simple trait that masks the default to string for sensitive classes
- trait NetworkElement extends Any
Created by chris on 1/14/16.
Created by chris on 1/14/16. This represents a element that can be serialized to be sent over the network
- trait PublicKey extends NetworkElement
- sealed trait RipeMd160Digest extends HashDigest
Represents the result of RIPEMD160()
- sealed trait RipeMd160DigestBE extends HashDigest
Represents the result of RIPEMD160() big endian
- case class SIGHASH_ALL(num: Int) extends HashType with Product with Serializable
defaultValue is the underlying value of the HashType.
defaultValue is the underlying value of the HashType. The last byte of a signature determines the HashType. https://en.bitcoin.it/wiki/OP_CHECKSIG
- case class SIGHASH_ALL_ANYONECANPAY(num: Int) extends HashType with Product with Serializable
- case class SIGHASH_ANYONECANPAY(num: Int) extends HashType with Product with Serializable
- case class SIGHASH_NONE(num: Int) extends HashType with Product with Serializable
- case class SIGHASH_NONE_ANYONECANPAY(num: Int) extends HashType with Product with Serializable
- case class SIGHASH_SINGLE(num: Int) extends HashType with Product with Serializable
- case class SIGHASH_SINGLE_ANYONECANPAY(num: Int) extends HashType with Product with Serializable
- case class SchnorrDigitalSignature(rx: SchnorrNonce, sig: FieldElement, hashTypeOpt: Option[HashType]) extends DigitalSignature with Product with Serializable
- case class SchnorrNonce(bytes: ByteVector) extends NetworkElement with Product with Serializable
- case class SchnorrPublicKey(bytes: ByteVector) extends PublicKey with Product with Serializable
- sealed trait SecpPoint extends NetworkElement
Represents a point on the secp256k1 elliptic curve.
- case class SecpPointFinite(x: CurveCoordinate, y: CurveCoordinate) extends SecpPoint with Product with Serializable
A non-identity point, (x, y), on the secp256k1 elliptic curve.
- sealed trait Sha1Digest extends HashDigest
Represents the result of SHA1()
- sealed trait Sha1DigestBE extends HashDigest
- sealed trait Sha256Digest extends HashDigest
Represents the result of SHA256()
- sealed trait Sha256DigestBE extends HashDigest
Represents the result of SHA256()
- sealed trait Sha256Hash160Digest extends HashDigest
Represents the result of RIPEMD160(SHA256())
- sealed trait Sha256Hash160DigestBE extends HashDigest
Represents the result of RIPEMD160(SHA256()) big endian
- sealed trait Sha3_256Digest extends HashDigest
Represents the result of SHA3-256()
- sealed trait Sha3_256DigestBE extends HashDigest
Represents the result of SHA3-256()
- trait Sign extends AsyncSign
- case class SipHashKey(bytes: ByteVector) extends NetworkElement with Product with Serializable
- trait StringFactory[+T] extends AnyRef
A common factory trait that can be re-used to deserialize a string to a type t
- case class XOnlyPubKey(bytes: ByteVector) extends PublicKey with Product with Serializable
Represents the x-coordinate of an ECPublicKey, with undetermined y-coordinate parity
Value Members
- object AdaptorUtil
Implements the ECDSA Adaptor Signing Specification: https://github.com/discreetlogcontracts/dlcspecs/blob/d01595b70269d4204b05510d19bba6a4f4fcff23/ECDSA-adaptor.md
Implements the ECDSA Adaptor Signing Specification: https://github.com/discreetlogcontracts/dlcspecs/blob/d01595b70269d4204b05510d19bba6a4f4fcff23/ECDSA-adaptor.md
Note that the naming is not entirely consistent between the specification and this file in hopes of making this code more readable.
The naming in this file more closely matches the naming in the secp256k1-zkp implementation: https://github.com/ElementsProject/secp256k1-zkp/tree/master/src/modules/ecdsa_adaptor
Legend: x <> privKey X <> pubKey y <> adaptorSecret Y <> adaptorPoint/adaptor messageHash <> dataToSign/data/message R_a <> untweakedNonce R <> tweakedNonce proof <> (e, s)
- object AesCrypt
Provides functionality for encrypting and decrypting with AES
- object AesEncryptedData extends Factory[AesEncryptedData] with Serializable
- object AesException
- object AesIV extends Serializable
- object AesKey extends Serializable
- object AesPassword extends StringFactory[AesPassword] with Serializable
- object AesSalt extends Factory[AesSalt] with Serializable
- object AsyncSign
- object BouncyCastleCryptoParams
- object BouncyCastleUtil
- object BouncycastleCryptoRuntime extends BouncycastleCryptoRuntime
- object CryptoBytesUtil extends CryptoBytesUtil
- object CryptoContext
- object CryptoNumberUtil extends CryptoNumberUtil
- object CryptoOrdering
- object CryptoParams extends CryptoParams
- object CryptoRuntimeFactory extends CryptoRuntimeFactory
- Attributes
- protected
- object CryptoUtil extends CryptoUtil
- object CurveCoordinate extends FiniteFieldObject[CurveCoordinate] with Serializable
- object DERSignatureUtil extends DERSignatureUtil
- object DLEQUtil
Implements the DLEQ ZKP Specification: https://github.com/discreetlogcontracts/dlcspecs/blob/d01595b70269d4204b05510d19bba6a4f4fcff23/ECDSA-adaptor.md
Implements the DLEQ ZKP Specification: https://github.com/discreetlogcontracts/dlcspecs/blob/d01595b70269d4204b05510d19bba6a4f4fcff23/ECDSA-adaptor.md
Note that the naming is not entirely consistent between the specification and this file in hopes of making this code more readable.
The naming in this file more closely matches the naming in the secp256k1-zkp implementation: https://github.com/ElementsProject/secp256k1-zkp/tree/master/src/modules/ecdsa_adaptor
Legend: x <> fe X <> p1/point y <> adaptorSecret Y <> adaptorPoint/adaptor Z <> p2/tweakedPoint a <> k A_G <> r1 A_Y <> r2 b <> e c <> s proof <> (e, s)
- object DoubleSha256Digest extends Factory[DoubleSha256Digest] with Serializable
- object DoubleSha256DigestBE extends Factory[DoubleSha256DigestBE] with Serializable
- object ECAdaptorSignature extends Factory[ECAdaptorSignature] with Serializable
- object ECDigitalSignature extends Factory[ECDigitalSignature] with Serializable
- object ECPrivateKey extends Factory[ECPrivateKey] with Serializable
- object ECPrivateKeyBytes extends Factory[ECPrivateKeyBytes] with Serializable
- object ECPublicKey extends Factory[ECPublicKey] with Serializable
- object ECPublicKeyBytes extends Factory[ECPublicKeyBytes] with Serializable
- case object EvenParity extends KeyParity with Product with Serializable
- object FieldElement extends FiniteFieldObject[FieldElement] with Serializable
- object HashType extends Factory[HashType]
- object KeyParity extends Factory[KeyParity]
- object LibSecp256k1CryptoRuntime extends LibSecp256k1CryptoRuntime
- object NetworkElement
- case object OddParity extends KeyParity with Product with Serializable
- object PBKDF2
- object RipeMd160Digest extends Factory[RipeMd160Digest]
- object RipeMd160DigestBE extends Factory[RipeMd160DigestBE]
- object SIGHASH_ALL extends Serializable
- case object SIGHASH_DEFAULT extends HashType with Product with Serializable
- object SchnorrDigitalSignature extends Factory[SchnorrDigitalSignature] with Serializable
- object SchnorrNonce extends Factory[SchnorrNonce] with Serializable
- object SchnorrPublicKey extends Factory[SchnorrPublicKey] with Serializable
- object SecpPoint
- case object SecpPointInfinity extends SecpPoint with Product with Serializable
The point at infinity, this is the secp256k1 group identity element meaning p + 0x00 = 0x00 + p = p for any point p and p + (-p) = 0x00.
The point at infinity, this is the secp256k1 group identity element meaning p + 0x00 = 0x00 + p = p for any point p and p + (-p) = 0x00.
Note that this does not correspond to a valid ECPublicKey just like FieldElement.zero does not correspond to a valid private key (and in fact 0x00 = FieldElement.zero*G).
- object Sha1Digest extends Factory[Sha1Digest]
- object Sha1DigestBE extends Factory[Sha1DigestBE]
- object Sha256Digest extends Factory[Sha256Digest]
- object Sha256DigestBE extends Factory[Sha256DigestBE]
- object Sha256Hash160Digest extends Factory[Sha256Hash160Digest]
- object Sha256Hash160DigestBE extends Factory[Sha256Hash160DigestBE]
- object Sha3_256Digest extends Factory[Sha3_256Digest]
- object Sha3_256DigestBE extends Factory[Sha3_256DigestBE]
- object Sign
- object XOnlyPubKey extends Factory[XOnlyPubKey] with Serializable