mirror of https://github.com/nucypher/nucypher.git
Add NONCE_RANDOM_PREFIX_SIZE to constants
Add test for NONCE_RANDOM_PREFIX_SIZE constantpull/52/head
parent
d9f1bcb82b
commit
0004532871
|
@ -1 +1,5 @@
|
|||
# Number of random bytes to prefix before the counter
|
||||
NONCE_RANDOM_PREFIX_SIZE = 20
|
||||
|
||||
# Size of the counter in bytes (4 = int)
|
||||
NONCE_COUNTER_BYTE_SIZE = 4
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import msgpack
|
||||
import pathlib
|
||||
from nacl.utils import random
|
||||
from nkms.storage.constants import NONCE_RANDOM_PREFIX_SIZE
|
||||
|
||||
|
||||
class Header(object):
|
||||
|
@ -53,7 +54,7 @@ class Header(object):
|
|||
:rtype: Dict
|
||||
"""
|
||||
if not nonce:
|
||||
nonce = random(20)
|
||||
nonce = random(NONCE_RANDOM_PREFIX_SIZE)
|
||||
|
||||
return {
|
||||
'version': version,
|
||||
|
|
|
@ -5,3 +5,4 @@ from nkms.storage import constants
|
|||
class TestConstants(unittest.TestCase):
|
||||
def test_constants(self):
|
||||
self.assertEqual(4, constants.NONCE_COUNTER_BYTE_SIZE)
|
||||
self.assertEqual(20, constants.NONCE_RANDOM_PREFIX_SIZE)
|
||||
|
|
Loading…
Reference in New Issue