Skip to content

Add a curve-independent Shamir secret sharing implementation. - #134

Open
tbrezot wants to merge 2 commits into
developfrom
tbz/shamir_secret_sharing
Open

Add a curve-independent Shamir secret sharing implementation.#134
tbrezot wants to merge 2 commits into
developfrom
tbz/shamir_secret_sharing

Conversation

@tbrezot

@tbrezot tbrezot commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

This implementation of Shamir secret sharing is based on the generic Field
trait to perform all operations independently from the concrete scalars in use.
This allows instantiating the secret sharing with both the P256 scalars (via the
OpenSSL provider), or the Ristretto/Curve25519 scalars (via the Dalek provider).

Additionally, guaranteed sized serialization is done through the modification of
the FixedSizeCBytes trait (which may be renamed?).

In order to implement this feature, a rework of the global structure of the
library was needed in order to prevent dependency cycles (in which Shamir
requires a concrete instantiation provided by a provider in a different crate,
which in turns depends on the traits that where hosted in the same crate as
Shamir).

Previously, the curve providers depended on traits.rs which was in core,
meaning that instantiating Shamir secret sharing from there would create a
dependency cycle.

NOTE.1 to avoid most breaking change, all base structures are re-exported
from core, almost recovering the same interface as before.

NOTE.2 the Shamir-secret-sharing implementation is tested based on both P256
and R25519 scalars.

NOTE.3 There are still some breaking changes, e.g. some old traits have been
removed and the key derivation as a method has been removed (it is to be replaced by
the use of some KDF).

@tbrezot
tbrezot force-pushed the tbz/shamir_secret_sharing branch from fd2ab4f to 3abf07d Compare August 26, 2026 11:34
This implementation of Shamir secret sharing is based on the generic `Field`
trait to perform all operations independently from the concrete scalars in use.
This allows instantiating the secret sharing with both the P256 scalars (via the
OpenSSL provider), or the Ristretto/Curve25519 scalars (via the Dalek provider).

Additionally, guaranteed sized serialization is done through the modification of
the `FixedSizeCBytes` trait (which may be renamed?).

In order to implement this feature, a rework of the global structure of the
library was needed in order to prevent dependency cycles (in which Shamir
requires a concrete instantiation provided by a provider in a different crate,
which in turns depends on the traits that where hosted in the same crate as
Shamir).

Previously, the curve providers depended on `traits.rs` which was in `core`,
meaning that instantiating Shamir secret sharing from there would create a
dependency cycle.

*NOTE.1* to avoid most breaking change, all `base` structures are re-exported
from `core`, almost recovering the same interface as before.

*NOTE.2* the Shamir-secret-sharing implementation is tested based on both P256
and R25519 scalars.
@tbrezot
tbrezot force-pushed the tbz/shamir_secret_sharing branch from 3abf07d to 875e2c6 Compare August 26, 2026 11:37
pointche-ens
pointche-ens previously approved these changes Aug 26, 2026
Comment thread crates/core/src/shamir.rs

/// Splits a freshly generated `SKSeed` into `share_count` shares such that any
/// `threshold` of them suffice to reconstruct it, using a random polynomial of
/// degree `threshold - 1` over the P-256 scalar field. `threshold` is the

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a generic field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants