/rust/registry/src/index.crates.io-1949cf8c6b5b557f/signature-2.2.0/src/keypair.rs
Line | Count | Source |
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 | 0 | fn verifying_key(&self) -> Self::VerifyingKey { |
27 | 0 | self.as_ref().clone() |
28 | 0 | } |
29 | | } |