Reading Encrypted Arrays

To read from an encrypted array, you simply need to open it for reading using the encryption key you used to create it.

C
C++
Python
R
Java
Go
C
// ... create context ctx
// Open encrypted array for reading
const char key[] = "0123456789abcdeF0123456789abcdeF";
tiledb_array_t* array;
tiledb_array_alloc(ctx, "<array-uri>", &array);
tiledb_array_open_with_key(
ctx, array, TILEDB_READ, TILEDB_AES_256_GCM, key, sizeof(key));
// Or, open at timestamp
unsigned long long timestamp = 1561492235844; // In ms
tiledb_array_open_at_with_key(
ctx, array, TILEDB_READ, TILEDB_AES_256_GCM, key, sizeof(key), timestamp);
C++
// ... create context ctx
// Open encrypted array for reading
const char key[] = "0123456789abcdeF0123456789abcdeF";
Array array(ctx, "<array-uri>", TILEDB_READ, TILEDB_AES_256_GCM, key, sizeof(key));
// Or, open at timestamp
uint64_t timestamp = 1561492235844; // In ms
Array array(ctx, "<array-uri>", TILEDB_READ, TILEDB_AES_256_GCM, key, sizeof(key), timestamp);
Python
# All array and schema opening APIs support `key` as an
# optional keyword argument to open encrypted arrays:
key = "0123456789abcdeF0123456789abcdeF"
tiledb.DenseArray(uri, key=key)
tiledb.SparseArray(uri, key=key)
tiledb.open(uri, key=key)
tiledb.ArraySchema.load(uri, key=key)
R
ctx <- tiledb_ctx()
arrptr <-
tiledb:::libtiledb_array_open_with_key(ctx@ptr, uridensewkey,
"READ", encryption_key)
## subarray of rows 1,2 and cols 2,3,4
subarr <- c(1L,2L, 2L,4L)
qryptr <- tiledb:::libtiledb_query(ctx@ptr, arrptr, "READ")
qryptr <- tiledb:::libtiledb_query_set_subarray(qryptr, subarr)
qryptr <- tiledb:::libtiledb_query_set_layout(qryptr,
"ROW_MAJOR")
v <- integer(6) # reserve space
qryptr <- tiledb:::libtiledb_query_set_buffer(qryptr, "a", v)
qryptr <- tiledb:::libtiledb_query_submit(qryptr)
print(v) # unformed array, no coordinates
res <- tiledb:::libtiledb_array_close(arrptr)
## TODO open at timestamp example
Java
// ... create context ctx
// Open encrypted array for reading
String key = "0123456789abcdeF0123456789abcdeF";
Array array = new Array(ctx, "<array-uri>", TILEDB_READ, TILEDB_AES_256_GCM, key.getBytes(StandardCharsets.UTF_8));
// Or, open at timestamp
uint64_t timestamp = 1561492235844; // In ms
Array array = new Array(ctx, "<array-uri>", TILEDB_READ, TILEDB_AES_256_GCM, key.getBytes(StandardCharsets.UTF_8), timestamp);
Go
// ... create context ctx
// Open encrypted array for reading
var encryption_key = "0123456789abcdeF0123456789abcdeF"
array, _ := tiledb.NewArray(ctx, "<array-uri>")
array.OpenWithKey(tiledb.TILEDB_READ, tiledb.TILEDB_AES_256_GCM, encryption_key)
// Or, open at timestamp
var timestamp uint64 = 1561492235844 // In ms
array.OpenAtWithKey(tiledb.TILEDB_READ, tiledb.TILEDB_AES_256_GCM, encryption_key, timestamp)