• Stars
    star
    258
  • Rank 158,189 (Top 4 %)
  • Language ANTLR
  • License
    Other
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The secure data format for a modern world

CE Logo

Concise Encoding

The secure data format for a modern world


πŸ’‘ Solving today's problems

Times are different from the carefree days that brought us XML and JSON:

πŸ”’ Security (protect your data and infrastructure)

    State actors, criminal organizations and mercenaries are now actively hacking governments, companies and individuals to steal secrets, plant malware, and hold your data hostage.

    The existing ad-hoc data formats are too loosely defined to be secure, and can't be fixed because they're not versioned.

    Concise Encoding is designed for security, and is versioned so that it can be updated to handle new threats.

πŸ”‹ Efficiency (but not at the cost of convenience)

    We send so much data now that efficiency is critical, but switching to binary means giving up the ease of text formats.

    ... or does it?

    Concise Encoding gives you ease and efficiency with its 1:1 compatible text and binary formats.

🧬 Types (because stringifying everything is wasteful)

    Lack of types forces everyone to add extra encoding steps to send their data, which is buggy, reduces compatibility, and opens even more security holes.

    We live in the 21st century - base64 should be a footnote in history by now!

    Concise Encoding supports all of the common types natively. No more encoding things into strings.


πŸ“Š Compared to other formats

Features

Type CE XML JSON BSON CBOR Protobufs Thrift ASN.1 Ion
Int Max Size (bits) ∞ ❌ 53 64 64 64 64 64 ∞
Float Max Size (bits) ∞ ❌ 64 128 64 64 64 64 ∞
Subsecond Precision ns ❌ ❌ ns ns ns ❌ ns ns
Ad-hoc βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ ❌ ❌ ❌ βœ”οΈ
Little Endian βœ”οΈ ❌ ❌ βœ”οΈ ❌ βœ”οΈ ❌ ❌ ❌
Non-string map keys βœ”οΈ ❌ ❌ βœ”οΈ βœ”οΈ βœ”οΈ ❌ ❌ ❌
Size Optimization βœ”οΈ ❌ ❌ ❌ βœ”οΈ ❌ ❌ βœ”οΈ ❌
Cyclic Data βœ”οΈ ❌ ❌ ❌ βœ”οΈ ❌ ❌ ❌ ❌
Time Zones βœ”οΈ ❌ ❌ ❌ βœ”οΈ ❌ ❌ ❌ ❌
Records βœ”οΈ ❌ ❌ ❌ ❌ βœ”οΈ ❌ ❌ ❌
Bin + Txt βœ”οΈ ❌ ❌ ❌ ❌ ❌ ❌ βœ”οΈ βœ”οΈ
Versioned βœ”οΈ βœ”οΈ ❌ ❌ ❌ ❌ ❌ ❌ ⚠️
  • Ad-hoc: Supports ad-hoc data (does not require a schema).
  • Little Endian: Uses little-endian (modern CPUs use little endian, making little endian formats more efficient).
  • Size Optimization: The most common types and values use less space.
  • Cyclic Data: Supports cyclic (recursive) data structures.
  • Time Zones: Time types support real time zones.
  • Records: Records separate definition and instance for frequently occurring structures.
  • Bin + Txt: Has twin binary and text formats that are 1:1 convertible to each other without data loss.
  • Versioned: Documents are versioned to the specification they adhere to. (Ion supports versioning in the binary format only).

Type Support

