Class EcKey

extends Object

Class summary


CURVE-SECP256R1 -> any
Named constant for the "secp256r1" curve.
CURVE-SECP384R1 -> any
Named constant for the "secp384r1" curve.
CURVE-SECP521R1 -> any
Named constant for the "secp521r1" curve.
SHA-1 -> any
Produces a 20-byte digest.
SHA-256 -> any
Produces a 32-byte digest.
SHA-384 -> any
Produces a 48-byte digest.
SHA-512 -> any
Produces a 64-byte digest.
parse-private key/Data --password/string= -> EcKey
Parses an EC private key and stores it as DER.
parse-public key/Data -> EcKey
Parses an EC public key and stores it as DER.

Statics

Named constant for the "secp256r1" curve.

Named constant for the "secp384r1" curve.

Named constant for the "secp521r1" curve.

parse-private key/Data --password/string="" -> EcKey
Parses an EC private key and stores it as DER.
The key must be DER or PEM.
The password is optional and used for encrypted keys.

Parses an EC public key and stores it as DER.
The key must be DER or PEM.

SHA-1 -> any
Produces a 20-byte digest.

SHA-256 -> any
Produces a 32-byte digest.

SHA-384 -> any
Produces a 48-byte digest.

SHA-512 -> any
Produces a 64-byte digest.

Methods

Computes a shared secret with the other-public-key.
This key must be a private key.

Decrypts the given ciphertext using ECIES.
This key must be a private key.

operator == other/any -> bool
Whether this object is equal to the other.
By default, identical is used for equality.
Inheritance
Classes overwrite this operator to get an equality specific to their needs. Equality operators often compare the type and field contents. For example:

class Pin:
  number/int

  constructor .number:

  operator == other:
    if other is not Pin: return false
    return number == other.number
A class doesn't have to follow the above format, but it must keep the operator in sync with any hash-code method. That is, if a class has a hash-code member, then the equality and hash-code must agree. If two instances are equal (a == b), then their hash codes must also be equal (a.hash-code == b.hash-code).

sign message/Data --hash/int=SHA-256 -> ByteArray
Signs the message with this private key.

Signs the digest with this private key.

The size of the key DER in bytes.

Stringifies this object.
Inheritance
Objects that need a human-friendly string representation should overwrite this method. The default string is based on the internal class-ID.

Exports this key in PEM format.

verify message/Data signature/ByteArray --hash/int=SHA-256 -> bool
Verifies the signature of the message with this public key.

verify-digest digest/ByteArray signature/ByteArray --hash/int -> bool
Verifies the signature of the digest with this public key.

Fields

The DER-encoded key bytes.