class

Matter::Crypto::Key

Inherits Reference < Object

Represents a cryptographic key Models keys similar to JSON Web Key (JWK) format for compatibility

Constructors

generate_key_pair

Generate a random EC key pair

Source
new(type : KeyType = KeyType::EC, curve : CurveType | Nil = CurveType::P256, extractable : Bool = true)
Source

Class methods

compute_shared_secret(private_key : Key, peer_public_key : Key) : Bytes

Compute shared secret for Diffie-Hellman using ECDH

Source
extract_private_key_from_der(der : Bytes) : Bytes

Extract 32-byte private key from DER format

Source
extract_public_key_from_der(der : Bytes) : Bytes

Extract 65-byte uncompressed public key from DER format

Source

Instance methods

algorithm
Source
algorithm=(algorithm : String | Nil)
Source
curve
Source
curve=(curve : CurveType | Nil)
Source
extractable=(extractable : Bool)
Source
extractable?
Source
import_pkcs8(data : Bytes)

Import PKCS#8 private key

Source
import_sec1(data : Bytes)

Import SEC1 private key

Source
import_spki(data : Bytes)

Import SPKI public key

Source
key_pair
Source
key_pair_bits

Import/export key pair

Source
key_pair_bits=(pair : BinaryKeyPair)
Source
operations
Source
operations=(operations : Array(String) | Nil)
Source
private_bits

Get/set private key bytes

Source
private_bits=(value : Bytes | Nil)
Source
private_key
Source
public_bits

Import/export public key in SEC1/SPKI format (0x04 || x || y)

Source
public_bits=(value : Bytes)
Source
public_key

Asserted accessors that raise if not present

Source
type
Source
type=(type : KeyType)
Source
x_bits

Get/set public key x coordinate

Source
x_bits=(value : Bytes | Nil)
Source
y_bits

Get/set public key y coordinate

Source
y_bits=(value : Bytes | Nil)
Source