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.Makewill produce aMemlocthat has been generated before (from eithermemloc.Makeormemloc.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
Memlocfromb, wherebis 16 bytes in length. (It does this by copying the byte values frombinto the bytes of theMemloc.) Raises an error ifbis not 16 bytes in length.Be aware that the adversary sees all
Memlocs stored on the Dataserver, so confidentiality is lost on any inputbtomemloc.MakeFromBytes.- Parameters:
b (bytes) – The byte string to copy from
- Returns:
A memory location
- Return type:
- Raises:
ValueError – if
bis not 16 bytes in length