askar-crypto 0.3.7

Hyperledger Aries Askar cryptography
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use elliptic_curve::{
    bigint::{Encoding, Limb},
    Curve, SecretKey,
};

pub fn write_sk<C: Curve>(sk: &SecretKey<C>, out: &mut [u8]) {
    let limbs = sk.as_scalar_primitive().as_limbs();
    debug_assert_eq!(out.len(), Limb::BYTES * limbs.len());

    for (src, dst) in limbs
        .iter()
        .rev()
        .cloned()
        .zip(out.chunks_exact_mut(Limb::BYTES))
    {
        dst.copy_from_slice(&src.to_be_bytes());
    }
}