idcrypt 0.2.0

A library for securely collecting, encrypting, and verifying identity information with field-level authorization.
Documentation
use base64::prelude::*;
use p256::{PublicKey, SecretKey};
use crate::{authority::Authority, profile::FieldFlags};

pub struct Collection<'a, F>
where
    F: FieldFlags,
{
    pub(crate) authority: &'a Authority,
    pub(crate) collected_fields: F,
    pub(crate) public_key: PublicKey,
    pub(crate) secret_key: Option<SecretKey>,
    pub(crate) context: String,
}

impl<'a, F> Collection<'a, F>
where
    F: FieldFlags,
{
    pub fn authority(&self) -> &'a Authority {
        self.authority
    }
    pub fn collected_fields(&self) -> F {
        self.collected_fields
    }
    pub fn secret_key(&self) -> Option<String> {
        Some(BASE64_STANDARD.encode(self.secret_key.as_ref()?.to_bytes().to_vec()))
    }
    pub fn context(&self) -> &str {
        &self.context
    }
}