Skip to content

Go SDK: int16 is widened to Int32, and there's no way to encrypt a date, timestamp, decimal or 128-bit integer #1144

Description

@coderdan

Background

The Go SDK (languages/golang) encrypts Go struct fields. stashgen
generates the code, and encrypt/gensupport converts Go values into
vitaminc value kinds.

Problem

  1. int8 and int16 are widened to Int32, and the unsigned widths to
    UInt32 (encrypt/gensupport/declaration.go:22-23). That fixes the wrong
    kind into every stored ciphertext and term.
  2. time.Time could mean a date or a timestamp, and there is no date type.
  3. There is no mapping for decimals or 128-bit integers.
  4. eql_gen.go refuses every numeric and date EQL type (stashgen refuses every number, date and boolean EQL type — produce them in EQL v4 using ADR-0002's encodings #1130).

The Go SDK hasn't been released, so changing the mapping now costs nothing.
After release it needs a data migration.

Proposal

  1. Map each integer width to its own kind. Add Int128 and Uint128 value
    types.
  2. time.Time maps to Timestamp, and encrypt.Date{Year, Month, Day} is a
    date. A field whose EQL target is a date family accepts time.Time,
    truncated to its UTC calendar day.
  3. Add a decimal mapping that refuses NaN and ±Infinity.
  4. Update record.Kind, the gensupport conversions and stashgen's type
    mapping. Regenerate eql_gen.go against v4. Change the eql_v3 strings to
    eql_v4 (about 245 lines).
  5. Run vitaminc's shared value-level vectors (aead-value: a cross-language conformance corpus for the FFI transport codec vitaminc#332).

Must land before the Go SDK ships (#1046). Needs #1140 and #1142. Decided in
ADR-0002 (#1139).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions