Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
e6d1cc0
add node struct
thehoul Jun 1, 2025
e37dfd6
RBC bracha
thehoul Mar 7, 2025
3afae1b
Fix Bracha RBC implementation and add single test
thehoul Mar 12, 2025
44211ae
Four rounds RBC skeleton
thehoul Mar 12, 2025
932bba3
renaming 4-Round RBC class
thehoul Mar 18, 2025
2e42277
Redefine RBC interface and adapt BrachaRBC. Also add a message interface
thehoul Mar 25, 2025
1601516
temp: try to implement 4RoundsRBC
thehoul Mar 25, 2025
ae821b6
move bracha to its own folder
thehoul Apr 9, 2025
a915f24
add custom data structures
thehoul Apr 9, 2025
777751f
move and implement RS code
thehoul Apr 9, 2025
d747aa8
update RBC interface
thehoul Apr 9, 2025
31cdc6d
export message types to their own file and create protobuf structure
thehoul Apr 9, 2025
6b622b2
move fourround RBC to its own file and implement
thehoul Apr 9, 2025
3fa7549
Temporarily add very basic RS codes and sanity test
thehoul Apr 14, 2025
8790006
remove useless structures
thehoul Apr 14, 2025
6f54cf9
finish 4RoundsRBC implementation and add unit and a simple "everythin…
thehoul Apr 14, 2025
6b6c042
Add 4RoundRBC test with dead nodes
thehoul Apr 14, 2025
6171b25
Remove avss files that should not have been here in the first place
thehoul Apr 14, 2025
34d8e65
Add dying dealer test
thehoul Apr 16, 2025
37d5c31
Change logger and allow disabling
thehoul Apr 16, 2025
f62bec1
Add stop channel to receive methods to allow halting
thehoul Apr 23, 2025
d799cbd
Create rbc_test.yml in branch RBC
thehoul Apr 23, 2025
aa578e0
Change received name for 4Round RBC to f
thehoul Apr 23, 2025
6e0f92d
fix code analysis warnings
thehoul Apr 23, 2025
9ed464c
Update rbc_test.yml
thehoul Apr 23, 2025
640aa73
Update rbc_test.yml
thehoul Apr 23, 2025
f43446a
rename Bracha test
thehoul Apr 23, 2025
d63606d
Add locks to prevent concurrency issues with received and sent arrays
thehoul Apr 23, 2025
7f8edde
Add timeout in RBC test action
thehoul Apr 23, 2025
4187879
add log message
thehoul Apr 23, 2025
b4c53bf
remove ConcurrentMaps
thehoul Apr 23, 2025
7e88edb
update RS codes to use Berlekamp-Welch
thehoul Apr 24, 2025
eb90363
removed messages.go
thehoul Apr 24, 2025
2856699
remove generic type to 4 rounds RBC
thehoul Apr 24, 2025
31a8201
remove generic from RBC interface and remove useless InstanceID type
thehoul Apr 24, 2025
fcf661b
change to pass contexts as discussed in meeting
thehoul Apr 24, 2025
92f5f21
fix fake_network test and data races
thehoul Apr 24, 2025
b145b0a
fix lint
thehoul Apr 25, 2025
35a17af
fix warnings and deprecated gomnd
thehoul Apr 25, 2025
6910234
fix type check in test
thehoul Apr 25, 2025
99b14ae
fix PR reviews
thehoul May 6, 2025
f07af03
fix lint
thehoul May 6, 2025
a0bb7bc
use clearer names in message.proto for 4Rounds RBC
thehoul May 9, 2025
60573d3
rename bracha and 4rounds to rbc because their package name already r…
thehoul May 13, 2025
4f91fc5
add node struct
thehoul Jun 1, 2025
7be11ca
adapt 4rounds RBC test to the new networking
thehoul May 20, 2025
47d66ba
fix lint
thehoul May 20, 2025
3fac02e
add test on UDP with small network
thehoul May 20, 2025
1925e6b
fix lint
thehoul May 20, 2025
1d4ff43
get logger from logging package
thehoul May 20, 2025
da6b3b7
reduce logging
thehoul May 20, 2025
cd711d6
change reed solomon interface to use pointers
thehoul May 20, 2025
b7ed2a2
send one broadcast with all shares instead of one broadcast for each
thehoul May 20, 2025
3633890
add benchmark test to get data
thehoul May 20, 2025
36e5016
fix lint
thehoul May 21, 2025
b21deab
fix RBC receive READY tests
thehoul May 21, 2025
58a1487
remove weird mutex in networking
thehoul May 21, 2025
0a33218
update benchmark csv
thehoul May 21, 2025
fac86fd
fix lint
thehoul May 22, 2025
7b14600
remove unused r in 4Rounds RBC
thehoul May 22, 2025
1f4f31e
add benchmark
thehoul May 22, 2025
04fc272
fix lint
thehoul May 22, 2025
0d0c151
multi RBC - stress tests don't pass
thehoul May 23, 2025
5c9a5fb
fix lint
thehoul May 23, 2025
32d434c
Better channel handling
thehoul May 23, 2025
149861c
of course I forgot to fix lint
thehoul May 23, 2025
7b1af3f
add multiple instances test
thehoul May 23, 2025
3baa8dc
update Bracha implementation to new interface
thehoul May 24, 2025
651e2f7
Update RBC interface
thehoul May 24, 2025
3273df5
add Instance interface to RBC
thehoul May 28, 2025
de290d8
add node struct
thehoul Jun 1, 2025
bc9e380
add padding for message of size different from multiple of threshold+1
thehoul May 28, 2025
f7b9951
make RBC broadcast return the instance created
thehoul Jun 1, 2025
6d208b0
add GetInstances and SetPredicate to the RBC interface
thehoul Jun 5, 2025
9f5aca4
udpate test benchmark to add message bytes count
thehoul Jun 6, 2025
083b609
fix lint
thehoul Jun 24, 2025
0df4d66
fix tests and skip benchmark
thehoul Jun 24, 2025
ee1c3f8
simplify test
thehoul Jun 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/rbc_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: RBC Test

