How to use the pvtsutils.Convert.FromBinary function in pvtsutils

To help you get started, we’ve selected a few pvtsutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PeculiarVentures / 2key-ratchet / src / crypto / public_key.ts View on Github external
throw new Error("Error: Unsupported asymmetric key algorithm.");
        }
        if (publicKey.type !== "public") {
            throw new Error("Error: Expected key type to be public but it was not.");
        }
        res.key = publicKey;

        // Serialize public key to JWK
        const jwk = await getEngine().crypto.subtle.exportKey("jwk", publicKey);
        if (!(jwk.x && jwk.y)) {
            throw new Error("Wrong JWK data for EC public key. Parameters x and y are required.");
        }
        const x = Convert.FromBase64Url(jwk.x);
        const y = Convert.FromBase64Url(jwk.y);
        const xy = Convert.ToBinary(x) + Convert.ToBinary(y);
        res.serialized = Convert.FromBinary(xy);
        res.id = await res.thumbprint();

        return res;
    }
github PeculiarVentures / 2key-ratchet / src / const.ts View on Github external
* Based on https://whispersystems.org/docs/specifications/doubleratchet/ and
 * https://whispersystems.org/docs/specifications/x3dh/ by Open Whisper Systems
 *
 */

import { Convert } from "pvtsutils";
export const SIGN_ALGORITHM_NAME = "ECDSA";
export const DH_ALGORITHM_NAME = "ECDH";
export const SECRET_KEY_NAME = "AES-CBC";
export const HASH_NAME = "SHA-256";
export const HMAC_NAME = "HMAC";

export const MAX_RATCHET_STACK_SIZE = 20;

export const INFO_TEXT = Convert.FromBinary("InfoText");
export const INFO_RATCHET = Convert.FromBinary("InfoRatchet");
export const INFO_MESSAGE_KEYS = Convert.FromBinary("InfoMessageKeys");
github PeculiarVentures / 2key-ratchet / src / const.ts View on Github external
* https://whispersystems.org/docs/specifications/x3dh/ by Open Whisper Systems
 *
 */

import { Convert } from "pvtsutils";
export const SIGN_ALGORITHM_NAME = "ECDSA";
export const DH_ALGORITHM_NAME = "ECDH";
export const SECRET_KEY_NAME = "AES-CBC";
export const HASH_NAME = "SHA-256";
export const HMAC_NAME = "HMAC";

export const MAX_RATCHET_STACK_SIZE = 20;

export const INFO_TEXT = Convert.FromBinary("InfoText");
export const INFO_RATCHET = Convert.FromBinary("InfoRatchet");
export const INFO_MESSAGE_KEYS = Convert.FromBinary("InfoMessageKeys");
github PeculiarVentures / 2key-ratchet / src / const.ts View on Github external
* Copyright (c) 2016 Peculiar Ventures, Inc
 * Based on https://whispersystems.org/docs/specifications/doubleratchet/ and
 * https://whispersystems.org/docs/specifications/x3dh/ by Open Whisper Systems
 *
 */

import { Convert } from "pvtsutils";
export const SIGN_ALGORITHM_NAME = "ECDSA";
export const DH_ALGORITHM_NAME = "ECDH";
export const SECRET_KEY_NAME = "AES-CBC";
export const HASH_NAME = "SHA-256";
export const HMAC_NAME = "HMAC";

export const MAX_RATCHET_STACK_SIZE = 20;

export const INFO_TEXT = Convert.FromBinary("InfoText");
export const INFO_RATCHET = Convert.FromBinary("InfoRatchet");
export const INFO_MESSAGE_KEYS = Convert.FromBinary("InfoMessageKeys");