1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//! Threshold ECDSA on secp256k1 — DKLs23 (ePrint 2023/765).
//!
//! Implements threshold ECDSA following the DKLs23 protocol (Doerner, Kondi,
//! Lee, Shelat, "Threshold ECDSA in Three Rounds"). Built on oblivious-transfer
//! extension rather than Paillier/MtA, sidestepping the RSA/Paillier-proof
//! attack surface (TSSHOCK, Alpha-Rays, …) of GG18 implementations.
//!
//! Planned surface:
//! - n-party t-of-n distributed key generation (Feldman VSS based)
//! - (t+1)-party threshold signing producing standard ECDSA signatures
//! - Pre-signing as a separate offline phase with single-use online sign
//! - Proactive share + OT-extension refresh
//! - Resharing to a new committee preserving the public key
//! - HD wallet derivation (BIP32 non-hardened) at sign time
//! - Versioned key save/load for persistence
//!
//! Peer **authentication** is out of scope (the broker is trusted to
//! authenticate message origin). Peer **equivocation** is caught
//! cryptographically by an echo-broadcast phase in keygen/refresh/reshare:
//! disagreeing SHA-256 digests abort with the offending dealer in
//! [`crate::tss::TssError::culprits`].
//!
//! # Security: malicious signers and selective-failure aborts
//!
//! The **default** signing path ([`sign`] / [`SigningParty`]) uses the *plain*
//! OT-based Gilboa multiplication in the `ole` module: Alice's raw secret bits are the
//! OT choice bits and Bob's correction values are unverified. It implements no
//! πMul input-consistency check, so a malicious co-signer can mount a
//! **selective-failure attack**: by corrupting a single chosen OT row or
//! correction value, the session either produces a valid signature or aborts
//! at the final `ecdsa_verify` gate depending on one bit of the victim's
//! secret share/nonce — leaking roughly one bit per aborted signing session.
//! This default path is kept **byte-compatible with Go tss-lib's default
//! (unchecked) signing** on purpose, so it is not changed.
//!
//! ## Opt-in malicious-security: the *checked* signing path
//!
//! An **opt-in** Mul-then-check variant (DKLs23 §5) is now available and
//! **SHOULD be used whenever co-signers are not mutually trusted**:
//! - [`sign_checked`] / [`sign_checked_with_tweak`] — synchronous in-process;
//! - [`CheckedSigningParty`] — broker-driven, the security-relevant one
//! (a genuinely remote malicious peer can only deviate over the wire).
//!
//! Each cross-term ΠMul is run **twice in parallel** under sub-session-ids
//! `sid|1` and `sid|2` with the same `α`; Bob attaches a cross-run consistency
//! value `Z = u_B1 − u_B2` and Alice rejects unless `Z_A + Z ≡ 0 (mod n)`
//! (see the `ole_check` module). A peer who uses inconsistent `β` across the two runs —
//! the lever of the selective-failure attack — is caught, and in
//! [`CheckedSigningParty`] the offending peer is named in
//! [`crate::tss::TssError::culprits`] (identifiable abort). Cost is roughly
//! 2× the wire/CPU of the default path.
//!
//! **Inherited limitation (matches Go):** this simplified check catches an
//! *inconsistent* `β` across the two runs but **not** a *consistently wrong*
//! `β` (same wrong value in both runs); that residual class is caught only at
//! the signing layer by the final ECDSA verification gate. The full
//! identifiable-abort variant with a Pedersen-style `β` commitment is Go's
//! task #17 and is intentionally not ported.
//!
//! Mitigations that apply to **both** paths: echo-broadcast consistency checks
//! in keygen/refresh/reshare, single-use enforcement of presignatures, the KOS
//! consistency check against a malicious OT-extension *receiver*, and the
//! final verification gate (no invalid signature is ever released).
//!
//! When the **default** (unchecked) path is used with untrusted peers,
//! operators MUST:
//! - treat **repeated signing failures with the same participant set as a
//! potential attack**, not a transient error;
//! - **not retry indefinitely**: bound retries, and after a small number of
//! unexplained aborts stop signing with that set;
//! - rotate the key (reshare to exclude the suspect, or generate a fresh key)
//! once an attack is suspected, since each abort may have leaked a share
//! bit;
//! - or switch to the opt-in checked path above, which closes the
//! selective-failure oracle for the inconsistent-`β` case.
//!
//! # Status
//!
//! In progress. The secp256k1 group layer and OT stack are built on
//! `purecrypto`'s secp256k1 primitives; higher protocol layers follow.
// dklstss is under active construction: lower layers (secp/OT) are exercised by
// tests and by the not-yet-landed protocol layers. Remove once keygen/signing
// wire everything together.
pub
pub
pub
pub
pub
pub
pub
pub use ;
pub use ;
pub use ;
pub use KeygenParty;
pub use ;
pub use RefreshParty;
pub use ;
pub use ResharingParty;
pub use ;
pub use CheckedSigningParty;
pub use SigningParty;
/// Errors raised by the `dklstss` protocols.