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 aMemloc
that has been generated before (from eithermemloc.Make
ormemloc.MakeFromBytes
), even if those invocations were performed on different clients and / or by different users.- Returns:
A memory location
- Return type:
- memloc.MakeFromBytes(b: bytes) Memloc
Makes a
Memloc
fromb
, whereb
is 16 bytes in length. (It does this by copying the byte values fromb
into the bytes of theMemloc
.) Raises an error ifb
is not 16 bytes in length.Be aware that the adversary sees all
Memloc
s stored on the Dataserver, so confidentiality is lost on any inputb
tomemloc.MakeFromBytes
.- Parameters:
b (bytes) – The byte string to copy from
- Returns:
A memory location
- Return type:
- Raises:
ValueError – if
b
is not 16 bytes in length