-
Notifications
You must be signed in to change notification settings - Fork 0
/
bls_common.go
63 lines (52 loc) · 1.33 KB
/
bls_common.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) 2020 The Meter.io developers
// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying
// file LICENSE or <https://www.gnu.org/licenses/lgpl-3.0.html>
package consensus
import (
bls "github.com/saolacoincom/saolacoin/crypto/multi_sig"
)
type BlsCommon struct {
PrivKey bls.PrivateKey //my private key
PubKey bls.PublicKey //my public key
//global params of BLS
system bls.System
params bls.Params
pairing bls.Pairing
}
func NewBlsCommonFromParams(pubKey bls.PublicKey, privKey bls.PrivateKey, system bls.System, params bls.Params, pairing bls.Pairing) *BlsCommon {
return &BlsCommon{
PrivKey: privKey,
PubKey: pubKey,
system: system,
params: params,
pairing: pairing,
}
}
func NewBlsCommon() *BlsCommon {
params := bls.GenParamsTypeA(160, 512)
pairing := bls.GenPairing(params)
system, err := bls.GenSystem(pairing)
if err != nil {
return nil
}
PubKey, PrivKey, err := bls.GenKeys(system)
if err != nil {
return nil
}
return &BlsCommon{
PrivKey: PrivKey,
PubKey: PubKey,
system: system,
params: params,
pairing: pairing,
}
}
func (cc *BlsCommon) GetSystem() *bls.System {
return &cc.system
}
func (cc *BlsCommon) GetPrivKey() bls.PrivateKey {
return cc.PrivKey
}
func (cc *BlsCommon) GetPubKey() *bls.PublicKey {
return &cc.PubKey
}