Static ReadonlyKEY_The byte length of a ECPrivateKey.
A copy of the bytes; mutating it does not touch this value.
StaticrandomA fresh random value; pass rng to make it deterministic.
StatickeypairA fresh private key and its public key.
StaticderiveDerive an ECPrivateKey from the given key material.
The key material to derive from
A new ECPrivateKey derived from the key material
StaticfromRestore an ECPrivateKey from a fixed-size array of bytes.
StaticfromGet hex string representation.
Get base64 representation.
Get the ECPublicKey (compressed) corresponding to this ECPrivateKey.
Get the SchnorrPublicKey (x-only) corresponding to this ECPrivateKey.
Sign a message using ECDSA.
The message to sign
A 64-byte signature
Sign a message using Schnorr signature (BIP-340).
The message to sign
A 64-byte signature
Sign a message using Schnorr signature with custom RNG.
The message to sign
Random number generator for auxiliary randomness
A 64-byte signature
The reference: the digest of the tagged CBOR, as the reference computes it.
The first four bytes of reference() in hex, the reference's ref_hex_short.
The reference's Display: the type name over the short reference.
The CBOR tags of this type; the first one is used to encode. As the
reference, this type is only encoded: it has no fromCbor.
Returns the untagged CBOR encoding.
Format: { 2: true, 3: h'<32-byte-key>' }
The tagged CBOR form.
As a UR, typed by the first tag's name.
EC private key for ECDSA and Schnorr signatures (secp256k1, 32 bytes)
An
ECPrivateKeyis a 32-byte secret value that can be used to:These keys use the secp256k1 curve, which is the same curve used in Bitcoin and other cryptocurrencies.
CBOR Serialization
ECPrivateKeyis serialized to CBOR with tags 40306 (or legacy 306).The format is a map: