class Matter::Crypto::Key

Overview

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

Defined in:

matter/crypto/key.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.generate_key_pair : Key #

Generate a random EC key pair


[View source]
def self.new(type : KeyType = KeyType::EC, curve : CurveType | Nil = CurveType::P256, extractable : Bool = true) #

[View source]

Class Method Detail

def self.compute_shared_secret(private_key : Key, peer_public_key : Key) : Bytes #

Compute shared secret for Diffie-Hellman


[View source]
def self.extract_private_key_from_der(der : Bytes) : Bytes #

Extract 32-byte private key from DER format

TODO Make private after testing


[View source]
def self.extract_public_key_from_der(der : Bytes) : Bytes #

Extract 65-byte uncompressed public key from DER format

TODO Make private after testing


[View source]

Instance Method Detail

def algorithm : String | Nil #

[View source]
def algorithm=(algorithm : String | Nil) #

[View source]
def curve : CurveType | Nil #

[View source]
def curve=(curve : CurveType | Nil) #

[View source]
def extractable : Bool #

[View source]
def extractable=(extractable : Bool) #

[View source]
def import_pkcs8(data : Bytes) #

Import PKCS#8 private key


[View source]
def import_sec1(data : Bytes) #

Import SEC1 private key


[View source]
def import_spki(data : Bytes) #

Import SPKI public key


[View source]
def key_pair : BinaryKeyPair #

[View source]
def key_pair_bits : BinaryKeyPair | Nil #

Import/export key pair


[View source]
def key_pair_bits=(pair : BinaryKeyPair) #

[View source]
def operations : Array(String) | Nil #

[View source]
def operations=(operations : Array(String) | Nil) #

[View source]
def private_bits : Bytes | Nil #

Get/set private key bytes


[View source]
def private_bits=(value : Bytes | Nil) #

[View source]
def private_key : Bytes #

[View source]
def public_bits : Bytes | Nil #

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


[View source]
def public_bits=(value : Bytes) #

[View source]
def public_key : Bytes #

Asserted accessors that raise if not present


[View source]
def type : KeyType #

[View source]
def type=(type : KeyType) #

[View source]
def x_bits : Bytes | Nil #

Get/set public key x coordinate


[View source]
def x_bits=(value : Bytes | Nil) #

[View source]
def y_bits : Bytes | Nil #

Get/set public key y coordinate


[View source]
def y_bits=(value : Bytes | Nil) #

[View source]