Type CE XML JSON BSON CBOR Protobufs Thrift ASN.1 Ion
Boolean βœ”οΈ ❌ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Integer βœ”οΈ ❌ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Binary Float βœ”οΈ ❌ ❌ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Bfloat βœ”οΈ ❌ ❌ ❌ ❌ ❌ ❌ ❌ ❌
Decimal Float βœ”οΈ ❌ ❌ βœ”οΈ βœ”οΈ ❌ ❌ ❌ βœ”οΈ
NaN, Infinity βœ”οΈ ❌ ❌ ❌ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Universal ID βœ”οΈ ❌ ❌ βœ”οΈ βœ”οΈ ❌ ❌ βœ”οΈ ❌
Timestamp βœ”οΈ ❌ ❌ βœ”οΈ βœ”οΈ βœ”οΈ ❌ βœ”οΈ βœ”οΈ
Resource ID βœ”οΈ βœ”οΈ ❌ ❌ ❌ ❌ ❌ ❌ ❌
String βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Bytes βœ”οΈ ❌ ❌ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
List βœ”οΈ ❌ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Map βœ”οΈ ❌ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ ❌ ❌
Edge βœ”οΈ ❌ ❌ ❌ ❌ ❌ ❌ ❌ ❌
Node βœ”οΈ ❌ ❌ ❌ ❌ ❌ ❌ ❌ ❌
Record βœ”οΈ ❌ ❌ ❌ ❌ ❌ ❌ ❌ ❌
Typed Arrays βœ”οΈ ❌ ❌ ❌ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ ❌
Reference βœ”οΈ ❌ ❌ ❌ βœ”οΈ ❌ ❌ ❌ ❌
Remote Ref βœ”οΈ ❌ ❌ ❌ ❌ ❌ ❌ ❌ ❌
Comment βœ”οΈ βœ”οΈ ❌ ❌ ❌ ❌ ❌ ❌ ❌
Null βœ”οΈ ❌ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ ❌ βœ”οΈ βœ”οΈ
Media βœ”οΈ ❌ ❌ ❌ ❌ ❌ ❌ ❌ ❌
Custom βœ”οΈ ❌ ❌ ❌ ❌ ❌ ❌ βœ”οΈ βœ”οΈ

πŸ“š Specifications and Code

Specifications

Note: Most applications will only need the binary format. The text format is only required in places where a human must get involved, and this can often be handled by a simple command-line tool.

Design

Grammar

Implementations

Tools


⚠️ Draft Specification

Although Concise Encoding is nearing a release, it's currently a draft specification and thus subject to change. Please use a version of 0 for now to avoid compatibility issues with existing documents when version 1 is released.

Note: When version 1 is released, 0 will no longer be a valid version number.


πŸ“Œ Examples

All examples are valid Concise Text Encoding documents that can be transparently 1:1 converted to/from Concise Binary Encoding.

Numeric Types

c1
{
    "boolean"       = true
    "binary int"    = -0b10001011
    "octal int"     = 0o644
    "decimal int"   = -10000000
    "hex int"       = 0xfffe0001
    "very long int" = 100000000000000000000000000000000000009
    "decimal float" = -14.125
    "hex float"     = 0x5.1ec4p+20
    "very long flt" = 4.957234990634579394723460546348e+100000
    "not-a-number"  = nan
    "infinity"      = inf
    "neg infinity"  = -inf
}

String and String-Like

c1
{
    "string" = "Strings support escape sequences: \n \t \[1f415]"
    "url"    = @"https://example.com/"
    "email"  = @"mailto:[email protected]"
}

Other Basic Types

c1
{
    "uuid"      = f1ce4567-e89b-12d3-a456-426655440000
    "date"      = 2019-07-01
    "time"      = 18:04:00.948/Europe/Prague
    "timestamp" = 2010-07-15/13:28:15.415942344
    "null"      = null
    "media"     = @application/x-sh[23 21 2f 62 69 6e 2f 73 68 0a 0a
                   65 63 68 6f 20 68 65 6c 6c 6f 20 77 6f 72 6c 64 0a]
}

Containers

c1
{
    "list"          = [1 2.5 "a string"]
    "map"           = {"one"=1 2="two" "today"=2020-09-10}
    "bytes"         = @u8x[01 ff de ad be ef]
    "int16 array"   = @i16[7374 17466 -9957]
    "uint16 hex"    = @u16x[91fe 443a 9c15]
    "float32 array" = @f32[1.5e10 -8.31e-12]
}

Records

c1
@vehicle<"make" "model" "drive" "sunroof"> // type
[
    @vehicle{"Ford"   "Explorer" "4wd" true } // instance
    @vehicle{"Toyota" "Corolla"  "fwd" false} // instance
]

Which is equivalent to:

c1
[
    {
        "make" = "Ford"
        "model" = "Explorer"
        "drive" = "4wd"
        "sunroof" = true
    }
    {
        "make" = "Toyota"
        "model" = "Corolla"
        "drive" = "fwd"
        "sunroof" = false
    }
]

Trees

c1
/* The tree:
 *
 *       2
 *      / \
 *     5   7
 *    /   /|\
 *   9   6 1 2
 *  /   / \
 * 4   8   5
 *
 */