on:
push:
branches: [ main ]
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
test:
strategy:
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{matrix.platform}}
env:
LLVL: trace
steps:
- name: Use Go = 1.23
uses: actions/setup-go@v3
with:
go-version: '=1.23'
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3

# Install gotestfmt on the VM running the action.
- name: Set up gotestfmt
uses: gotesttools/gotestfmt-action@v2
with:
# Pass GITHUB_TOKEN to avoid rate limiting.
token: ${{ secrets.GITHUB_TOKEN }}

- name: Create temp directory
run: |
mkdir -p ./${{ github.run_attempt }}

- name: run RBC Bracha tests
run: go test -json -v -race ./rbc/bracha/... | gotestfmt

- name: run RBC FourRounds tests
run: go test -json -timeout 20m -v -race ./rbc/fourrounds/... | gotestfmt
Binary file added benchmark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ module student_25_adkg
go 1.23.0

require (
github.com/HACKERALERT/infectious v0.0.0-20240622035800-1b100aa35681
github.com/rs/zerolog v1.34.0
github.com/stretchr/testify v1.9.0
go.dedis.ch/kyber/v4 v4.0.0-pre2.0.20250219110603-23debab3f61d
go.dedis.ch/protobuf v1.0.11
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
google.golang.org/protobuf v1.36.6
)

require (
go.dedis.ch/fixbuf v1.0.3 // indirect
golang.org/x/crypto v0.21.0 // indirect
)

