Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
belenios
belenios
Commits
7d274e7a
Commit
7d274e7a
authored
May 22, 2013
by
Stephane Glondu
Browse files
Use raw ballots for hashing
parent
cf5d746a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/web/common.ml
View file @
7d274e7a
...
...
@@ -93,7 +93,7 @@ let load_elections_and_votes dirname =
Lwt_stream
.
map
(
fun
x
->
let
v
=
Serializable_compat_j
.
ballot_of_string
Serializable_builtin_j
.
read_number
x
in
assert
(
Uuidm
.
equal
uuid
v
.
election_uuid
);
v
x
,
v
)
)
else
Lwt_stream
.
from_direct
(
fun
()
->
None
)
in
...
...
@@ -102,37 +102,3 @@ let load_elections_and_votes dirname =
|
None
->
assert
false
)
else
Lwt
.
return
None
)
let
concat
s
l
f
=
String
.
concat
s
(
List
.
map
f
(
Array
.
to_list
l
))
let
hash_ballot
v
=
concat
"//"
v
.
answers
(
fun
a
->
concat
"|"
a
.
choices
(
fun
c
->
Printf
.
sprintf
"%s,%s"
(
Z
.
to_string
c
.
alpha
)
(
Z
.
to_string
c
.
beta
)
)
^
"#"
^
concat
"|"
a
.
individual_proofs
(
fun
p
->
concat
"/"
p
(
fun
pi
->
Printf
.
sprintf
"%a,%a,%a,%a"
Z
.
sprint
pi
.
dp_commitment
.
a
Z
.
sprint
pi
.
dp_commitment
.
b
Z
.
sprint
pi
.
dp_challenge
Z
.
sprint
pi
.
dp_response
)
)
^
"#"
^
concat
"/"
a
.
overall_proof
(
fun
pi
->
Printf
.
sprintf
"%a,%a,%a,%a"
Z
.
sprint
pi
.
dp_commitment
.
a
Z
.
sprint
pi
.
dp_commitment
.
b
Z
.
sprint
pi
.
dp_challenge
Z
.
sprint
pi
.
dp_response
)
)
^
"#"
^
v
.
election_hash
^
"#"
^
(
Uuidm
.
to_string
v
.
election_uuid
)
|>
hashB
let
hash_user
v
=
Serializable_compat_j
.
string_of_user
v
|>
hashB
src/web/common.mli
View file @
7d274e7a
...
...
@@ -7,8 +7,7 @@ type election_data = {
public_data
:
Z
.
t
election_public_data
;
}
val
load_elections_and_votes
:
string
->
(
election_data
*
Z
.
t
ballot
Lwt_stream
.
t
)
Lwt_stream
.
t
val
hashB
:
string
->
string
val
hash_ballot
:
Z
.
t
ballot
->
string
val
hash_user
:
user
->
string
val
load_elections_and_votes
:
string
->
(
election_data
*
(
string
*
Z
.
t
ballot
)
Lwt_stream
.
t
)
Lwt_stream
.
t
src/web/registration.ml
View file @
7d274e7a
...
...
@@ -32,8 +32,8 @@ let () =
lwt
()
=
Ocsipersist
.
add
elections_table
uuid
e
in
let
uuid_underscored
=
String
.
map
(
function
'
-
'
->
'
_'
|
c
->
c
)
uuid
in
let
table
=
Ocsipersist
.
open_table
(
"ballots_"
^
uuid_underscored
)
in
lwt
()
=
Lwt_stream
.
iter_s
(
fun
v
->
Ocsipersist
.
add
table
(
Common
.
hash
_ballot
v
)
v
lwt
()
=
Lwt_stream
.
iter_s
(
fun
(
r
,
v
)
->
Ocsipersist
.
add
table
(
Common
.
hash
B
r
)
v
)
ballots
in
return
()
)
|>
...
...
@@ -193,7 +193,7 @@ let () = Eliom_registration.Html5.register
if
Uuidm
.
equal
uuid
ballot
.
election_uuid
&&
E
.
check_ballot
(
Serializable_compat
.
ballot
ballot
)
then
`Valid
(
Common
.
hash
_ballot
ballot
)
then
`Valid
(
Common
.
hash
B
raw_
ballot
)
else
`Invalid
with
e
->
`Malformed
in
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment