Skip to content

Instantly share code, notes, and snippets.

View daviddahl's full-sized avatar
💭
burning the midnight oil

David Dahl daviddahl

💭
burning the midnight oil
View GitHub Profile
begin;
create table item (
item_id int8 not null primary key default nextval('version_identifier'),
account_id int8 not null references account,
name_hmac bytea not null unique,
creation_time timestamp not null default current_timestamp,
modified_time timestamp not null default current_timestamp,
deletion_time timestamp,
value bytea,
@daviddahl
daviddahl / scema.diff
Created November 11, 2015 19:11
Diff from HEAD to the current production database
diff --git a/928a5500234abb5db508ba07b1d2f6c385fe8d19:server/lib/stores/postgres/sql/setup.sql b/HEAD:server/lib/stores/postgres/sql/setup.sql
index ed69e77..1091725 100644
--- a/928a5500234abb5db508ba07b1d2f6c385fe8d19:server/lib/stores/postgres/sql/setup.sql
+++ b/HEAD:server/lib/stores/postgres/sql/setup.sql
@@ -620,4 +620,165 @@ create unique index transaction_delete_message_msg_id_idx
on transaction_delete_message
(transaction_id, message_id);
+
+create table item (
@daviddahl
daviddahl / Kloak QA Plan 1
Last active October 14, 2015 19:02
A plan for anyone testing Kloak to follow, Private Beta (Copy this Gist to begin)
Name:
Date/Time:
Kloak Version:
1. Install Kloak from Apple Test Flight
* Bugs, Problems:
---
// Difference between Container Encryption and Item Encryption
// (Short answer: Item Encryption & decryption is identical to container encryoption and decryoption, just 1 step & simpler with no diffs, etc)
// Containers Encryption:
// https://github.com/SpiderOak/crypton/blob/a7e6a76f0c099ef2762c27f85f474bfb1c62727b/client/src/session.js#L663-L699
var selfPeer = new crypton.Peer({
session: this,
pubKey: this.account.pubKey,
signKeyPub: this.account.signKeyPub
@daviddahl
daviddahl / items-api.js
Last active August 29, 2015 14:17
Crypton Items API
// We use session.getOrCreateItem in order to create a new item that we can share with others
app.session.getOrCreateItem('myReport', function (err, report) {
if (err) {
callback(err);
return console.error(err);
}
// update the report
report.value = { updated: Date.now(), reportContent: app.reportContent };
// share this data:
CREATE OR REPLACE FUNCTION notifyUpdatedItem() RETURNS TRIGGER AS $$
DECLARE
notify_row RECORD;
BEGIN
FOR notify_row IN
SELECT s.item_session_key_share_id,
s.account_id, s.to_account_id, k.item_id,
a.username as toUser, b.username AS fromUser
FROM item_session_key_share s
JOIN item_session_key k ON
CREATE OR REPLACE FUNCTION notifyUpdatediItem() RETURNS TRIGGER AS $$
DECLARE
rec RECORD;
BEGIN
FOR rec IN (SELECT getSharedItemNotifees(NEW.item_id)) LOOP
PERFORM pg_notify('SharedItemUpdated', CAST(rec.to_account_id AS text)|| ' ' || CAST(NEW.name_hmac AS text));
END LOOP;
END;
$$ LANGUAGE PLPGSQL;
createItem("my-dossier9", {name: 'foo', address: 123, city: 'chicago'});
window.session.items;
Object {my-dossier8: Item, my-dossier9: Item}
window.session.items['my-dossier8'].value
Object {name: "foo", address: 123, city: "chicago"}
var app = {};
app.createUser = function(user, password) {
crypton.generateAccount(user, password, function (err, account){
if (err) { console.error(err); return;}
console.log(account);
})
};
app.auth = function (username, password) {
(gdb) break gcry_kdf_derive
Breakpoint 3 at 0x7ffff7b65180
(gdb) r
Starting program: /home/ddahl/code/spideroak/daviddahl/crypton/client/native/src/./pbkdf
Breakpoint 3, 0x00007ffff7b65180 in gcry_kdf_derive () from /lib/x86_64-linux-gnu/libgcrypt.so.11
(gdb) s
Single stepping until exit from function gcry_kdf_derive,
which has no line number information.
generateKeyFromPassword (passphrase=0x401a5b "password", item=0x7fffffffe118) at pbkdf2.c:45