forked from taurushq-io/multi-party-sig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmp.go
49 lines (44 loc) · 1.95 KB
/
cmp.go
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
package cmp
import (
"github.com/MixinNetwork/multi-party-sig/common/round"
"github.com/MixinNetwork/multi-party-sig/pkg/math/curve"
"github.com/MixinNetwork/multi-party-sig/pkg/party"
"github.com/MixinNetwork/multi-party-sig/pkg/pool"
"github.com/MixinNetwork/multi-party-sig/pkg/protocol"
"github.com/MixinNetwork/multi-party-sig/protocols/cmp/config"
"github.com/MixinNetwork/multi-party-sig/protocols/cmp/keygen"
"github.com/MixinNetwork/multi-party-sig/protocols/cmp/sign"
)
// Config represents the stored state of a party who participated in a successful `Keygen` protocol.
// It contains secret key material and should be safely stored.
type Config = config.Config
// EmptyConfig creates an empty Config with a fixed group, ready for unmarshalling.
//
// This needs to be used for unmarshalling, otherwise the points on the curve can't
// be decoded.
func EmptyConfig(group curve.Curve) *Config {
return &Config{
Group: group,
}
}
// Keygen generates a new shared ECDSA key over the curve defined by `group`. After a successful execution,
// all participants posses a unique share of this key, as well as auxiliary parameters required during signing.
//
// For better performance, a `pool.Pool` can be provided in order to parallelize certain steps of the protocol.
// Returns *cmp.Config if successful.
func Keygen(group curve.Curve, selfID party.ID, participants []party.ID, threshold int, pl *pool.Pool) protocol.StartFunc {
info := round.Info{
ProtocolID: "cmp/keygen-threshold",
FinalRoundNumber: keygen.Rounds,
SelfID: selfID,
PartyIDs: participants,
Threshold: threshold,
Group: group,
}
return keygen.Start(info, pl)
}
// Sign generates an ECDSA signature for `messageHash` among the given `signers`.
// Returns *ecdsa.Signature if successful.
func Sign(config *Config, signers []party.ID, messageHash []byte, pl *pool.Pool) protocol.StartFunc {
return sign.StartSign(config, signers, messageHash, pl)
}