3.1. Memloc API

The Dataserver uses memory locations (Memloc) as the lookup key for arbitrary data. This API provides several functions that allow you to generate these memory locations.

Warning

The Dataserver does not allow you to index into a subset of data stored at a particular Memloc—if you want to access data stored within a given Memloc on the Dataserver, you will have to download all of the data stored at the Memloc. You should carefully consider this in light of the efficiency requirements for User.append_file (and, for CS162 students, User.upload_file).

3.1.1. Types

class Memloc

A 16-byte representation of a memory location on the Dataserver.

3.1.2. Functions

memloc.Make() Memloc

Randomly generates a universally unique memory location.

“Universally unique” means that, with overwhelming probability, no invocation of memloc.Make will produce a Memloc that has been generated before (from either memloc.Make or memloc.MakeFromBytes), even if those invocations were performed on different clients and / or by different users.

Returns:

A memory location

Return type:

Memloc

memloc.MakeFromBytes(b: bytes) Memloc

Makes a Memloc from b, where b is 16 bytes in length. (It does this by copying the byte values from b into the bytes of the Memloc.) Raises an error if b is not 16 bytes in length.

Be aware that the adversary sees all Memlocs stored on the Dataserver, so confidentiality is lost on any input b to memloc.MakeFromBytes.

Parameters:

b (bytes) – The byte string to copy from

Returns:

A memory location

Return type:

Memloc

Raises:

ValueError – if b is not 16 bytes in length