fn generate_from_entropy(&self, entropy: &Trits<T1B1>) -> Result<Self::PrivateKey, Self::Error> {
        if entropy.len() != HASH_LENGTH {
            return Err(Error::InvalidEntropyLength(entropy.len()));
        }

        if entropy[HASH_LENGTH - 1] != Btrit::Zero {
            return Err(Error::NonNullEntropyLastTrit);
        }

        let mut state = TritBuf::<T1B1Buf>::zeros(self.security_level as usize * SIGNATURE_FRAGMENT_LENGTH);
        let mut shake = Shake256::default();
        let mut ternary_buffer = T243::<Btrit>::default();
        ternary_buffer.copy_from(entropy);
        let mut binary_buffer: I384<BigEndian, U8Repr> = ternary_buffer.into_t242().into();

        shake.update(&binary_buffer[..]);
        let mut reader = shake.finalize_xof();

        for chunk in state.chunks_mut(HASH_LENGTH) {
            reader.read(&mut binary_buffer[..]);
            ternary_buffer = T242::from_i384_ignoring_mst(binary_buffer).into_t243();

            chunk.copy_from(&ternary_buffer);
        }

        Ok(Self::PrivateKey {
            state,
            marker: PhantomData,
        })
    }
/// Derives a private key from entropy using the SHAKE256 extendable-output function.
/// The entropy must be a slice of exactly 243 trits where the last trit is zero.
/// Derives its security assumptions from the properties of the underlying SHAKE function.
Derives a private key from entropy using the SHAKE256 extendable-output function.
The entropy must be a slice of exactly 243 trits where the last trit is zero.
Derives its security assumptions from the properties of the underlying SHAKE function.
Derives a private key from entropy using the SHAKE256 extendable - output function . The entropy must be a slice of exactly 243 trits where the last trit is zero . Derives its security assumptions from the properties of the underlying SHAKE function .
fn generate_from_entropy(&self, entropy: &Trits<T1B1>) -> Result<Self::PrivateKey, Self::Error> {
        if entropy.len() != HASH_LENGTH {
            return Err(Error::InvalidEntropyLength(entropy.len()));
        }
        if entropy[HASH_LENGTH - 1] != Btrit::Zero {
            return Err(Error::NonNullEntropyLastTrit);
        }
        let mut state = TritBuf::<T1B1Buf>::zeros(self.security_level as usize * SIGNATURE_FRAGMENT_LENGTH);
        let mut shake = Shake256::default();
        let mut ternary_buffer = T243::<Btrit>::default();
        ternary_buffer.copy_from(entropy);
        let mut binary_buffer: I384<BigEndian, U8Repr> = ternary_buffer.into_t242().into();
        shake.update(&binary_buffer[..]);
        let mut reader = shake.finalize_xof();
        for chunk in state.chunks_mut(HASH_LENGTH) {
            reader.read(&mut binary_buffer[..]);
            ternary_buffer = T242::from_i384_ignoring_mst(binary_buffer).into_t243();
            chunk.copy_from(&ternary_buffer);
        }
        Ok(Self::PrivateKey {
            state,
            marker: PhantomData,
        })
    }
fn generate_from_entropy ( & self , entropy : & Trits < T1B1 > ) -> Result < Self :: PrivateKey , Self :: Error > { if entropy . len ( ) != HASH_LENGTH { return Err ( Error :: InvalidEntropyLength ( entropy . len ( ) ) ) ; } if entropy [ HASH_LENGTH - 1 ] != Btrit :: Zero { return Err ( Error :: NonNullEntropyLastTrit ) ; } let mut state = TritBuf :: < T1B1Buf > :: zeros ( self . security_level as usize * SIGNATURE_FRAGMENT_LENGTH ) ; let mut shake = Shake256 :: default ( ) ; let mut ternary_buffer = T243 :: < Btrit > :: default ( ) ; ternary_buffer . copy_from ( entropy ) ; let mut binary_buffer : I384 < BigEndian , U8Repr > = ternary_buffer . into_t242 ( ) . into ( ) ; shake . update ( & binary_buffer [ .. ] ) ; let mut reader = shake . finalize_xof ( ) ; for chunk in state . chunks_mut ( HASH_LENGTH ) { reader . read ( & mut binary_buffer [ .. ] ) ; ternary_buffer = T242 :: from_i384_ignoring_mst ( binary_buffer ) . into_t243 ( ) ; chunk . copy_from ( & ternary_buffer ) ; } Ok ( Self :: PrivateKey { state , marker : PhantomData , } ) }
Derives a private key from entropy using the SHAKE256 extendable-output function.
Derives a private key from entropy using the SHAKE256 extendable - output function .
&self
entropy
&Trits<T1B1>
&self
entropy
&Trits<T1B1>