(2
    (7
        2
        1
        (6
            5
            8
        )
    )
    (5
        (9
            4
        )
    )
)

Notice how when rotated 90Β°, it resembles the tree it represents:

Rotated

Graphs

c1
/* The weighted graph:
 *
 *     b
 *    /|\
 *   4 1 1
 *  /  |  \
 * a-3-c-4-d
 *
 */
{
    "vertices" = [
        &a:{}
        &b:{}
        &c:{}
        &d:{}
    ]
    "edges" = [
        @($a {"weight"=4 "direction"="both"} $b)
        @($a {"weight"=3 "direction"="both"} $c)
        @($b {"weight"=1 "direction"="both"} $c)
        @($b {"weight"=1 "direction"="both"} $d)
        @($c {"weight"=4 "direction"="both"} $d)
    ]
}

References

c1
{
    // Entire map will be referenced later as $id1
    "marked object" = &id1:{
        "recursive" = $id1
    }
    "ref1" = $id1
    "ref2" = $id1

    // Reference pointing to part of another document.
    "outside ref" = $"https://xyz.com/document.cte#some_id"
}

Custom Types

c1
{
    // Custom types are user-defined, with user-supplied codecs.
    // In this example, we assume that custom type 12 is registered
    // via a schema to a custom "complex number" type.
    "custom text"   = @12"2.94+3i"
    "custom binary" = @12[04 f6 28 3c 40 00 00 40 40]
}

License

Copyright (c) 2018-2023 Karl Stenerud. All rights reserved.

