Envelope Format
The PIGI envelope format version 0, its six fields with sizes and offsets, and the struct definition that reads them.
Current SDK format generation. This page documents the envelope format the mintBlue SDK writes today. The open SDX Protocol specifies a later generation of this format; the two are not wire-compatible. Read the open specification
Generations sets out which of the two documents applies to the code you installed.
Version 0
| Field | Size | Offset | Description |
|---|---|---|---|
| Version | 1 | 0 | Version of the pigi file format. This defines the rest of the fields |
| Algorithm | 1 | 1 | A single-byte to signal which algorithms are used |
| File ID | 32 | 2 | The SHA256 of the original file |
| Length | 4 | 34 | The length of the Payload field (uint32 big endian) |
| IV | 16 | 38 | The Initialization Vector |
| Payload | Value(Length) | 54 | The encrypted and compressed payload |
The Pigi file format version 0 can be defined using the restructure Node.js library as follows:
import r from 'restructure';
export const PigiStruct = new r.VersionedStruct(r.uint8, {
0: {
algorithm: new r.Enum(r.uint8, Algorithms),
originalFileHash: new r.Buffer(32),
encryptedSize: r.uint32be,
iv: new r.Buffer(16),
encryptedData: new r.Buffer('encryptedSize'),
},
});The single byte in the Algorithm field selects the cipher, compression and
encoding the payload was built with. Algorithms
lists the identifiers that byte can carry.