• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / catalyst-libs / 16498400354

24 Jul 2025 01:35PM UTC coverage: 64.185% (-1.6%) from 65.758%
16498400354

push

github

web-flow
feat(general): Get rid from the `path` dependencies (#436)

* wip

* wip

* wip

* wip

10735 of 16725 relevant lines covered (64.19%)

2579.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/rust/catalyst-voting/src/crypto/ed25519/decoding.rs
1
//! `Ed25519` objects decoding implementation
2

3
use anyhow::anyhow;
4
use ed25519_dalek::{
5
    Signature as Ed25519Signature, SigningKey, VerifyingKey, PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH,
6
    SIGNATURE_LENGTH,
7
};
8

9
use super::{PrivateKey, PublicKey, Signature};
10

11
impl PrivateKey {
12
    /// `PrivateKey` bytes size
13
    pub const BYTES_SIZE: usize = SECRET_KEY_LENGTH;
14

15
    /// Convert this `PrivateKey` to its underlying sequence of bytes.
16
    #[must_use]
17
    pub fn to_bytes(&self) -> [u8; Self::BYTES_SIZE] {
×
18
        self.0.to_bytes()
×
19
    }
×
20

21
    /// Attempt to construct a `PrivateKey` from a byte representation.
22
    ///
23
    /// # Errors
24
    ///   - Cannot decode public key.
25
    pub fn from_bytes(bytes: &[u8; Self::BYTES_SIZE]) -> Self {
×
26
        Self(SigningKey::from_bytes(bytes))
×
27
    }
×
28
}
29

30
impl PublicKey {
31
    /// `PublicKey` bytes size
32
    pub const BYTES_SIZE: usize = PUBLIC_KEY_LENGTH;
33

34
    /// Convert this `PublicKey` to its underlying sequence of bytes.
35
    #[must_use]
36
    pub fn to_bytes(&self) -> [u8; Self::BYTES_SIZE] {
×
37
        self.0.to_bytes()
×
38
    }
×
39

40
    /// Attempt to construct a `PublicKey` from a byte representation.
41
    ///
42
    /// # Errors
43
    ///   - Cannot decode public key.
44
    pub fn from_bytes(bytes: &[u8; Self::BYTES_SIZE]) -> anyhow::Result<Self> {
×
45
        Ok(Self(
×
46
            VerifyingKey::from_bytes(bytes).map_err(|_| anyhow!("Cannot decode public key."))?,
×
47
        ))
48
    }
×
49
}
50

51
impl Signature {
52
    /// `Signature` bytes size
53
    pub const BYTES_SIZE: usize = SIGNATURE_LENGTH;
54

55
    /// Convert this `Signature` to its underlying sequence of bytes.
56
    #[must_use]
57
    pub fn to_bytes(&self) -> [u8; Self::BYTES_SIZE] {
×
58
        self.0.to_bytes()
×
59
    }
×
60

61
    /// Attempt to construct a `Signature` from a byte representation.
62
    pub fn from_bytes(bytes: &[u8; Self::BYTES_SIZE]) -> Self {
×
63
        Self(Ed25519Signature::from_bytes(bytes))
×
64
    }
×
65
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc