Repository navigation
OnixLabs.Security.Cryptography.DigitalSignatureAndPublicKey
Represents a pair consisting of a cryptographic digital signature and the named public key required to verify it.
| Namespace | OnixLabs.Security.Cryptography |
| Assembly | OnixLabs.Security.Cryptography.dll (NuGet) |
| Inheritance |
object → ValueType → DigitalSignatureAndPublicKey
|
| Implements | IEquatable<DigitalSignatureAndPublicKey> |
public readonly record struct DigitalSignatureAndPublicKey(DigitalSignature Signature, NamedPublicKey Key);DigitalSignatureAndPublicKey is a convenience readonly record struct that keeps a DigitalSignature and its associated NamedPublicKey together as a single value. This is useful when a signing operation must return both the signature bytes and the public key that can be used to verify them — for example, when recording signed artefacts that may be verified later without a separate key lookup.
Because this is a readonly record struct, the compiler synthesizes value-equality, GetHashCode, ToString, and deconstruction automatically. Two DigitalSignatureAndPublicKey values are equal when both their Signature and Key components are equal.
The positional record syntax means the constructor parameters Signature and Key are also auto-generated { get; init; } properties.
using OnixLabs.Security.Cryptography;
EcdsaPrivateKey privateKey = EcdsaPrivateKey.Create();
byte[] data = System.Text.Encoding.UTF8.GetBytes("important document");
DigitalSignature signature = privateKey.SignData(data);
NamedPublicKey publicKey = privateKey.GetPublicKey();
// Bundle the two together for storage or transmission.
var bundle = new DigitalSignatureAndPublicKey(signature, publicKey);
// Later: verify using the bundled key.
bool valid = bundle.Key.IsValidSignature(bundle.Signature, data);
Console.WriteLine(valid); // True
// Deconstruct using positional pattern.
var (sig, key) = bundle;| Constructor | Description |
|---|---|
DigitalSignatureAndPublicKey(DigitalSignature, NamedPublicKey) |
Initializes a new instance with the specified signature and key. |
public DigitalSignatureAndPublicKey(DigitalSignature Signature, NamedPublicKey Key)Initializes a new instance of the DigitalSignatureAndPublicKey record struct.
| Parameter | Type | Description |
|---|---|---|
Signature |
DigitalSignature |
The cryptographic digital signature. |
Key |
NamedPublicKey |
The named public key associated with the signature. |
| Property | Type | Description |
|---|---|---|
Signature |
DigitalSignature |
Gets the cryptographic digital signature. |
Key |
NamedPublicKey |
Gets the named public key associated with the signature. |
public DigitalSignature Signature { get; init; }Gets the DigitalSignature component of this pair.
public NamedPublicKey Key { get; init; }Gets the NamedPublicKey component of this pair. A NamedPublicKey bundles a public key with its algorithm name, providing the information needed to select the correct verification algorithm.
ONIXLabs .NET Library · Repository · NuGet · License (Apache-2.0)
Copyright © ONIXLabs 2020. Licensed under the Apache License, Version 2.0.
- Enumeration<T>
- Optional<T>
- OptionalEqualityComparer<T>
- OptionalExtensions
- Result
- Result<T>
- ResultEqualityComparer<T>
- ResultExtensions
- Specification<T>
- Preconditions
- IValueEquatable<T>
- IValueComparable<T>
- IBinaryConvertible
- ISpanBinaryConvertible
- IMemoryBinaryConvertible
- ArrayExtensions
- ComparableExtensions
- DateTimeExtensions
- ISpanParsableExtensions
- ObjectExtensions
- RandomExtensions
- ReadOnlySequenceExtensions
- ReadOnlySpanExtensions
- StringExtensions
- Base16
- Base32
- Base58
- Base64
- IBaseCodec
- IBaseValue
- IBaseValue<T>
- Base16Codec
- Base32Codec
- Base58Codec
- Base64Codec
- Base16FormatProvider
- Base32FormatProvider
- Base58FormatProvider
- Base64FormatProvider
- EncodingExtensions
- ReadOnlySpanExtensions
- StringBuilderExtensions
- BigDecimal
- BigDecimalEqualityComparer
- BigDecimalOrdinalityComparer
- NumberInfo
- NumberInfoEqualityComparer
- NumberInfoOrdinalityComparer
- Int256
- Int512
- UInt256
- UInt512
- Float128
- Float256
- GenericMath
- NumericsExtensions
- ConversionMode
- ScaleMode
- Hash
- NamedHash
- Sha3
- Sha3Hash224
- Sha3Hash256
- Sha3Hash384
- Sha3Hash512
- Sha3Shake128
- Sha3Shake256
- MerkleTree
- MerkleTree<T>
- PrivateKey
- PublicKey
- NamedPrivateKey
- NamedPublicKey
- EcdhPrivateKey
- EcdhPublicKey
- EcdsaPrivateKey
- EcdsaPublicKey
- EddsaPrivateKey
- EddsaPublicKey
- RsaPrivateKey
- RsaPublicKey
- DigitalSignature
- DigitalSignatureAndPublicKey
- Salt
- Secret
- ICryptoPrimitive<T>
- IHashable
- IEcdhPrivateKey
- IEcdsaPrivateKey
- IEddsaPrivateKey
- IRsaPrivateKey
- IPrivateKeyDerivable<T>
- IPrivateKeyExportable
- IPrivateKeyImportable<T>
- IPrivateKeyPemImportable<T>
- IPrivateKeyPkcs8Exportable
- IPrivateKeyPkcs8Importable<T>
- IPrivateKeyPkcs8PemExportable
- IPrivateKeyRawExportable
- IPrivateKeyRawImportable<T>
- IPrivateKeyRawPemExportable
- IEcdhPublicKey
- IEcdsaPublicKey
- IEddsaPublicKey
- IRsaPublicKey
- IPublicKeyExportable
- IPublicKeyImportable<T>
- IPublicKeyPemExportable
- IPublicKeyPemImportable<T>
- IPublicKeyRawExportable
- IPublicKeyRawImportable<T>
- HashAlgorithmExtensions
- ReadOnlySpanExtensions