Repository navigation
Expand file tree
/
Copy pathdoc.go
More file actions
128 lines (128 loc) · 7.16 KB
/
Copy pathdoc.go
File metadata and controls
128 lines (128 loc) · 7.16 KB
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
// Package dklstss implements threshold ECDSA on secp256k1 following the
// DKLs23 protocol (Doerner, Kondi, Lee, Shelat, "Threshold ECDSA in Three
// Rounds", IACR ePrint 2023/765).
//
// The package wraps crypto/ot/baseot, crypto/ot/otext, and crypto/ot/ole
// to provide:
// - 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 (different N, T, members) preserving
// the public key
// - HD wallet derivation (BIP32 non-hardened) at sign time
// - Malicious-secure signing (Mul-then-check) with identifiable abort
// for cryptographically-detectable deviations (Bob's β inconsistency
// across parallel ΠMul runs)
// - Versioned Key Save/Load for persistence
//
// Peer AUTHENTICATION is OUT OF SCOPE. The broker-driven Party state
// machines trust whatever tss.MessageBroker implementation the caller
// supplies to authenticate message origin. Pinning peer identities,
// signing transport-level messages, and rejecting tampered bytes are
// the implementor's responsibility. Earlier revisions of this package
// exposed Ed25519 identity-key helpers; those were removed because the
// parties did not in fact bind them to round messages.
//
// Peer EQUIVOCATION (a malicious peer running tampered library code
// that ships different VSS commitments to different recipients under
// a single To==nil broadcast) is caught CRYPTOGRAPHICALLY by the
// echo-broadcast phase in keygen / refresh / reshare: every recipient
// broadcasts a SHA-256 digest of every dealer's commitments as it
// received them, and any pair of disagreeing digests aborts the
// protocol with the offending dealer's PartyID returned in the
// *tss.Error's Culprits(). This holds without any trust in the
// broker's broadcast semantics — see dklstss/echo.go.
//
// Compared to the existing GG18-based ecdsatss/ package, dklstss/ has no
// Paillier/MtA layer — the multiplicative-to-additive subprotocol is built
// from oblivious transfer extension instead, sidestepping the entire
// RSA/Paillier-proof attack surface that gave rise to TSSHOCK, Alpha-Rays,
// and related disclosed attacks against GG18 implementations.
//
// APIs: the package provides two styles of every protocol.
//
// - Synchronous in-process: Keygen, Sign, SignChecked, Presign,
// SignWithPresign, Refresh, Reshare, DeriveAndSign. Each takes all
// parties' state as arguments and runs the protocol locally in the
// caller's goroutine. Intended for tests and direct integration.
//
// - Broker-driven Party: NewKeygen / NewSigning / NewPresign /
// NewRefresh / NewResharing each return a per-party state machine
// that runs over a tss.MessageBroker (mirroring the
// ecdsatss/eddsatss/frosttss pattern). Round-by-round messages flow
// via tss.JsonWrap / tss.NewJsonExpect; the result lands on Done
// or Err. Suited to real distributed deployment (each party in its
// own process, connected by network transport that implements
// tss.MessageBroker).
//
// Threading model: a Key produced by Keygen() is read-only after Keygen
// returns. Sign, Presign, SignWithPresign, DeriveChild, DeriveAndSign do
// NOT mutate the Key or its OT-extension setup state; multiple
// goroutines may invoke them concurrently against the same []*Key
// without external synchronization. Refresh DOES return a new []*Key;
// callers must atomically swap the slice reference under their own
// synchronization if they refresh while signing. PresignOutput uses an
// atomic CAS to enforce single-use, so concurrent SignWithPresign
// calls on the same presign are race-safe (exactly one succeeds).
//
// SECURITY STATUS — PRE-AUDIT.
//
// This implementation has NOT received external cryptographic review and
// SHOULD NOT be used in production until that audit completes. The
// protocol surface is feature-complete; what follows is the threat-model
// summary callers should weigh before deployment:
//
// - Secret-scalar multiplications (signing nonces k_i, base-OT sender
// trapdoor y) route through crypto/ctmul, which implements a
// Montgomery ladder over secp256k1 Jacobian coordinates with Z
// randomization, 64-bit scalar blinding, and byte-level constant-time
// conditional swap. See ctmul/doc.go for the threat-model details
// and the residual identity-branch caveat.
// - ΠMul is malicious-secure against the receiver via the OT extension's
// KOS-style consistency check, and against the sender via DKLs23 §5
// "Mul-then-check" (cross-run β-consistency). SignChecked surfaces
// check failures as tss.Error with Culprits populated; in plain Sign,
// a malicious party's wrong shares are caught one layer up by ECDSA
// signature verification.
// - OT-extension reuse: the long-term OT extension setup established
// at DKG time is reused across many signing/presigning sessions.
// The PRG derivation in crypto/ot/otext binds every Extend
// invocation to its caller-supplied sid, and signing_party.go /
// presign_party.go mix every signer's freshly-random K_i into the
// round-2 sid before any ΠMul runs — so re-running the same
// protocol with identical static inputs (same key, same subset,
// same message) cannot produce identical OT-extension sids between
// calls.
// - Pre-sign single-use is enforced in two layers: an in-memory atomic
// CAS on PresignOutput, and an optional UsedPresignStore interface
// for caller-provided durable nonce-commitment tracking across
// process restarts (SignWithPresignDurable). The library does not
// prescribe a storage backend — that is the caller's responsibility.
// - Identifiable abort surfaces ONLY for cryptographically-detectable
// deviations: a malicious Bob who uses inconsistent β across the two
// parallel ΠMul runs is caught by SignChecked (synchronous) or
// CheckedSigningParty (broker-driven) and the deviating PartyID is
// returned in the *tss.Error's Culprits(). Transport-level
// equivocation of K_i is caught by the echo-broadcast phase in
// SigningParty.round2KCollect / PresignParty.round2KCollect with
// N >= 3 signers; with N = 2 the protocol can detect but not
// attribute. Other transport-level equivocation classes remain the
// caller's responsibility — bind them at the tss.MessageBroker
// layer.
//
// # ChainCode privacy
//
// The BIP32 chain code attached to every Key is a DETERMINISTIC function
// of the joint public key (see deriveChainCode). It is NOT a per-DKG
// secret. Anyone who knows the joint pub can recompute the chain code
// and derive every non-hardened descendant address — a deliberate
// departure from BIP32's "chain code is a shared secret" assumption.
// Implication: descendants of a DKLs23 key are PUBLICLY DERIVABLE.
// Hardened HD derivation (which would close this gap) is unsupported.
// For descendant privacy, generate a fresh DKG per identity.
//
// References:
// - J. Doerner, Y. Kondi, E. Lee, A. Shelat. "Threshold ECDSA in Three
// Rounds", IACR ePrint 2023/765.
package dklstss