fixed plugins import onionrblocksapi unnecessary

master
Kevin Froman 2019-09-22 03:28:38 -05:00
parent 6d4b35c5e3
commit 0d4ab54ceb
7 changed files with 20 additions and 15 deletions

View File

@ -1,4 +1,4 @@
# Onionr Block Spec v1.1.0 # Onionr Block Spec v2.0.0
# Block Description # Block Description
@ -20,13 +20,13 @@ The metadata section has the following fields. If a block contains any other fie
## meta ## meta
Max byte size: 1000 Max byte size (when in escaped json string format): 1000
Meta is a string field which can contain arbitrary sub fields. It is intended for applications and plugins to use it for arbitrary metadata information. In the reference client, if the data section is encrypted or signed, the meta section also is. Meta is a string field which can contain arbitrary sub fields. It is intended for applications and plugins to use it for arbitrary metadata information. If the data section is encrypted or signed, the meta section also is.
Common meta fields, such as 'type' are used by the reference Onionr client to describe the type of a block. Common meta fields, such as 'type' are used by the reference Onionr client to describe the type of a block.
## sig ## sig (optional)
Max byte size: 200 Max byte size: 200
@ -34,30 +34,30 @@ Sig is a field for storing public key signatures of the block, typically ed25519
Note: the max field size is larger than a EdDSA signature (which is what is typically used) in order to allow other primitives for signing in alternative implementations or future versions. Note: the max field size is larger than a EdDSA signature (which is what is typically used) in order to allow other primitives for signing in alternative implementations or future versions.
## signer ## signer (optional, necessary if sig is present)
Max byte size: 200 Max byte size: 200
Signer is a field for specifying the public key which signed the block. In the reference client this is a base64 encoded ed25519 public key. Signer is a field for specifying the public key which signed the block. In the reference client this is a base64 encoded ed25519 public key.
## time ## time (mandatory)
Max byte size: 10 Max byte size: 10
Time is an integer field for specifying the time of which a block was created. The trustworthiness of this field is based on one's trust of the block creator, however blocks with a time field set in the future (past a reasonable clock skew) are thrown out by the reference client. Time is an integer field for specifying the time of which a block was created. The trustworthiness of this field is based on one's trust of the block creator, however blocks with a time field set in the future at the point of block receipt (past a reasonable clock skew) are thrown out by the reference client.
## expire ## expire (optional)
Max byte size: 10 Max byte size: 10
Expire is an integer field for specifying the time of which the block creator has indicated that the block should be deleted. The purpose of this is for voluntarily freeing the burden of unwanted blocks on the Onionr network, rather than security/privacy (since blocks could be trivially kept past expiration). Regardless, the reference client deletes blocks after a preset time if the expire field is either not set or longer than the preset time. Expire is an integer field for specifying the time of which the block creator has indicated that the block should be deleted. The purpose of this is for voluntarily freeing the burden of unwanted blocks on the Onionr network, rather than security/privacy (since blocks could be trivially kept past expiration). Regardless, the reference client deletes blocks after a preset time if the expire field is either not set or longer than the preset time.
## pow ## pow (effectively mandatory)
Max byte size: 1000 Max byte size: 1000
Pow is a field for placing the nonce found to make a block meet a target proof of work. In theory, a block could meet a target without a random token in this field. Pow is a field for placing the nonce found to make a block meet a target proof of work. In theory, a block could meet a target without a random token in this field.
## encryptType ## encryptType (optional)
encryptType is a field to specify the mode of encryption for a block. The values supported by Onionr are 'asym' and 'sym'. encryptType is a field to specify the mode of encryption for a block. The values supported by Onionr are 'asym' and 'sym'.

View File

@ -59,6 +59,7 @@ def process_block_metadata(blockHash: str):
try: try:
expireTime = int(myBlock.getHeader('expire')) expireTime = int(myBlock.getHeader('expire'))
# test that expire time is an integer of sane length (for epoch) # test that expire time is an integer of sane length (for epoch)
# doesn't matter if its too large because of the min() func below
if not len(str(expireTime)) < 20: raise ValueError('timestamp invalid') if not len(str(expireTime)) < 20: raise ValueError('timestamp invalid')
except (ValueError, TypeError) as e: except (ValueError, TypeError) as e:
expireTime = onionrvalues.DEFAULT_EXPIRE + curTime expireTime = onionrvalues.DEFAULT_EXPIRE + curTime

View File

@ -89,6 +89,13 @@ def validate_metadata(metadata, block_data) -> bool:
else: else:
# if metadata loop gets no errors, it does not break, therefore metadata is valid # if metadata loop gets no errors, it does not break, therefore metadata is valid
# make sure we do not have another block with the same data content (prevent data duplication and replay attacks) # make sure we do not have another block with the same data content (prevent data duplication and replay attacks)
# Make sure time is set (validity was checked above if it is)
try:
metadata['time']
except KeyError:
return False
nonce = bytesconverter.bytes_to_str(onionrcrypto.hashers.sha3_hash(block_data)) nonce = bytesconverter.bytes_to_str(onionrcrypto.hashers.sha3_hash(block_data))
try: try:
with open(filepaths.data_nonce_file, 'r') as nonceFile: with open(filepaths.data_nonce_file, 'r') as nonceFile:

View File

@ -20,7 +20,6 @@
# Imports some useful libraries # Imports some useful libraries
import logger, config, threading, time, datetime, sys, json import logger, config, threading, time, datetime, sys, json
from onionrblockapi import Block
from onionrutils import stringvalidators, bytesconverter from onionrutils import stringvalidators, bytesconverter
from onionrcrypto import encryption, keypair, signing, getourkeypair from onionrcrypto import encryption, keypair, signing, getourkeypair
import onionrexceptions, onionrusers import onionrexceptions, onionrusers

View File

@ -20,7 +20,7 @@
# Imports some useful libraries # Imports some useful libraries
import threading, time, locale, sys, os import threading, time, locale, sys, os
from onionrblockapi import Block from onionrblocks.onionrblockapi import Block
import logger, config, onionrblocks import logger, config, onionrblocks
from onionrutils import escapeansi, epoch, bytesconverter from onionrutils import escapeansi, epoch, bytesconverter
locale.setlocale(locale.LC_ALL, '') locale.setlocale(locale.LC_ALL, '')

View File

@ -21,7 +21,6 @@
# useful libraries # useful libraries
import logger, config import logger, config
import os, sys, json, time, random, shutil, base64, getpass, datetime, re import os, sys, json, time, random, shutil, base64, getpass, datetime, re
from onionrblockapi import Block
import onionrusers, onionrexceptions import onionrusers, onionrexceptions
from onionrutils import stringvalidators from onionrutils import stringvalidators

View File

@ -20,7 +20,6 @@
# Imports some useful libraries # Imports some useful libraries
import logger, config, threading, time, datetime import logger, config, threading, time, datetime
from onionrblockapi import Block
import onionrexceptions import onionrexceptions
from onionrusers import onionrusers, contactmanager from onionrusers import onionrusers, contactmanager
from utils import reconstructhash from utils import reconstructhash