pub struct DirtyCoreKeyShare<E: Curve> {
pub i: u16,
pub key_info: DirtyKeyInfo<E>,
pub x: NonZero<SecretScalar<E>>,
}Expand description
Dirty (unvalidated) core key share
Key share can be either polynomial or additive:
-
Polynomial key share:
- Supports any threshold $2 \le t \le n$
- All signers co-share a secret polynomial $F(x)$ with degree $deg(F) = t-1$
- Signer with index $i$ (index is in range $0 \le i < n$) holds secret share $x_i = F(I_i)$
- Shared secret key is $\sk = F(0)$.
If key share is polynomial,
vss_setupfiels should beSome(_).$I_j$ mentioned above is defined in
VssSetup::I. Reasonable default would be $I_j = j+1$. -
Additive key share:
- Always non-threshold (i.e. $t=n$)
- Signer with index $i$ holds a secret share $x_i$
- All signers share a secret key that is sum of all secret shares $\sk = \sum_{j \in [n]} x_j$.
Advantage of additive share is that DKG protocol that yields additive share is a bit more efficient.
§HD wallets support
If hd-wallets feature is enabled, key share provides basic support of deterministic key derivation:
chain_codefield is added. If it’sSome(_), then the key is HD-capable.(shared_public_key, chain_code)is extended public key of the wallet (can be retrieved via extended_public_key method).- Setting
chain_codetoNonedisables HD wallets support for the key
- Setting
- Convenient methods are provided such as derive_child_public_key
§Serialization format via serde
We make our best effort to keep serialization format the same between the versions (even with breaking changes), and so far we’ve never introduced breaking change into the serialization format. This ensures that newer versions of library are able to deserialize the key shares produced by the old version version of the library.
It’s unlikely, but at some point, we might introduce a breaking change into the serialization format. In this case, we’ll announce it and publish the migration instructions.
Not every serde backend supports features that we use to ensure backwards compatibility. We require that field names
are being serialized, that helps us adding new fields as the library grows. We strongly advise using either
serde_json, if verbose/human-readable format is needed, or
ciborium, if you’d like to opt for binary format. Other serialization
backends are not tested and may not work or stop working at some point (like bincode did)
or be not backwards compatible between certain versions.
If you need the smallest size of serialized key share, we advise implementing serialization manually (all fields of the key share are public!).
Fields§
§i: u16Index of local party in key generation protocol
key_info: DirtyKeyInfo<E>Public key info
x: NonZero<SecretScalar<E>>Secret share $x_i$
Implementations§
Sourcepub fn is_hd_wallet(&self) -> bool
Available on crate feature hd-wallet only.
pub fn is_hd_wallet(&self) -> bool
hd-wallet only.Checks whether the key is HD-capable
Sourcepub fn extended_public_key(&self) -> Option<ExtendedPublicKey<E>>
Available on crate feature hd-wallet only.
pub fn extended_public_key(&self) -> Option<ExtendedPublicKey<E>>
hd-wallet only.Returns extended public key, if HD support was enabled
Sourcepub fn derive_child_public_key<Hd: HdWallet<E>, ChildIndex>(
&self,
derivation_path: impl IntoIterator<Item = ChildIndex>,
) -> Result<ExtendedPublicKey<E>, HdError<<ChildIndex as TryInto<NonHardenedIndex>>::Error>>where
NonHardenedIndex: TryFrom<ChildIndex>,
Available on crate feature hd-wallet only.
pub fn derive_child_public_key<Hd: HdWallet<E>, ChildIndex>(
&self,
derivation_path: impl IntoIterator<Item = ChildIndex>,
) -> Result<ExtendedPublicKey<E>, HdError<<ChildIndex as TryInto<NonHardenedIndex>>::Error>>where
NonHardenedIndex: TryFrom<ChildIndex>,
hd-wallet only.Derives child public key, if it’s HD key
Methods from Deref<Target = DirtyKeyInfo<E>>§
Returns share preimage associated with j-th signer
- For additive shares, share preimage is defined as
j+1 - For VSS-shares, share preimage is scalar $I_j$ such that $x_j = F(I_j)$ where $F(x)$ is polynomial co-shared by the signers and $x_j$ is secret share of j-th signer
Note: if you have no idea what it is, probably you don’t need it.
Sourcepub fn is_hd_wallet(&self) -> bool
Available on crate feature hd-wallet only.
pub fn is_hd_wallet(&self) -> bool
hd-wallet only.Checks whether the key is HD-capable
Sourcepub fn extended_public_key(&self) -> Option<ExtendedPublicKey<E>>
Available on crate feature hd-wallet only.
pub fn extended_public_key(&self) -> Option<ExtendedPublicKey<E>>
hd-wallet only.Returns extended public key, if HD support was enabled
Sourcepub fn derive_child_public_key<Hd: HdWallet<E>, ChildIndex>(
&self,
derivation_path: impl IntoIterator<Item = ChildIndex>,
) -> Result<ExtendedPublicKey<E>, HdError<<ChildIndex as TryInto<NonHardenedIndex>>::Error>>where
NonHardenedIndex: TryFrom<ChildIndex>,
Available on crate feature hd-wallet only.
pub fn derive_child_public_key<Hd: HdWallet<E>, ChildIndex>(
&self,
derivation_path: impl IntoIterator<Item = ChildIndex>,
) -> Result<ExtendedPublicKey<E>, HdError<<ChildIndex as TryInto<NonHardenedIndex>>::Error>>where
NonHardenedIndex: TryFrom<ChildIndex>,
hd-wallet only.Derives child public key, if it’s HD key, using HdWallet algorithm
Trait Implementations§
Source§fn as_ref(&self) -> &DirtyKeyInfo<E>
fn as_ref(&self) -> &DirtyKeyInfo<E>
Source§fn clone(&self) -> DirtyCoreKeyShare<E>
fn clone(&self) -> DirtyCoreKeyShare<E>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§fn validate_parts(
(i, key_info, x): &(u16, DirtyKeyInfo<E>, NonZero<SecretScalar<E>>),
) -> Result<(), Self::Error>
fn validate_parts( (i, key_info, x): &(u16, DirtyKeyInfo<E>, NonZero<SecretScalar<E>>), ) -> Result<(), Self::Error>
Source§fn from_parts(
(i, key_info, x): (u16, DirtyKeyInfo<E>, NonZero<SecretScalar<E>>),
) -> Self
fn from_parts( (i, key_info, x): (u16, DirtyKeyInfo<E>, NonZero<SecretScalar<E>>), ) -> Self
Self from parts