alice-auth 0.5.0

Ed25519 ZKP auth for ALICE
Documentation
//! random.

use crate::errors::*;

// Random
// ============================================================================

/// # Errors
/// Returns `AuthError::E5` if the platform RNG fails.
#[inline(always)]
pub fn rand<const N: usize>() -> Result<[u8; N]> {
    let mut b = [0u8; N];
    getrandom::getrandom(&mut b).map_err(|_| AuthError::E5)?;
    Ok(b)
}

/// # Errors
/// Returns `AuthError::E5` if the platform RNG fails.
#[inline(always)]
pub fn challenge() -> Result<[u8; 32]> {
    rand()
}