You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by gs...@apache.org on 2022/05/29 22:46:30 UTC
[steve] branch trunk updated (d362cf1 -> e8e2e01)
This is an automated email from the ASF dual-hosted git repository.
gstein pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git
from d362cf1 start drafting app-level work
new 6aeee54 add note that vid == _ROWID_
new 347a08b Slight tweaks to the crypo functions.
new e8e2e01 add helper to create new ElectionID values
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
v3/schema.sql | 3 ++-
v3/steve/crypto.py | 14 ++++++--------
v3/steve/election.py | 10 ++++++++++
3 files changed, 18 insertions(+), 9 deletions(-)
[steve] 01/03: add note that vid == _ROWID_
Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git
commit 6aeee5458d9ce41238e2459b8028dee1fbd71ad0
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Sun May 29 17:28:16 2022 -0500
add note that vid == _ROWID_
---
v3/schema.sql | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/v3/schema.sql b/v3/schema.sql
index b386424..2284871 100644
--- a/v3/schema.sql
+++ b/v3/schema.sql
@@ -110,7 +110,8 @@ CREATE TABLE VOTES (
/* The key is auto-incrementing to provide a record of insert-order,
so that we have an ordering to find the "most recent" when
- re-voting on an issue. */
+ re-voting on an issue.
+ Note: an integer primary key is an alias for _ROWID_. */
vid INTEGER PRIMARY KEY AUTOINCREMENT,
/* A hashed token representing a single Participant. 32 bytes. */
[steve] 03/03: add helper to create new ElectionID values
Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git
commit e8e2e019d1a715940cca86a660c50f67b1737b28
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Sun May 29 17:40:07 2022 -0500
add helper to create new ElectionID values
---
v3/steve/election.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/v3/steve/election.py b/v3/steve/election.py
index 3452295..30670f5 100644
--- a/v3/steve/election.py
+++ b/v3/steve/election.py
@@ -65,3 +65,13 @@ class Election:
for_table('issues', self.c_salt_issue)
for_table('record', self.c_salt_record)
+
+
+def new_eid():
+ "Create a new ElectionID."
+
+ # Use 4 bytes of a salt, for 32 bits.
+ b = crypto.gen_salt()[:4]
+
+ # Format into 8 hex characters.
+ return f'{b[0]:02x}{b[1]:02x}{b[2]:02x}{b[3]:02x}'
[steve] 02/03: Slight tweaks to the crypo functions.
Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git
commit 347a08bd0f70dff35217356f25f5a3d8d51222e4
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Sun May 29 17:30:51 2022 -0500
Slight tweaks to the crypo functions.
* return salt, then the value it was used for
* gen_token() is usually used to recreate a token, so it needs the
salt that was originally used -- meaning it comes from the app
* clarify a few todo comments
---
v3/steve/crypto.py | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/v3/steve/crypto.py b/v3/steve/crypto.py
index fb1271f..be7d560 100644
--- a/v3/steve/crypto.py
+++ b/v3/steve/crypto.py
@@ -36,23 +36,21 @@ def gen_salt() -> bytes:
### fix the types of the election metadata and issue data
-### fix return type
+### fix return type, to be a tuple
def gen_opened_key(election: bytes, issues: bytes) -> bytes:
"Generate the OpenedKey for this election."
salt = gen_salt()
### TBD: map ELECTION and ISSUES parameters to bytes
opened_key = _hash(election + issues, salt)
- return opened_key, salt
+ return salt, opened_key
-### fix return type
-def gen_token(opened_key: bytes, value: bytes) -> bytes:
+def gen_token(opened_key: bytes, value: bytes, salt: bytes) -> bytes:
"Generate a voter or issue token."
- salt = gen_salt()
- return _hash(opened_key + value, salt), salt
+ return _hash(opened_key + value, salt)
-### fix return type
+### fix return type, to be a tuple
def create_vote(voter_token: bytes,
issue_token: bytes,
votestring: bytes) -> bytes:
@@ -61,7 +59,7 @@ def create_vote(voter_token: bytes,
key = _hash(voter_token + issue_token, salt)
b64key = base64.urlsafe_b64encode(key)
f = cryptography.fernet.Fernet(b64key)
- return voter_token, issue_token, salt, f.encrypt(votestring)
+ return salt, f.encrypt(votestring)
def decrypt_votestring(voter_token: bytes,