Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

End Of Semester Project - Merge #170

Merged
merged 132 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
7998bd6
change some error checking method
MaximeZmt Feb 25, 2024
036084d
Merge pull request #1 from MaximeZmt/Work-Mzmt-RefactorEvotingMod_Test
MaximeZmt Feb 27, 2024
c703526
Merge branch 'c4dt:main' into main
MaximeZmt Mar 4, 2024
89f11d2
Merge branch 'c4dt:main' into main
MaximeZmt Mar 7, 2024
c2dd4a2
Merge branch 'c4dt:main' into main
MaximeZmt Mar 14, 2024
463b91a
add formAdmin struct
MaximeZmt Mar 25, 2024
b9e2bf7
patch linting
MaximeZmt Mar 25, 2024
f35632e
push working changes there
MaximeZmt Mar 27, 2024
2a28803
Update .gitignore
MaximeZmt Mar 27, 2024
a1ec49a
address changes
MaximeZmt Mar 27, 2024
a27faff
Merge branch 'c4dt:main' into main
MaximeZmt Mar 27, 2024
f35398f
change comment formatting
MaximeZmt Mar 27, 2024
823103a
Update .gitignore
MaximeZmt Mar 27, 2024
4a972d0
make encode function logic simpler
MaximeZmt Mar 27, 2024
84360be
Merge pull request #4 from MaximeZmt/Work-Mzmt-FormAdmin
MaximeZmt Apr 2, 2024
3ad2457
change dela id
MaximeZmt Apr 3, 2024
5e881bb
solve conflict
MaximeZmt Apr 3, 2024
0c596c8
update UserID to VoterID
MaximeZmt Apr 3, 2024
d7ffa0e
happy linter
MaximeZmt Apr 3, 2024
b218c64
happy linter bis
MaximeZmt Apr 3, 2024
399d0f0
change SciperID to UserID
MaximeZmt Apr 3, 2024
8973938
address Carine review
MaximeZmt Apr 16, 2024
2942f02
Merge pull request #5 from MaximeZmt/Work-Mzmt-UserID
MaximeZmt Apr 16, 2024
3151902
add remove and is admin
MaximeZmt Apr 18, 2024
d1bdf22
add ADD_ADMIN and REMOVE_ADMIN cmd
MaximeZmt Apr 18, 2024
639b346
patch current error
MaximeZmt Apr 18, 2024
ec8e93f
create admin form test
MaximeZmt Apr 18, 2024
9732d06
working on the testing part
MaximeZmt Apr 21, 2024
589dfbf
patch test mistake
MaximeZmt Apr 22, 2024
d652b1b
fully working adminForm test
MaximeZmt Apr 22, 2024
c40ff49
clean test
MaximeZmt Apr 22, 2024
721ba90
linter compliance
MaximeZmt Apr 22, 2024
c7c1323
linter compliance part 2
MaximeZmt Apr 22, 2024
9439cda
remove double name var on my new code plus some other spotted places
MaximeZmt Apr 23, 2024
49fd9a2
improve refactoring
MaximeZmt Apr 23, 2024
fa9af1c
patch #1
MaximeZmt Apr 23, 2024
da0a080
remove old code
MaximeZmt Apr 23, 2024
28939bb
revert to longer var name
MaximeZmt Apr 23, 2024
9f1de8b
attempt to simplify the code
MaximeZmt Apr 23, 2024
202a266
address review
MaximeZmt Apr 25, 2024
4a6d878
patch vet check
MaximeZmt Apr 25, 2024
78e8542
final review
MaximeZmt Apr 25, 2024
4ccdcaa
Merge pull request #6 from MaximeZmt/Work-Mzmt-AdminFormLogic
MaximeZmt Apr 25, 2024
5f1827a
modification of data struct + create form
MaximeZmt Apr 22, 2024
8b5a014
implement the basic logic for owners and voters
MaximeZmt Apr 22, 2024
f117081
patch sciper type
MaximeZmt Apr 22, 2024
fff22fe
patch dummy userid to sciper format
MaximeZmt Apr 22, 2024
e9f505a
patch dummy userid to sciper format part 2
MaximeZmt Apr 22, 2024
c767aa7
improve code readability
MaximeZmt Apr 24, 2024
104bbbd
add necessary command and data struct
MaximeZmt Apr 24, 2024
179cb94
add template of owner and voter manager
MaximeZmt Apr 28, 2024
a4720c4
add logic for managers voters and owners
MaximeZmt Apr 28, 2024
6160325
implem test
MaximeZmt Apr 29, 2024
d376a0a
add test voters list
MaximeZmt Apr 29, 2024
dd183a6
clean + comment test
MaximeZmt Apr 29, 2024
835ce87
patch for vet
MaximeZmt Apr 29, 2024
42bab3f
merge manager voters and owners
MaximeZmt Apr 30, 2024
ea3f62a
improve code
MaximeZmt Apr 30, 2024
4fa972b
apply SciperToInt method to admin
MaximeZmt Apr 30, 2024
aff482d
patch broken test
MaximeZmt Apr 30, 2024
fa17b8e
start implement is admin logic
MaximeZmt May 1, 2024
218128b
ongoing implem
MaximeZmt May 2, 2024
03606e1
add SciperToInt to AddVoter
MaximeZmt May 2, 2024
64f7dbb
change error message to make them more clear
MaximeZmt May 2, 2024
4d48f2b
change error message to make them more clear part 2
MaximeZmt May 2, 2024
d75c5d1
add an additional SciperToInt Method
MaximeZmt May 2, 2024
445c009
patched unvalid userid in test
MaximeZmt May 2, 2024
b54e0f4
update a comment in the test
MaximeZmt May 2, 2024
0f440cc
update a comment in the test 2
MaximeZmt May 2, 2024
3edb051
Merge pull request #7 from MaximeZmt/Work-Mzmt-FormModification
MaximeZmt May 3, 2024
6a4dffa
patch changes
MaximeZmt May 11, 2024
44bab35
patch changes 2
MaximeZmt May 11, 2024
26fd707
Init AdminForm method
MaximeZmt May 11, 2024
f3aed81
now need an admin perm on blockchain to create form
MaximeZmt May 11, 2024
ecdfd61
Merge branch 'main' into Work-Mzmt-AdminLogic
MaximeZmt May 11, 2024
a3cb443
evening work refactor part 1
MaximeZmt May 14, 2024
483d417
merge rebase
MaximeZmt May 14, 2024
4b47701
patch one test
MaximeZmt May 14, 2024
eccc6fe
Merge branch 'Work-Mzmt-Admin-Logic-Patch' into Work-Mzmt-AdminLogic
MaximeZmt May 14, 2024
d1074cc
patch vet
MaximeZmt May 14, 2024
3a64006
patch even more adminform to adminlist
MaximeZmt May 15, 2024
6a346c0
getting rid of adminform
MaximeZmt May 15, 2024
cdde2db
add performing and target field
MaximeZmt May 16, 2024
ab8faac
patch error and test
MaximeZmt May 16, 2024
357e4ac
some minor changes
MaximeZmt May 16, 2024
45b5ab4
small code cleaning
MaximeZmt May 21, 2024
78977de
Update contracts/evoting/evoting.go
MaximeZmt May 23, 2024
18e7325
Update contracts/evoting/mod_test.go
MaximeZmt May 23, 2024
22661a2
Update contracts/evoting/types/admin.go
MaximeZmt May 23, 2024
10e8080
Update contracts/evoting/types/admin.go
MaximeZmt May 23, 2024
ef2af91
address partial review
MaximeZmt May 23, 2024
5b22dad
isAdmin function
MaximeZmt May 23, 2024
302a4b0
patch updatemetadata review
MaximeZmt May 23, 2024
df96a91
patch ownervoter test
MaximeZmt May 23, 2024
a6d8e8d
Update evoting.go
MaximeZmt May 23, 2024
36ebc0b
patch is admin error mgmt
MaximeZmt May 23, 2024
645a08f
patch test
MaximeZmt May 23, 2024
bf030a2
patch isAdmin structure
MaximeZmt May 23, 2024
c014c6e
Address review
MaximeZmt May 24, 2024
ca82ad0
Merge pull request #8 from MaximeZmt/Work-Mzmt-AdminLogic
MaximeZmt May 24, 2024
7f070ac
first version of ownersvoters logic
MaximeZmt May 27, 2024
b291e37
remove slices package and replace it by hand implemented method
MaximeZmt May 27, 2024
fbbed41
patch integration test for createform and openform
MaximeZmt May 28, 2024
c256b9e
patch shuffle intergration test
MaximeZmt May 28, 2024
2dc4a7c
patch neff test
MaximeZmt May 28, 2024
98c0f46
patch neff test round 2
MaximeZmt May 28, 2024
4a40e99
patch weird neff test
MaximeZmt May 28, 2024
e48be78
remove useless time.sleep
MaximeZmt May 28, 2024
1eb028f
add explanation for voterid
MaximeZmt May 28, 2024
93cdd3b
vet reformat
MaximeZmt May 28, 2024
62cf3e8
Merge pull request #9 from MaximeZmt/Work-Mzmt-OwnersVotersLogic
MaximeZmt May 28, 2024
7242c71
Merge branch 'c4dt:main' into main
MaximeZmt May 29, 2024
b7cf44b
feat: added new interface to the proxy (part 1)
MaximeZmt May 29, 2024
a4d96fb
feat: AddToAdminList first implem
MaximeZmt May 29, 2024
b6d4d25
temp: add info
MaximeZmt May 29, 2024
e3454c4
fix: do reinsert existing admin
MaximeZmt May 29, 2024
d2080fd
Merge pull request #11 from MaximeZmt/Work-Mzmt-FixAddAdmin
MaximeZmt May 29, 2024
36cd87d
feat: update the signature verification on proxy
MaximeZmt Jun 3, 2024
0d6075d
work: working on debugging the new features of the proxy
MaximeZmt Jun 3, 2024
032fe70
work: proxy add/remove/get adminlist
MaximeZmt Jun 4, 2024
ec4fcc1
fix: for display
MaximeZmt Jun 4, 2024
d4cf486
fix: fix bug on transaction result
MaximeZmt Jun 5, 2024
31d1230
fix: code cleaning + continue implem proxy
MaximeZmt Jun 12, 2024
3cc3b98
fix: remove commented query for testing
MaximeZmt Jun 16, 2024
1f14351
fix: improve comments to make govet happy
MaximeZmt Jun 16, 2024
148b6ca
fix: clean the code
MaximeZmt Jun 16, 2024
a91682d
fix: remove debug print
MaximeZmt Jun 20, 2024
cdda328
fix: revert change
MaximeZmt Jun 20, 2024
8e9babf
Merge pull request #10 from MaximeZmt/Work-Mzmt-EditProxy
MaximeZmt Jun 20, 2024
05b3d33
docs: update api.md
MaximeZmt Jun 26, 2024
98fa438
Update api.md
MaximeZmt Jul 2, 2024
34c8feb
Merge pull request #12 from MaximeZmt/Work-Mzmt-Docs
MaximeZmt Jul 2, 2024
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
76 changes: 76 additions & 0 deletions contracts/evoting/admin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package evoting

