aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / vendor / signature / src / keypair.rs
| 1 | //! Signing keypairs. |
| 2 | |
| 3 | /// Signing keypair with an associated verifying key. |
| 4 | /// |
| 5 | /// This represents a type which holds both a signing key and a verifying key. |
| 6 | pub trait Keypair { |
| 7 | /// Verifying key type for this keypair. |
| 8 | type VerifyingKey: Clone; |
| 9 | |
| 10 | /// Get the verifying key which can verify signatures produced by the |
| 11 | /// signing key portion of this keypair. |
| 12 | fn verifying_key(&self) -> Self::VerifyingKey; |
| 13 | } |
| 14 | |
| 15 | /// Signing keypair with an associated verifying key. |
| 16 | /// |
| 17 | /// This represents a type which holds both a signing key and a verifying key. |
| 18 | pub trait KeypairRef: AsRef<Self::VerifyingKey> { |
| 19 | /// Verifying key type for this keypair. |
| 20 | type VerifyingKey: Clone; |
| 21 | } |
| 22 | |
| 23 | impl<K: KeypairRef> Keypair for K { |
| 24 | type VerifyingKey = <Self as KeypairRef>::VerifyingKey; |
| 25 | |
| 26 | fn verifying_key(&self) -> Self::VerifyingKey { |
| 27 | self.as_ref().clone() |
| 28 | } |
| 29 | } |