Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
goshimmer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iota-imt
goshimmer
Commits
6889228b
Commit
6889228b
authored
4 years ago
by
capossele
Browse files
Options
Downloads
Patches
Plain Diff
adds configuration of the dRNG
parent
392db32e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
config.default.json
+6
-0
6 additions, 0 deletions
config.default.json
plugins/drng/drng.go
+36
-0
36 additions, 0 deletions
plugins/drng/drng.go
plugins/drng/parameters.go
+19
-0
19 additions, 0 deletions
plugins/drng/parameters.go
plugins/drng/plugin.go
+35
-1
35 additions, 1 deletion
plugins/drng/plugin.go
with
96 additions
and
1 deletion
config.default.json
+
6
−
0
View file @
6889228b
...
...
@@ -28,6 +28,12 @@
"database"
:
{
"directory"
:
"mainnetdb"
},
"drng"
:
{
"instanceId"
:
1
,
"threshold"
:
3
,
"distributedPubKey"
:
""
,
"committeeMembers"
:
[]
},
"gossip"
:
{
"port"
:
14666
},
...
...
This diff is collapsed.
Click to expand it.
plugins/drng/drng.go
0 → 100644
+
36
−
0
View file @
6889228b
package
drng
import
(
"encoding/base64"
"errors"
"fmt"
"github.com/iotaledger/goshimmer/plugins/config"
"github.com/iotaledger/hive.go/crypto/ed25519"
)
var
(
// ErrParsingCommitteeMember is returned for an invalid committee member
ErrParsingCommitteeMember
=
errors
.
New
(
"cannot parse committee member"
)
)
func
parseCommitteeMembers
()
(
result
[]
ed25519
.
PublicKey
,
err
error
)
{
for
_
,
committeeMember
:=
range
config
.
Node
.
GetStringSlice
(
CFG_COMMITTEE_MEMBERS
)
{
if
committeeMember
==
""
{
continue
}
pubKey
,
err
:=
base64
.
StdEncoding
.
DecodeString
(
committeeMember
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"%w: invalid public key: %s"
,
ErrParsingCommitteeMember
,
err
)
}
publicKey
,
err
,
_
:=
ed25519
.
PublicKeyFromBytes
(
pubKey
)
if
err
!=
nil
{
return
nil
,
err
}
result
=
append
(
result
,
publicKey
)
}
return
result
,
nil
}
This diff is collapsed.
Click to expand it.
plugins/drng/parameters.go
0 → 100644
+
19
−
0
View file @
6889228b
package
drng
import
(
flag
"github.com/spf13/pflag"
)
const
(
CFG_INSTANCE_ID
=
"drng.instanceId"
CFG_THRESHOLD
=
"drng.threshold"
CFG_DISTRIBUTED_PUB_KEY
=
"drng.distributedPubKey"
CFG_COMMITTEE_MEMBERS
=
"drng.committeeMembers"
)
func
init
()
{
flag
.
Uint32
(
CFG_INSTANCE_ID
,
1
,
"instance ID of the drng instance"
)
flag
.
Uint32
(
CFG_THRESHOLD
,
3
,
"BLS threshold of the drng"
)
flag
.
String
(
CFG_DISTRIBUTED_PUB_KEY
,
""
,
"distributed public key of the committee (hex encoded)"
)
flag
.
StringSlice
(
CFG_COMMITTEE_MEMBERS
,
[]
string
{},
"list of committee members of the drng"
)
}
This diff is collapsed.
Click to expand it.
plugins/drng/plugin.go
+
35
−
1
View file @
6889228b
package
drng
import
(
"encoding/hex"
"github.com/iotaledger/goshimmer/packages/binary/drng"
"github.com/iotaledger/goshimmer/packages/binary/drng/payload"
"github.com/iotaledger/goshimmer/packages/binary/drng/state"
cbPayload
"github.com/iotaledger/goshimmer/packages/binary/drng/subtypes/collectiveBeacon/payload"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/message"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/tangle"
"github.com/iotaledger/goshimmer/plugins/config"
"github.com/iotaledger/goshimmer/plugins/messagelayer"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/logger"
...
...
@@ -23,7 +28,36 @@ var (
func
configure
(
*
node
.
Plugin
)
{
log
=
logger
.
NewLogger
(
name
)
Instance
=
drng
.
New
()
// parse identities of the committee members
committeeMembers
,
err
:=
parseCommitteeMembers
()
if
err
!=
nil
{
log
.
Fatalf
(
"Invalid %s: %s"
,
CFG_COMMITTEE_MEMBERS
,
err
)
}
// parse distributed public key of the committee
var
dpk
[]
byte
if
str
:=
config
.
Node
.
GetString
(
CFG_DISTRIBUTED_PUB_KEY
);
str
!=
""
{
bytes
,
err
:=
hex
.
DecodeString
(
str
)
if
err
!=
nil
{
log
.
Fatalf
(
"Invalid %s: %s"
,
CFG_DISTRIBUTED_PUB_KEY
,
err
)
}
if
l
:=
len
(
bytes
);
l
!=
cbPayload
.
PublicKeySize
{
log
.
Fatalf
(
"Invalid %s length: %d, need %d"
,
CFG_DISTRIBUTED_PUB_KEY
,
l
,
cbPayload
.
PublicKeySize
)
}
dpk
=
append
(
dpk
,
bytes
...
)
}
// configure committee
committeeConf
:=
&
state
.
Committee
{
InstanceID
:
config
.
Node
.
GetUint32
(
CFG_INSTANCE_ID
),
Threshold
:
uint8
(
config
.
Node
.
GetUint32
(
CFG_THRESHOLD
)),
DistributedPK
:
dpk
,
Identities
:
committeeMembers
,
}
Instance
=
drng
.
New
(
state
.
SetCommittee
(
committeeConf
))
configureEvents
()
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment