pub struct DirtyCoreKeyShare<E>where
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
pub fn is_hd_wallet(&self) -> bool
Checks whether the key is HD-capable
Sourcepub fn extended_public_key(&self) -> Option<ExtendedPublicKey<E>>
pub fn extended_public_key(&self) -> Option<ExtendedPublicKey<E>>
Returns extended public key, if HD support was enabled
Sourcepub fn derive_child_public_key<Hd, ChildIndex>(
&self,
derivation_path: impl IntoIterator<Item = ChildIndex>,
) -> Result<ExtendedPublicKey<E>, HdError<<ChildIndex as TryInto<NonHardenedIndex>>::Error>>where
Hd: HdWallet<E>,
NonHardenedIndex: TryFrom<ChildIndex>,
pub fn derive_child_public_key<Hd, ChildIndex>(
&self,
derivation_path: impl IntoIterator<Item = ChildIndex>,
) -> Result<ExtendedPublicKey<E>, HdError<<ChildIndex as TryInto<NonHardenedIndex>>::Error>>where
Hd: HdWallet<E>,
NonHardenedIndex: TryFrom<ChildIndex>,
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
pub fn is_hd_wallet(&self) -> bool
Checks whether the key is HD-capable
Sourcepub fn extended_public_key(&self) -> Option<ExtendedPublicKey<E>>
pub fn extended_public_key(&self) -> Option<ExtendedPublicKey<E>>
Returns extended public key, if HD support was enabled
Sourcepub fn derive_child_public_key<Hd, ChildIndex>(
&self,
derivation_path: impl IntoIterator<Item = ChildIndex>,
) -> Result<ExtendedPublicKey<E>, HdError<<ChildIndex as TryInto<NonHardenedIndex>>::Error>>where
Hd: HdWallet<E>,
NonHardenedIndex: TryFrom<ChildIndex>,
pub fn derive_child_public_key<Hd, ChildIndex>(
&self,
derivation_path: impl IntoIterator<Item = ChildIndex>,
) -> Result<ExtendedPublicKey<E>, HdError<<ChildIndex as TryInto<NonHardenedIndex>>::Error>>where
Hd: HdWallet<E>,
NonHardenedIndex: TryFrom<ChildIndex>,
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§type Target = DirtyKeyInfo<E>
type Target = DirtyKeyInfo<E>
Source§fn deserialize<D>(
deserializer: D,
) -> Result<DirtyCoreKeyShare<E>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<DirtyCoreKeyShare<E>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§type Error = InvalidCoreShare
type Error = InvalidCoreShare
Source§fn is_valid(&self) -> Result<(), <DirtyCoreKeyShare<E> as Validate>::Error>
fn is_valid(&self) -> Result<(), <DirtyCoreKeyShare<E> as Validate>::Error>
Source§fn validate_parts(
_: &(u16, DirtyKeyInfo<E>, NonZero<SecretScalar<E>>),
) -> Result<(), <DirtyCoreKeyShare<E> as Validate>::Error>
fn validate_parts( _: &(u16, DirtyKeyInfo<E>, NonZero<SecretScalar<E>>), ) -> Result<(), <DirtyCoreKeyShare<E> as Validate>::Error>
Source§fn from_parts(
_: (u16, DirtyKeyInfo<E>, NonZero<SecretScalar<E>>),
) -> DirtyCoreKeyShare<E>
fn from_parts( _: (u16, DirtyKeyInfo<E>, NonZero<SecretScalar<E>>), ) -> DirtyCoreKeyShare<E>
Self from partsAuto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.