Skip to content

Latest commit

 

History

History
143 lines (98 loc) · 4.2 KB

04.datatypes.md

File metadata and controls

143 lines (98 loc) · 4.2 KB

shambhala data types and storage


frontend web storage

  • field definitions for IndexedDB intefaced with localForage

    interface ItemLayout: {
        G_PUBLIC: string;
        C_UUID: string;
        C_PUBLIC: string;
        S_PUBLIC: string;
        SALT: string;
        ENC_CKP: string;
    }
    let
        key: string,  /* `key` is a `G_PUBLIC` */
        item: ItemLayout;

backend database - "key" table

  • structure (SQL table column definitions)

    name type options notes
    id bigserial PRIMARY KEY NOT NULL Usual SQL primary key.
    creation_time timestamptz NOT NULL DEFAULT now() Entry creation time.
    g_public varchar(56) NOT NULL Stellar account.
    c_uuid uuid NOT NULL UNIQUE Client-generated UUID.
    enc_skp text DEFAULT NULL Encrypted Server Keypair ([S_SECRET, PEPPER]).
    usage_count bigint NOT NULL DEFAULT 0 Times that extracted SKP was used to sign a transaction.
    last_usage timestamptz DEFAULT NULL Most recent timestamp of successful S_SECRET use.
    failure_count bigint NOT NULL DEFAULT 0 Times that extraction of S_SECRET has failed.
    last_failure timestamptz DEFAULT NULL Most recent timestamp of S_SECRET extraction failure.
    datum jsonb NOT NULL DEFAULT jsonb_build_object() Additional flags and options.
  • datum structure

    interface DatumLayout: {
        S_PUBLIC: string;
        decryptionAttemptsLeft: number;
        suspended: boolean;
        clientBackupPassphrase: string;
        /* ... future features ... */
    }
    
    let datum: DatumLayout;
  • indexes

    • btree on creation_time
    • btree on g_public
    • gin on datum
  • table definition (SQL)

    CREATE TABLE IF NOT EXISTS key_v1 (
        id            bigserial   PRIMARY KEY NOT NULL,
        creation_time timestamptz NOT NULL DEFAULT now(),
        g_public      varchar(56) NOT NULL,
        c_uuid        uuid        NOT NULL UNIQUE,
        enc_skp       text        DEFAULT NULL,
        usage_count   bigint      NOT NULL DEFAULT 0,
        last_usage    timestamptz DEFAULT NULL,
        failure_count bigint      NOT NULL DEFAULT 0,
        last_failure  timestamptz DEFAULT NULL,
        datum         jsonb       NOT NULL DEFAULT jsonb_build_object()
    ) WITH (
        OIDS=FALSE
    );
    
    ALTER        TABLE key_v1 OWNER TO "user";
    GRANT ALL ON TABLE key_v1 TO       "user";
    COMMENT   ON TABLE key_v1 IS       'Shambhala server-side key-structure.';
    
    CREATE INDEX key_v1_creation_time_idx ON key_v1 USING btree (creation_time);
    CREATE INDEX key_v1_g_public_idx      ON key_v1 USING btree (g_public);
    CREATE INDEX key_v1_data_gin_idx      ON key_v1 USING gin   (datum);

backend database - "whitelist" table

  • structure (SQL table column definitions)

    name type options notes
    id serial PRIMARY KEY NOT NULL Usual SQL primary key.
    domain text NOT NULL Domain allowed to talk to shambhala.
    creation_time timestamptz NOT NULL DEFAULT now() Entry creation time.
    validity_time timestamptz NOT NULL DEFAULT now() + interval '1 year' Entry validity time.
  • indexes

    • btree on domain
  • table definition (SQL)

    CREATE TABLE IF NOT EXISTS white_v1 (
        id            bigserial   PRIMARY KEY NOT NULL,
        domain        text        NOT NULL,
        creation_time timestamptz NOT NULL DEFAULT now(),
        validity_time timestamptz NOT NULL DEFAULT now() + interval '1 year'
    ) WITH (
        OIDS=FALSE
    );
    
    ALTER        TABLE white_v1 OWNER TO "user";
    GRANT ALL ON TABLE white_v1 TO       "user";
    COMMENT   ON TABLE white_v1 IS       'Shambhala whitelist.';
    
    CREATE INDEX white_v1_domain_idx ON white_v1 USING btree (domain);