Skip to content

OnixLabs.Security.Cryptography

Matthew Layton edited this page Nov 15, 2026 · 5 revisions

OnixLabs.Security.Cryptography

View on NuGet

Strongly typed cryptographic primitives and structures with value semantics, designed to make cryptographic operations safer and more explicit.

Installation

dotnet add package OnixLabs.Security.Cryptography

Features

  • Public and private key abstractions (PublicKey, PrivateKey).
  • ECDH, ECDSA, EdDSA, and RSA key implementations.
  • Digital signature types (DigitalSignature, DigitalSignatureAndPublicKey).
  • Cryptographic hash value types (Hash, NamedHash).
  • Extensions for HashAlgorithm.
  • Fully managed FIPS-202 SHA-3 implementation (SHA3-224/256/384/512, SHAKE128/256).
  • Merkle tree implementations (MerkleTree, MerkleTree<T>).
  • Cryptographic salt value type (Salt).
  • Encrypted-in-memory secret handling (Secret).
  • Common cryptographic primitive abstraction (ICryptoPrimitive).

API Reference

All types are in the OnixLabs.Security.Cryptography namespace.

Hashing

Type Description
Hash An immutable, algorithm-agnostic hash value with value semantics.
NamedHash A Hash paired with the name of the algorithm that produced it.
Sha3 FIPS-202 SHA-3 HashAlgorithm base class.
Sha3Hash224 / Sha3Hash256 / Sha3Hash384 / Sha3Hash512 Fixed-length SHA-3 hash algorithms.
Sha3Shake128 / Sha3Shake256 SHAKE extendable-output functions.
MerkleTree An immutable Merkle tree of Hash values.
MerkleTree<T> A Merkle tree that retains its typed leaf values.

Keys

Type Description
PrivateKey Abstract base for asymmetric private keys (encrypted in memory, disposable).
PublicKey Abstract base for asymmetric public keys.
NamedPrivateKey / NamedPublicKey A key paired with its algorithm name.
EcdhPrivateKey / EcdhPublicKey Elliptic Curve Diffie-Hellman key-agreement keys.
EcdsaPrivateKey / EcdsaPublicKey Elliptic Curve Digital Signature Algorithm keys.
EddsaPrivateKey / EddsaPublicKey Edwards-curve Digital Signature Algorithm keys.
RsaPrivateKey / RsaPublicKey RSA signing keys.

Signatures, salts, and secrets

Type Description
DigitalSignature An immutable digital signature value.
DigitalSignatureAndPublicKey A digital signature paired with its public key.
Salt A cryptographic salt value backed by random bytes.
Secret An encrypted-in-memory, disposable secret value.

Abstractions

Type Description
ICryptoPrimitive<T> Base contract for cryptographic primitives (value equality + binary conversion).
IHashable Defines computing the Hash of an object.

Private key interfaces

Type Description
IEcdhPrivateKey ECDH private-key operations (shared-secret derivation).
IEcdsaPrivateKey ECDSA private-key signing operations.
IEddsaPrivateKey EdDSA private-key signing operations.
IRsaPrivateKey RSA private-key signing operations.
IPrivateKeyDerivable<T> Derives the corresponding public key.
IPrivateKeyExportable Aggregate private-key export contract.
IPrivateKeyImportable<T> Aggregate private-key import contract.
IPrivateKeyPemImportable<T> PEM (RFC 7468) private-key import.
IPrivateKeyPkcs8Exportable PKCS #8 private-key export.
IPrivateKeyPkcs8Importable<T> PKCS #8 private-key import.
IPrivateKeyPkcs8PemExportable PKCS #8 PEM private-key export.
IPrivateKeyRawExportable Raw-bytes private-key export.
IPrivateKeyRawImportable<T> Raw-bytes private-key import.
IPrivateKeyRawPemExportable Raw PEM private-key export.

Public key interfaces

Type Description
IEcdhPublicKey ECDH public-key marker.
IEcdsaPublicKey ECDSA public-key verification operations.
IEddsaPublicKey EdDSA public-key verification operations.
IRsaPublicKey RSA public-key verification operations.
IPublicKeyExportable Aggregate public-key export contract.
IPublicKeyImportable<T> Aggregate public-key import contract.
IPublicKeyPemExportable PEM (RFC 7468) public-key export.
IPublicKeyPemImportable<T> PEM public-key import.
IPublicKeyRawExportable Raw-bytes public-key export.
IPublicKeyRawImportable<T> Raw-bytes public-key import.

Extensions

Type Description
HashAlgorithmExtensions HashAlgorithm extensions that compute a Hash.
ReadOnlySpanExtensions ReadOnlySpan<byte> extensions (ToHash, ToSecret).

Requirements

Item Supported
Target frameworks .NET 8.0, .NET 9.0, .NET 10.0, .NET 11.0
Language version C# 15
License Apache-2.0

Package Dependencies

Pkcs8PrivateKeyInfo is not part of the shared framework on any target, so each target framework references System.Security.Cryptography.Pkcs from its own runtime's servicing line.

Package .NET 8.0 .NET 9.0 .NET 10.0 .NET 11.0
OnixLabs.Core Same version Same version Same version Same version
System.Security.Cryptography.Pkcs 8.0.2 9.0.23 10.0.15 11.0.0

See Also

ONIXLabs .NET Library


Clone this wiki locally