{
  "name": "e2e",
  "description": "End-to-end Freedom manifest",
  "app": {
    "script": [
      "end-to-end.compiled.js",
      "googstorage.js",
      "hex2words.js",
      "e2e.js"
    ]
  },
  "constraints": {
    "isolation": "never"
  },
  "provides" : [
    "crypto"
  ],
  "default": "crypto",
  "api": {
    "crypto": {
      "_comment": "Simplified crypto interface",

      "ERRCODE": { "type": "constant", "value": {
        "KEYS_NOT_LOADED":    "No keys in memory - initialize first",
        "MALFORMED":          "Malformed armored message",
        "INVALID_PASSPHRASE": "Wrong passphrase",
        "KEY_NOT_GENERATED":  "Trying to generate key, but it already exists",
        "KEY_DOES_NOT_EXIST": "Trying to load a key that's not there",
        "BAD_SIGNATURE":      "Invalid signature on call to verify"
      }},

      "setup": {
        "_comment": "Creates a new keypair or loads one if it already exists",
        "type": "method",
        "value": ["string", "string"],
        "ret": [],
        "err": { "errcode": "string", "message": "string" }
      },

      "clear": {
        "_comment": "Clear local storage, resetting private key",
        "type": "method",
        "value": [],
        "ret": [],
        "err": { "errcode": "string", "message": "string" }
      },

      "importKeypair": {
        "_comment": "Import a public/private keypair, overwriting if needed",
        "type": "method",
        "value": ["string", "string", "string"],
        "ret": [],
        "err": { "errcode": "string", "message": "string" }
      },

      "exportKey": {
        "_comment": "Export your public key and fingerprint to share/check",
        "type": "method",
        "value": ["boolean"],
        "ret": { "key": "string", "fingerprint": "string",
                 "words": ["array", "string"] },
        "err": { "errcode": "string", "message": "string" }
      },

      "getFingerprint": {
        "_comment": "Calculate and return 20-byte public key fingerprint",
        "type": "method",
        "value": ["string"],
        "ret": { "fingerprint": "string", "words": ["array", "string"] },
        "err": { "errcode": "string", "message": "string" }
      },

      "signEncrypt": {
        "_comment": "Sign w/private key, optionally encrypt with other key",
        "type": "method",
        "value": ["buffer", "string", "boolean"],
        "ret": "buffer",
        "err": { "errcode": "string", "message": "string" }
      },

      "verifyDecrypt": {
        "_comment": "Decrypt w/private key, optionally verify with other key",
        "type": "method",
        "value": ["buffer", "string"],
        "ret": { "data": "buffer", "signedBy": ["array", "string"] },
        "err": { "errcode": "string", "message": "string" }
      },

      "armor": {
        "_comment": "ASCII armor data, and include given header",
        "type": "method",
        "value": ["buffer", "string"],
        "ret": "string",
        "err": { "errcode": "string", "message": "string" }
      },

      "dearmor": {
        "_comment": "De-armor given data, checking for given header",
        "type": "method",
        "value": ["string"],
        "ret": "buffer",
        "err": { "errcode": "string", "message": "string" }
      },

      "ecdhBob": {
        "_comment": "Full elliptical curve implementation in a single function",
        "type": "method",
        "value": ["string", "string"],
        "ret": "buffer",
        "err": { "errcode": "string", "message": "string" }
      }
    }
  },

  "permissions": [
    "core.crypto",
    "core.storage"
  ]
}
