Skip to main content

heika_wallet/
lib.rs

1//! ウォレットのための計算。合意形成には関わらない、鍵を作ったり覚えやすくしたり、ノードに鍵を渡したりするもの。
2
3pub mod age;
4pub mod amount;
5pub mod bip39;
6pub mod cipher;
7pub mod harvest_request;
8pub mod keystore;
9pub mod keystore_file;
10pub mod message;
11pub mod slip10;
12
13#[cfg(test)]
14mod testing {
15    /// 決まったバイト列を返すだけの乱数。テストでニーモニックや使い捨ての鍵を固定するのに使う。
16    pub struct Replay<'a>(pub &'a [u8]);
17
18    impl rand_core::TryRng for Replay<'_> {
19        type Error = core::convert::Infallible;
20
21        fn try_next_u32(&mut self) -> Result<u32, Self::Error> {
22            unimplemented!("only fill_bytes is used")
23        }
24
25        fn try_next_u64(&mut self) -> Result<u64, Self::Error> {
26            unimplemented!("only fill_bytes is used")
27        }
28
29        fn try_fill_bytes(&mut self, dst: &mut [u8]) -> Result<(), Self::Error> {
30            let (head, rest) = self.0.split_at(dst.len());
31            dst.copy_from_slice(head);
32            self.0 = rest;
33            Ok(())
34        }
35    }
36
37    impl rand_core::TryCryptoRng for Replay<'_> {}
38}