Distributed under the Creative Commons Attribution License (license deed.

More Repositories

1

KSCrash

The Ultimate iOS Crash Reporter
Objective-C
4,241
star
2

iOS-Universal-Framework

An XCode project template to build universal frameworks (arm7, arm7s, and simulator) for iOS / iPhone.
Python
2,944
star
3

ObjectAL-for-iPhone

Mac and iOS Audio development, minus the headache. ObjectAL is the easy Objective-C interface to OpenAL, AVAudioPlayer, and audio session management.
Objective-C
885
star
4

Musashi

Motorola 680x0 emulator written in C
C
428
star
5

bo

The Swiss army knife of data examination and manipulation
C
332
star
6

KSReachability

A better iOS & Mac reachability for a modern age.
Objective-C
258
star
7

nixos-beginners-handbook

The missing handbook for NixOS beginners
84
star
8

Crash-Manager

An iOS library for recording crash events.
Objective-C
71
star
9

meson-examples

Example C/C++ projects using Meson
Meson
64
star
10

dogma

Dogma: A modernized metalanguage with better expressiveness and binary grammar support
63
star
11

KSJSON

The fastest JSON parser and serializer for Objective-C.
Objective-C
63
star
12

virtual-builders

Builds various virtual environments
Shell
60
star
13

openwrt-relayd-wireless-bridge

Instructions for setting up a wireless bridge in OpenWRT using relayd
50
star
14

Objective-Gems

Useful little gems to use when programming in Objective C
Objective-C
47
star
15

docker-desktops

Desktops inside of Docker images
Shell
42
star
16

Aural

iOS (and later OSX) audio library based on Audio Units (work-in-progress)
C
37
star
17

safe-encoding

Binary-to-text encoding that is safe to pass through modern text processors
C
32
star
18

go-concise-encoding

Golang implementation of Concise Binary and Text Encoding
Go
30
star
19

smalltime

A simple and convenient binary date & time format in 64 bits.
C
26
star
20

bit-tricks

Various tricks for dealing with bits
C
22
star
21

modern-cmake-templates

Templates to get a CMake project started quickly
CMake
20
star
22

DOS-Serial-Library

A serial port / UART library for DOS
C
19
star
23

KSVarArgs

Taking the pain out of variable argument lists in Objective-C.
Objective-C
19
star
24

SynthesizeSingleton

Note: The latest version is at http://github.com/cjhanson/Objective-C-Optimized-Singleton
C
18
star
25

ubuntu-dev-installer

Scripts to install an ubuntu dev environment
Shell
15
star
26

compact-time

Encoding schemes to store a complete time, date, or timestamp in as few bytes as possible for data transmission.
14
star
27

ARCSafe-MemManagement

Makes your code both ARC and non-ARC compatible
Objective-C
13
star
28

go-subvert

Subvert go's runtime system
Go
13
star
29

depixelate

Implementation of various scaling/depixelating techbologies
C
12
star
30

specifications

Specifications for better computing
9
star
31

KSLogging

Basic, lightweight preprocessor-controlled logging for C and Objective-C.
C
9
star
32

ubuntu-server-zfs

Install Ubuntu server with ZFS root
Shell
9
star
33

Universal-Framework-Examples

Examples for more complex usage of universal iOS frameworks
Objective-C
9
star
34

proxmox-containers

Shell
9
star
35

CocosEnhanced

Some useful classes for cocos2d
Objective-C
8
star
36

JSONCompare

A program to compare the speeds of various Objective-C JSON libraries.
Objective-C
8
star
37

vlq

An encoding scheme to compress unsigned integers
C
7
star
38

mac-kvm

Scripts to launch mac os under kvm
Shell
6
star
39

streamux

A minimalist, asynchronous, multiplexing, request-response protocol.
C
5
star
40

go-describe

Rich object descriptions in go
Go
4
star
41

go-gotchas

Common gotchas with golang and how to work around them
4
star
42

lxc-desktop

Script to create complete desktop environments inside LXC containers
Shell
4
star
43

KSRetainTracker

A tool for debugging retain/release issues in Objective-C
Objective-C
4
star
44

enctool

A tool for manipulating data in various encoding formats.
Go
3
star
45

hyver

Hybrid Versioning: Versioning with better U/X
3
star
46

darip

Bulk downloads images from Deviant Art using Mechanicalsoup's simulated browser
Python
3
star
47

Throwaway-IntroMusic

A throwaway repo for demonstrating intro music in ObjectAL
Objective-C
3
star
48

c-smalltime

C implementation of smalltime and nanotime
C
3
star
49

showcase

Showcase of my best work
3
star
50

go-uleb128

Go implementation of unsigned little endian base-128
Go
2
star
51

work-installer

Installer for my work environment
Shell
2
star
52

KSLog

A simple, header-only, async-safe logger for C and C++
C
2
star
53

ubuntu-maintainers-handbook

Ubuntu Maintainer's Handbook
2
star
54

bonjson

A binary serialization format for JSON
2
star
55

go-smalltime

Go implementation of Smalltime and Nanotime
Go
2
star
56

marwaita

Marwaita Theme (Modified)
CSS
2
star
57

compact-float

An encoding scheme to store a floating point value in as few bytes as possible.
2
star
58

open-in-lxc

Start an LXC container wrapping a directory in the host
Shell
2
star
59

fix-crd

Fixes chrome remote desktop
Shell
1
star
60

go-cte

Go implementation of Concise Text Encoding
Go
1
star
61

go-loggedio

Logged I/O for Go
Go
1
star
62

ubuntu-package-fixing

Instructions for fixing an Ubuntu package
1
star
63

navigation

Idiomic navigation through DOM graphs
Java
1
star
64

xor

XORs each octet of the input file with 0xff
C
1
star
65

c-compact-time

C implementation of compact time
C
1
star
66

ubuntu-env-installer

Installer scripts to set up my dev and desktop environments.
Shell
1
star
67

bin

my bin dir
Shell
1
star
68

docker-commafeed

Dockerfile for the Commafeed RSS reader
1
star
69

unicode_range_finder

A quick utility to find and print ranges of unicode codepoints for BNF
Go
1
star
70

lxc-services

Various services running under LXC
Shell
1
star
71

go-equivalence

A go library for comparing objects
Go
1
star
72

c-compact-float

C implementation of compact float
C
1
star
73

endianness

Endianness macros and functions for C and C++
C
1
star
74

kstenerud

Go
1
star
75

varpad

Unlimited padding with an embedded length field
1
star
76

linux-fixes

Fixes for various Linux issues
1
star
77

bash-installer-common

Functions to help install things on an Ubuntu system.
Shell
1
star
78

ksbonjson

A BONJSON codec implemented in C
C
1
star
79

go-compact-time

golang implementation of compact time
Go
1
star
80

KSDelegateForwarding

Multiplex delegates for any object implementing the delegate pattern.
Objective-C
1
star