Skip to main content

Keystore

Struct Keystore 

Source
pub struct Keystore { /* private fields */ }

Implementations§

Source§

impl Keystore

Source

pub fn new() -> Self

Source

pub fn entries(&self) -> &[Entry]

Source

pub fn add(&mut self, entry: Entry) -> Result<(), KeystoreError>

秘密を足す。アカウントのラベルが正しくないか、すでにあるものと重なるなら足さない。

Source

pub fn add_account( &mut self, entry: usize, account: Account, ) -> Result<(), KeystoreError>

すでにある秘密にアカウントを足す。

Source

pub fn rename_account( &mut self, label: &str, new_label: &str, ) -> Result<(), KeystoreError>

アカウントのラベルを変える。

Source

pub fn remove_account( &mut self, label: &str, ) -> Result<(usize, Account), KeystoreError>

アカウントを外す。秘密は、アカウントがなくなっても残す。

Source

pub fn remove_entry(&mut self, entry: usize) -> Result<Entry, KeystoreError>

秘密を、残っているアカウントごと消す。

Source

pub fn accounts(&self) -> impl Iterator<Item = (usize, &Account)>

すべてのアカウントと、その秘密の番号。

Source

pub fn private_key( &self, label: &str, bip39_passphrase: &str, ) -> Result<(&Account, PrivateKey), KeystoreError>

ラベルでアカウントを探し、その秘密鍵を求める。

ニーモニックのアカウントは、bip39_passphrase を BIP39 のパスフレーズにして導出する。 公式ウォレットと同じ鍵になるのは空のときだけで、それ以外は同じ番号でも別の鍵(隠しウォレット)になる。 秘密鍵のアカウントには関係しない。

Source

pub fn fill_harvest_secrets<R: CryptoRng + ?Sized>(&mut self, rng: &mut R)

ハーベストの秘密がない秘密に、新しく作って入れる。すでにあるものは変えない。

Source

pub fn harvester_keys( &self, label: &str, bip39_passphrase: &str, rotation: u32, ) -> Result<Option<HarvesterKeys>, KeystoreError>

ラベルでアカウントを探し、そのハーベストの鍵を求める。

bip39_passphrase は Self::private_key と同じで、ニーモニックのアカウントでだけ使う。 rotation は作り直しの番号で、ふだんは 0。ハーベストの秘密がまだなければ None

Source

pub fn to_text(&self) -> Zeroizing<Vec<u8>>

開いた中身のテキスト。秘密が入るので、消えるようにして返す。

Source

pub fn from_text(text: &[u8]) -> Result<Self, KeystoreError>

開いた中身のテキストを読む。

Source

pub fn seal<R: CryptoRng + ?Sized>( &self, rng: &mut R, passphrase: &[u8], work_factor: u8, ) -> Vec<u8> ⓘ

パスフレーズで暗号化する。

Source

pub fn open(passphrase: &[u8], sealed: &[u8]) -> Result<Self, KeystoreError>

パスフレーズで開く。

Trait Implementations§

Source§

impl Debug for Keystore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Keystore

Source§

fn default() -> Keystore

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.