ssi-multicodec 0.2.0

Implementation of the Multicodec specification for the ssi library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::borrow::Cow;

use crate::{Codec, Error, ED25519_PUB};
use ed25519_dalek::VerifyingKey;

impl Codec for VerifyingKey {
    const CODEC: u64 = ED25519_PUB;

    fn from_bytes(bytes: &[u8]) -> Result<Self, Error> {
        Self::try_from(bytes).map_err(|_| Error::InvalidData)
    }

    fn to_bytes(&self) -> Cow<[u8]> {
        Cow::Borrowed(self.as_bytes().as_slice())
    }
}