pub struct Salter { /* private fields */ }Expand description
Salter is Matter subclass to maintain random salt for secrets (private keys) Its .raw is random salt, .code as cipher suite for salt
To initialize with deterministic salt pass in 16 bytes for raw: salter = Salter::new(Some(b“0123456789abcdef“), None, None).unwrap();
To create a deterministic secret, seed, or private key from salt call .signer: signer = salter.signer(Some(mtr_dex::ED25519_SEED), Some(true), “”, None, false).unwrap();
Implementations§
Source§impl Salter
impl Salter
Sourcepub fn new(
raw: Option<&[u8]>,
code: Option<&str>,
tier: Option<Tiers>,
) -> Result<Self, MatterError>
pub fn new( raw: Option<&[u8]>, code: Option<&str>, tier: Option<Tiers>, ) -> Result<Self, MatterError>
Initialize salter’s raw and code
Sourcepub fn stretch(
&self,
size: usize,
path: &str,
tier: Option<&Tiers>,
temp: bool,
) -> Result<Vec<u8>, MatterError>
pub fn stretch( &self, size: usize, path: &str, tier: Option<&Tiers>, temp: bool, ) -> Result<Vec<u8>, MatterError>
Returns raw binary seed (secret) derived from path and .raw and stretched to size given by code using argon2id stretching algorithm.
Sourcepub fn signer(
&self,
code: Option<&str>,
transferable: Option<bool>,
path: &str,
tier: Option<&Tiers>,
temp: bool,
) -> Result<Signer, MatterError>
pub fn signer( &self, code: Option<&str>, transferable: Option<bool>, path: &str, tier: Option<&Tiers>, temp: bool, ) -> Result<Signer, MatterError>
Returns Signer instance whose .raw secret is derived from path and salter’s .raw and stretched to size given by code. The signers public key for its .verfer is derived from code and transferable.
Sourcepub fn signers(
&self,
count: usize,
start: usize,
path: &str,
code: Option<&str>,
transferable: Option<bool>,
tier: Option<&Tiers>,
temp: bool,
) -> Result<Vec<Signer>, MatterError>
pub fn signers( &self, count: usize, start: usize, path: &str, code: Option<&str>, transferable: Option<bool>, tier: Option<&Tiers>, temp: bool, ) -> Result<Vec<Signer>, MatterError>
Returns vector of count number of Signer instances with unique derivation path made from path prefix and suffix of start plus offset for each count value from 0 to count - 1.