tink-crypto
Version:
A multi-language, cross-platform library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse.
41 lines (40 loc) • 1.81 kB
TypeScript
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as EllipticCurves from '../subtle/elliptic_curves';
import { PbEllipticCurveType, PbHashType, PbKeyset, PbKeysetKey, PbPointFormat } from './proto';
/**
* A type representing the constructor function for a given class. Unlike
* TypeScript's built-in `new` types, this works with abstract classes. It is
* used to describe the relationship between a primitive type object and its
* instances.
*/
export declare type Constructor<T> = Function & {
prototype: T;
};
/** Like the `instanceof` operator, but works with `Constructor`. */
export declare function isInstanceOf<T>(value: unknown, ctor: Constructor<T>): value is T;
/**
* Validates the given key and throws SecurityException if it is invalid.
*
*/
export declare function validateKey(key: PbKeysetKey): void;
/**
* Validates the given keyset and throws SecurityException if it is invalid.
*
*/
export declare function validateKeyset(keyset: PbKeyset): void;
/**
* Either prolong or shrinks the array representing number in BigEndian encoding
* to have the specified size. As webcrypto API assumes that x, y and d values
* has exactly the supposed number of bytes, whereas corresponding x, y and
* keyValue values in proto might either have some leading zeros or the leading
* zeros might be missing.
*
*/
export declare function bigEndianNumberToCorrectLength(bigEndianNumber: Uint8Array, sizeInBytes: number): Uint8Array;
export declare function curveTypeProtoToSubtle(curveTypeProto: PbEllipticCurveType): EllipticCurves.CurveType;
export declare function hashTypeProtoToString(hashTypeProto: PbHashType): string;
export declare function pointFormatProtoToSubtle(pointFormatProto: PbPointFormat): EllipticCurves.PointFormatType;