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
use std::borrow::Cow;

use crate::{Codec, Error, SECP256K1_PUB};

impl Codec for k256::PublicKey {
    const CODEC: u64 = SECP256K1_PUB;

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

    fn to_bytes(&self) -> Cow<[u8]> {
        Cow::Owned(self.to_sec1_bytes().into_vec())
    }
}