require (
Expand All @@ -16,8 +24,6 @@ require (
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/xid v1.6.0 // needed for dedis transport
go.dedis.ch/fixbuf v1.0.3 // indirect
golang.org/x/crypto v0.35.0 // indirect
golang.org/x/sys v0.30.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
24 changes: 20 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
github.com/HACKERALERT/infectious v0.0.0-20240622035800-1b100aa35681 h1:LOILOeWljaUZyXLpJrfY3F2F+YiXKcv867b/35SB1JQ=
github.com/HACKERALERT/infectious v0.0.0-20240622035800-1b100aa35681/go.mod h1:ZGuTcvIkN3f3CPe2PmI4hqVfKD/253FCvrQGDJ+Ca9E=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4=
github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
Expand All @@ -27,21 +30,34 @@ github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.dedis.ch/fixbuf v1.0.3 h1:hGcV9Cd/znUxlusJ64eAlExS+5cJDIyTyEG+otu5wQs=
go.dedis.ch/fixbuf v1.0.3/go.mod h1:yzJMt34Wa5xD37V5RTdmp38cz3QhMagdGoem9anUalw=
go.dedis.ch/kyber/v3 v3.0.4/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ=
go.dedis.ch/kyber/v3 v3.0.9 h1:i0ZbOQocHUjfFasBiUql5zVeC7u/vahFd96DFA8UOWk=
go.dedis.ch/kyber/v3 v3.0.9/go.mod h1:rhNjUUg6ahf8HEg5HUvVBYoWY4boAafX8tYxX+PS+qg=
go.dedis.ch/kyber/v4 v4.0.0-pre2.0.20250219110603-23debab3f61d h1:ah6c/OPmtPzo/7561gsNRZQVyp8uJYD8kaIjAKloXg8=
go.dedis.ch/kyber/v4 v4.0.0-pre2.0.20250219110603-23debab3f61d/go.mod h1:tg6jwKTYEjm94VxkFwiQy+ec9hoQvccIU989wNjXWVI=
golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
go.dedis.ch/protobuf v1.0.5/go.mod h1:eIV4wicvi6JK0q/QnfIEGeSFNG0ZeB24kzut5+HaRLo=
go.dedis.ch/protobuf v1.0.7/go.mod h1:pv5ysfkDX/EawiPqcW3ikOxsL5t+BqnV6xHSmE79KI4=
go.dedis.ch/protobuf v1.0.11 h1:FTYVIEzY/bfl37lu3pR4lIj+F9Vp1jE8oh91VmxKgLo=
go.dedis.ch/protobuf v1.0.11/go.mod h1:97QR256dnkimeNdfmURz0wAMNVbd1VmLXhG1CrTYrJ4=
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
33 changes: 33 additions & 0 deletions messages.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
syntax='proto3';
package typedefs;
option go_package ='./typedefs';

message RBCMessage{
message Propose{
bytes content=1;
}

message Echo{
repeated bytes encodingShares=1;
bytes messageHash=2;
repeated int64 sharesIndices=3;
}

message Ready{
bytes encodingShare=1;
bytes messageHash=2;
int64 index=3;
}

oneof op{
Propose propose_inst=1;
Echo echo_inst=2;
Ready ready_inst=3;
}
}

message Packet {
oneof message {
RBCMessage rbcMessage=1;
}
}
21 changes: 19 additions & 2 deletions networking/fake_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,30 @@ func (n *FakeNetwork) JoinNetwork() (NetworkInterface, error) {
return n.JoinWithBuffer(10000)
}

func (n *FakeNetwork) computeDelayFromTo(from, to int64) (time.Duration, bool) {
delayOut, okOut := n.delayMap[from]
delayIn, okIn := n.delayMap[to]
if !okOut && !okIn {
return 0, false
}
if !okOut {
delayOut = time.Duration(0)
}
if !okIn {
delayIn = time.Duration(0)
}
delay := delayIn + delayOut
return delay, true
}

func (n *FakeNetwork) Send(msg []byte, from, to int64) error {
rcv, ok := n.nodes[to]
if !ok {
return fmt.Errorf("destination node %d not found", to)
}
// Put the message in the recipient's receive channel
delay, ok := n.delayMap[from]
if ok {
delay, delayed := n.computeDelayFromTo(from, to)
if delayed {
go func() {
time.Sleep(delay)
rcv <- msg
Expand Down Expand Up @@ -118,6 +134,7 @@ func (f *FakeInterface) Broadcast(msg []byte) error {
return nil
}

// Receive blocks until something is received or the context passed stops
func (f *FakeInterface) Receive(ctx context.Context) ([]byte, error) {
select {
case msg := <-f.rcvQueue:
Expand Down
68 changes: 68 additions & 0 deletions networking/node.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package networking

import (
"context"
"errors"
"student_25_adkg/logging"
"student_25_adkg/typedefs"
"sync"

"github.com/rs/zerolog"
"google.golang.org/protobuf/proto"
)

type Callback func(*typedefs.Packet) error

type Node struct {
iface NetworkInterface
callback Callback
logger zerolog.Logger
sync.Mutex
}

func NewNode(iface NetworkInterface) *Node {
return &Node{
iface: iface,
logger: logging.GetLogger(iface.GetID()),
}
}

func (n *Node) Start(ctx context.Context) error {
for {
bs, err := n.iface.Receive(ctx)
if err != nil {
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return err
}
}

err = n.handleMessage(bs)
if err != nil {
n.logger.Error().Err(err).Msg("failed to handle message")
}

}
}

func (n *Node) handleMessage(message []byte) error {
packet := &typedefs.Packet{}
err := proto.Unmarshal(message, packet)
if err != nil {
return err
}
return n.callback(packet)
}

func (n *Node) SetCallback(callback Callback) {
n.Lock()
defer n.Unlock()
n.callback = callback
}

func (n *Node) Broadcast(packet *typedefs.Packet) error {
bs, err := proto.Marshal(packet)
if err != nil {
return err
}
return n.iface.Broadcast(bs)
}
2 changes: 0 additions & 2 deletions networking/socket_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ func (n *SocketNetwork) Receive(ctx context.Context) ([]byte, error) {
case <-n.stop:
return nil, fmt.Errorf("network stopped")
case msg := <-n.incoming:
n.recvMutex.Lock()
n.recvMutex.Unlock()
return msg, nil
}
}
Expand Down
21 changes: 21 additions & 0 deletions rbc/bracha/messaging.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package bracha

type Message struct {
MsgType MessageType
Content bool
}

func NewBrachaMessage(msgType MessageType, content bool) *Message {
return &Message{
MsgType: msgType,
Content: content,
}
}

type MessageType uint32

const (
PROPOSE MessageType = iota
ECHO
READY
)
Loading