def make_post(self, group_id, owner_id, data, post_key, proof_of_work_args): timestamp = ut.current_time() data_hash = ut.hash_function(data) request_string = ut.serialize_request( ['MAKE_POST', timestamp, self.node_name, group_id, owner_id, data_hash]) post_id = ut.hash_function(request_string) post_signature = None if post_key != None: post_signature = post_key.sign(post_id) proof_of_work = None if proof_of_work_args != None: proof_of_work = ut.make_proof_of_work(proof_of_work_args, post_id) resp = self.client_raw.make_post( timestamp, self.node_name, group_id, owner_id, data_hash, post_id, data, post_signature, proof_of_work)[0] gen = (post_id, timestamp, data_hash, post_signature, proof_of_work) return resp, gen
def create_group(self, group_id, owner_id, post_access, read_access, delete_access, posting_pub_key, reading_pub_key, delete_pub_key, quota_allocated, when_space_exhausted, max_post_size, auth_key): timestamp = ut.current_time() posting_key_type = None posting_pub_key_str = None reading_key_type = None reading_pub_key_str = None delete_key_type = None delete_pub_key_str = None if posting_pub_key != None: posting_key_type = posting_pub_key.key_type posting_pub_key_str = posting_pub_key.public_key if reading_pub_key != None: reading_key_type = reading_pub_key.key_type reading_pub_key_str = reading_pub_key.public_key if delete_pub_key != None: delete_key_type = delete_pub_key.key_type delete_pub_key_str = delete_pub_key.public_key request_string = ut.serialize_request( ['CREATE_GROUP', timestamp, self.node_name, group_id, owner_id, post_access, read_access, delete_access, posting_key_type, posting_pub_key_str, reading_key_type, reading_pub_key_str, delete_key_type, delete_pub_key_str, quota_allocated, when_space_exhausted, max_post_size]) signature = auth_key.sign(request_string) #ut.assert_access(read_access) #ut.assert_access(post_access) #ut.assert_access(delete_access) #ut.assert_public_key(posting_key_type, posting_pub_key) #ut.assert_public_key(reading_key_type, reading_pub_key) #ut.assert_public_key(delete_key_type, delete_pub_key) #ut.assert_exhaustion(when_space_exhausted) return self.client_raw.create_group( timestamp, self.node_name, group_id, owner_id, post_access, read_access, delete_access, posting_key_type, posting_pub_key_str, reading_key_type, reading_pub_key_str, delete_key_type, delete_pub_key_str, quota_allocated, when_space_exhausted, max_post_size, auth_key.public_key_hash, signature)[0]
def delete_user(self, user_id, auth_key): timestamp = ut.current_time() request_string = ut.serialize_request( ['DELETE_USER', timestamp, self.node_name, user_id]) signature = auth_key.sign(request_string) return self.client_raw.delete_user(timestamp, self.node_name, user_id, auth_key.public_key_hash, signature)[0]
def read_user_quota(self, user_id, auth_key): timestamp = ut.current_time() request_string = ut.serialize_request( ['READ_USER_QUOTA', timestamp, self.node_name, user_id]) signature = auth_key.sign(request_string) return self.client_raw.read_user_quota(timestamp, self.node_name, user_id, auth_key.public_key_hash, signature)[0]
def delete_message_access(self, user_id, from_user_key_hash, auth_key): timestamp = ut.current_time() request_string = ut.serialize_request( ['DELETE_MESSAGE_ACCESS', timestamp, self.node_name, user_id, from_user_key_hash]) signature = auth_key.sign(request_string) return self.client_raw.delete_message_access( timestamp, self.node_name, user_id, from_user_key_hash, auth_key.public_key_hash, signature)[0]
def read_last_message_time(self, user_id, auth_key): timestamp = ut.current_time() request_string = ut.serialize_request( ['READ_LAST_MESSAGE_TIME', timestamp, self.node_name, user_id]) signature = None if auth_key != None: signature = auth_key.sign(request_string) return self.client_raw.read_last_message_time(timestamp, self.node_name, user_id, auth_key.public_key_hash, signature)[0]
def read_max_post_size(self, group_id, owner_id, group_post_key): timestamp = ut.current_time() request_string = ut.serialize_request( ['READ_MAX_POST_SIZE', timestamp, self.node_name, group_id, owner_id]) post_signature = None if group_post_key != None: post_signature = group_post_key.sign(request_string) return self.client_raw.read_max_post_size( timestamp, self.node_name, group_id, owner_id, post_signature)[0]
def change_max_post_size(self, group_id, owner_id, new_size, auth_key): timestamp = ut.current_time() request_string = ut.serialize_request( ['CHANGE_MAX_POST_SIZE', timestamp, self.node_name, group_id, owner_id, new_size]) public_key_hash = auth_key.public_key_hash signature = auth_key.sign(request_string) return self.client_raw.change_max_post_size( timestamp, self.node_name, group_id, owner_id, new_size, public_key_hash, signature)[0]
def read_group(self, group_id, owner_id, auth_key): timestamp = ut.current_time() request_string = ut.serialize_request( ['READ_GROUP', timestamp, self.node_name, group_id, owner_id]) signature = auth_key.sign(request_string) return self.client_raw.read_group( timestamp, self.node_name, group_id, owner_id, auth_key.public_key_hash, signature)[0]
def change_message_quota(self, user_id, new_size, when_space_exhausted, auth_key): timestamp = ut.current_time() request_string = ut.serialize_request( ['CHANGE_MESSAGE_QUOTA', timestamp, self.node_name, user_id, new_size, when_space_exhausted]) signature = auth_key.sign(request_string) return self.client_raw.change_message_quota( timestamp, self.node_name, user_id, new_size, when_space_exhausted, auth_key.public_key_hash, signature)[0]
def change_user_quota(self, user_id, new_size, user_class, auth_token, auth_key): timestamp = ut.current_time() request_string = ut.serialize_request( ['CHANGE_USER_QUOTA', timestamp, self.node_name, user_id, new_size, user_class, auth_token]) signature = auth_key.sign(request_string) return self.client_raw.change_user_quota( timestamp, self.node_name, user_id, new_size, user_class, auth_token, auth_key.public_key_hash, signature)[0]
def change_group_access(self, group_id, owner_id, use, access, auth_key): timestamp = ut.current_time() request_string = ut.serialize_request( ['CHANGE_GROUP_ACCESS', timestamp, self.node_name, group_id, owner_id, use, access]) signature = auth_key.sign(request_string) return self.client_raw.change_group_access( timestamp, self.node_name, group_id, owner_id, use, access, auth_key.public_key_hash, signature)[0]
def read_group_quota(self, group_id, owner_id, group_read_key, proof_of_work_args): timestamp = ut.current_time() request_string = ut.serialize_request( ['READ_GROUP_QUOTA', timestamp, self.node_name, group_id, owner_id]) read_signature = None if group_read_key != None: read_signature = group_read_key.sign(request_string) proof_of_work = None if proof_of_work_args != None: proof_of_work = make_proof_of_work(proof_of_work_args, request_string) return self.client_raw.read_group_quota(timestamp, self.node_name, group_id, owner_id, read_signature, proof_of_work)[0]
def read_max_message_size(self, to_user, from_user, from_key): timestamp = ut.current_time() public_key_hash = None signature = None if from_key != None: request_string = ut.serialize_request( ['READ_MAX_MESSAGE_SIZE', timestamp, self.node_name, to_user, from_user, from_key.public_key_hash]) public_key_hash = from_key.public_key_hash signature = from_key.sign(request_string) return self.client_raw.read_max_message_size( timestamp, self.node_name, to_user, from_user, public_key_hash, signature)[0]
def read_group_access(self, group_id, owner_id, use, auth_key): timestamp = ut.current_time() request_string = ut.serialize_request( ['READ_GROUP_ACCESS', timestamp, self.node_name, group_id, owner_id, use]) signature = None if auth_key != None: signature = auth_key.sign(request_string) return self.client_raw.read_group_access( timestamp, self.node_name, group_id, owner_id, use, signature)[0]
def read_last_post_time(self, group_id, owner_id, group_read_key, proof_of_work_args): timestamp = ut.current_time() request_string = ut.serialize_request( ['READ_LAST_POST_TIME', timestamp, self.node_name, group_id, owner_id]) read_signature = None if group_read_key != None: read_signature = group_read_key.sign(request_string) proof_of_work = None if proof_of_work_args != None: proof_of_work = ut.make_proof_of_work(proof_of_work_args, request_string) return self.client_raw.read_last_post_time( timestamp, self.node_name, group_id, owner_id, read_signature, proof_of_work)[0]
def query_message_access(self, to_user, from_user, from_key): timestamp = ut.current_time() public_key_hash = None signature = None if from_key != None: request_string = ut.serialize_request( ['QUERY_MESSAGE_ACCESS', timestamp, self.node_name, to_user, from_user, from_key.public_key_hash]) public_key_hash = from_key.public_key_hash signature = from_key.sign(request_string) return self.client_raw.query_message_access( timestamp, self.node_name, to_user, from_user, public_key_hash, signature)[0]
def delete_post(self, group_id, owner_id, post_id, delete_key, proof_of_work_args): timestamp = ut.current_time() request_string = ut.serialize_request( ['DELETE_POST', timestamp, self.node_name, group_id, owner_id, post_id]) delete_signature = None if delete_key != None: delete_signature = delete_key.sign(request_string) proof_of_work = None if proof_of_work_args != None: proof_of_work = ut.make_proof_of_work(proof_of_work_args, request_string) return self.client_raw.delete_post( timestamp, self.node_name, group_id, owner_id, post_id, delete_signature, proof_of_work)[0]
def read_message_list(self, user_id, to_user_key, from_user, from_user_key, start_time, end_time, max_records, order, auth_key): timestamp = ut.current_time() request_string = ut.serialize_request( ['READ_MESSAGE_LIST', timestamp, self.node_name, user_id, to_user_key, from_user, from_user_key, start_time, end_time, max_records, order]) signature = auth_key.sign(request_string) return self.client_raw.read_message_list( timestamp, self.node_name, user_id, to_user_key, from_user, from_user_key, start_time, end_time, max_records, order, auth_key.public_key_hash, signature)[0]
def change_group_key(self, group_id, owner_id, key_use, pub_key, auth_key): timestamp = ut.current_time() key_type = None public_key = None if pub_key != None: key_type = pub_key.key_type public_key = pub_key.public_key request_string = ut.serialize_request( ['CHANGE_GROUP_KEY', timestamp, self.node_name, group_id, owner_id, key_use, key_type, public_key]) signature = auth_key.sign(request_string) return self.client_raw.change_group_key( timestamp, self.node_name, group_id, owner_id, key_use, key_type, public_key, auth_key.public_key_hash, signature)[0]
def send_message( self, to_user, to_user_key_hash, from_user, from_key, message, proof_of_work_args): timestamp = ut.current_time() message_hash = ut.hash_function(message) from_user_key_hash = None if from_key != None: from_user_key_hash = from_key.public_key_hash request_string = ut.serialize_request( ['SEND_MESSAGE', timestamp, self.node_name, to_user, to_user_key_hash, from_user, from_user_key_hash, message_hash]) message_id = ut.hash_function(request_string) from_signature = None if from_key != None: from_signature = from_key.sign(message_id) proof_of_work = None if proof_of_work_args != None: proof_of_work = ut.make_proof_of_work(proof_of_work_args, message_id) resp = self.client_raw.send_message( timestamp, self.node_name, to_user, to_user_key_hash, from_user, from_user_key_hash, message_hash, message_id, message, from_signature, proof_of_work)[0] return resp, (message_id, timestamp, message_hash, from_signature, proof_of_work)
def read_post_list(self, group_id, owner_id, start_time, end_time, max_records, order, group_read_key, proof_of_work_args): timestamp = ut.current_time() request_string = ut.serialize_request( ['READ_POST_LIST', timestamp, self.node_name, group_id, owner_id, start_time, end_time, max_records, order]) read_signature = None if group_read_key != None: read_signature = group_read_key.sign(request_string) proof_of_work = None if proof_of_work_args != None: proof_of_work = ut.make_proof_of_work(proof_of_work_args, request_string) return self.client_raw.read_post_list( timestamp, self.node_name, group_id, owner_id, start_time, end_time, max_records, order, read_signature, proof_of_work)[0]