-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathindex.d.ts
69 lines (60 loc) · 2.18 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
declare class Hasher<S = number> {
constructor(size?: S);
update(data: Buffer): this;
update(data: string, encoding?: BufferEncoding): this;
digest(): Buffer;
digest(encoding: "binary"): Buffer;
digest(encoding: BufferEncoding): string;
digest(options: DigestOptions<"binary">): Buffer;
digest(options: DigestOptions<BufferEncoding>): string;
reset(): this;
}
declare interface DigestOptions<T> {
format: T;
buffer?: Buffer;
padding?: number;
}
/**
* The SHA-3 specification requires that the input message be appended with a
* two-bit suffix, `01`. For byte-aligned messages, this results in an extra
* `0x02` byte (bits fill in from the right).
*
* Then, the standard Keccak padding scheme is applied (pad10*1), placing an
* additional bit at the `0x04` position, resulting in `0x06`.
*
* @see {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf}, Section B.2
*/
export class SHA3<S extends 224 | 256 | 384 | 512 = 512> extends Hasher<S> {
/**
* For backwards-compatibility, sprinkle SHA3Hash into the default export.
*
* @deprecated
*/
static SHA3Hash: typeof Keccak;
}
/**
* Provided for historical purposes. This is an alias for the *Keccak* algorithm,
* which an early version of SHA3 with different padding.
*
* @deprecated
*/
export const SHA3Hash: typeof Keccak;
/**
* The Keccak reference implementation uses the simplest possible padding scheme,
* described as follows:
*
* > Definition 1. Multi-rate padding, denoted by pad10*1, appends a single bit 1
* > followed by the minimum number of bits 0 followed by a single bit 1 such that
* > the length of the result is a multiple of the block length.
*
* @see {@link https://keccak.team/files/Keccak-reference-3.0.pdf}, Section 1.1.2
*/
export class Keccak<S extends 224 | 256 | 384 | 512 = 512> extends Hasher<S> {}
/**
* SHAKE is an 128-bit or 256-bit extendable output function (XOF) variant of
* Keccak that uses `0x1F` padding. (SHAKE = Secure Hash Algorithm KEccak)
*
* @see {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf}, Section 6.3
*/
export class SHAKE<S extends 128 | 256 = 256> extends Hasher<S> {}
export default SHA3;