import (
"github.com/c4dt/d-voting/contracts/evoting/types"
"github.com/stretchr/testify/require"
"go.dedis.ch/dela/serde"
sjson "go.dedis.ch/dela/serde/json"
"testing"
)

var ctxAdminTest serde.Context

var formFacAdminTest serde.Factory
var transactionFacAdminTest serde.Factory

func init() {
ciphervoteFac := types.CiphervoteFactory{}
formFacAdminTest = types.NewFormFactory(ciphervoteFac, fakeAuthorityFactory{})
transactionFacAdminTest = types.NewTransactionFactory(ciphervoteFac)

ctxAdminTest = sjson.NewContext()
}

// This test create an Admin Form structure which is then serialized and
// deserialized to check whether these operations work as intended.
// Serialization/Deserialization of an AdminList should not change its values.
func TestAdmin_Serde(t *testing.T) {
initialAdminList := []int{111111, 222222, 333333, 123456}

adminList := types.AdminList{AdminList: initialAdminList}

value, err := adminList.Serialize(ctxAdminTest)

require.NoError(t, err)

// deserialization
deserializedAdminList := types.AdminList{}

msgs, err := deserializedAdminList.Deserialize(ctxAdminTest, value)

require.NoError(t, err)

updatedAdminList := msgs.(types.AdminList)

require.Equal(t, initialAdminList, updatedAdminList.AdminList)
}

func TestAdmin_AddAdminAndRemoveAdmin(t *testing.T) {
initialAdminList := []int{}

myTestID := "123456"

adminList := types.AdminList{AdminList: initialAdminList}

res, err := adminList.GetAdminIndex(myTestID)
require.Equal(t, -1, res)
require.NoError(t, err)

err = adminList.AddAdmin(myTestID)
require.NoError(t, err)
res, err = adminList.GetAdminIndex(myTestID)
require.Equal(t, 0, res)
require.NoError(t, err)

err = adminList.RemoveAdmin(myTestID)
require.ErrorContains(t, err, "cannot remove this Admin because it is the only one remaining")

err = adminList.AddAdmin("654321")
require.NoError(t, err)

err = adminList.RemoveAdmin(myTestID)
require.NoError(t, err)
res, err = adminList.GetAdminIndex(myTestID)
require.Equal(t, -1, res)
require.NoError(t, err)
}
33 changes: 22 additions & 11 deletions contracts/evoting/controller/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ const (
contentType = "application/json"
formPath = "/evoting/forms"
// FormPathSlash is the path to the form with a trailing slash
FormPathSlash = formPath + "/"
formIDPath = FormPathSlash + "{formID}"
transactionSlash = "/evoting/transactions/"
FormPathSlash = formPath + "/"
formIDPath = FormPathSlash + "{formID}"
transactionSlash = "/evoting/transactions/"

evotingPathSlash = "/evoting/"

transactionPath = transactionSlash + "{token}"
unexpectedStatus = "unexpected status: %s, body: %s"
failRetrieveDecryption = "failed to retrieve decryption key: %v"
Expand Down Expand Up @@ -169,12 +172,19 @@ func (a *RegisterAction) Execute(ctx node.Context) error {
return xerrors.Errorf("failed to unmarshal proxy key: %v", err)
}

transactionManager := txnmanager.NewTransactionManager(mngr, p, sjson.NewContext(), proxykey, blocks, signer)
transactionManager := txnmanager.NewTransactionManager(mngr, p, sjson.NewContext(), proxykey, blocks, signer, validation)

ep := eproxy.NewForm(ordering, p, sjson.NewContext(), formFac, proxykey, transactionManager)

router := mux.NewRouter()

router.HandleFunc(evotingPathSlash+"addadmin", ep.AddAdmin).Methods("POST")
router.HandleFunc(evotingPathSlash+"removeadmin", ep.RemoveAdmin).Methods("POST")
router.HandleFunc(evotingPathSlash+"adminlist", ep.AdminList).Methods("GET")
router.HandleFunc(formIDPath+"/addowner", ep.AddOwnerToForm).Methods("POST")
router.HandleFunc(formIDPath+"/removeowner", ep.RemoveOwnerToForm).Methods("POST")
router.HandleFunc(formIDPath+"/addvoter", ep.AddVoterToForm).Methods("POST")
router.HandleFunc(formIDPath+"/removevoter", ep.RemoveVoterToForm).Methods("POST")
router.HandleFunc(formPath, ep.NewForm).Methods("POST")
router.HandleFunc(formPath, ep.Forms).Methods("GET")
router.HandleFunc(formPath, eproxy.AllowCORS).Methods("OPTIONS")
Expand All @@ -188,6 +198,7 @@ func (a *RegisterAction) Execute(ctx node.Context) error {
router.NotFoundHandler = http.HandlerFunc(eproxy.NotFoundHandler)
router.MethodNotAllowedHandler = http.HandlerFunc(eproxy.NotAllowedHandler)

proxy.RegisterHandler(evotingPathSlash, router.ServeHTTP)
proxy.RegisterHandler(formPath, router.ServeHTTP)
proxy.RegisterHandler(FormPathSlash, router.ServeHTTP)
proxy.RegisterHandler(transactionSlash, router.ServeHTTP)
Expand Down Expand Up @@ -352,8 +363,8 @@ func (a *scenarioTestAction) Execute(ctx node.Context) error {
}

castVoteRequest := ptypes.CastVoteRequest{
UserID: "user1",
Ballot: ballot1,
VoterID: "user1",
Ballot: ballot1,
}

signed, err := createSignedRequest(secret, castVoteRequest)
Expand All @@ -377,8 +388,8 @@ func (a *scenarioTestAction) Execute(ctx node.Context) error {
}

castVoteRequest = ptypes.CastVoteRequest{
UserID: "user2",
Ballot: ballot2,
VoterID: "user2",
Ballot: ballot2,
}

signed, err = createSignedRequest(secret, castVoteRequest)
Expand All @@ -402,8 +413,8 @@ func (a *scenarioTestAction) Execute(ctx node.Context) error {
}

castVoteRequest = ptypes.CastVoteRequest{
UserID: "user3",
Ballot: ballot3,
VoterID: "user3",
Ballot: ballot3,
}

signed, err = createSignedRequest(secret, castVoteRequest)
Expand Down Expand Up @@ -593,7 +604,7 @@ func setupSimpleForm(ctx node.Context, secret kyber.Scalar, proxyAddr1 string,

createSimpleFormRequest := ptypes.CreateFormRequest{
Configuration: configuration,
AdminID: "adminId",
UserID: "UserID",
}

signed, err := createSignedRequest(secret, createSimpleFormRequest)
Expand Down
Loading
Loading