forked from bcoin-org/bcrypto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblake2s256.js
65 lines (50 loc) · 1.03 KB
/
blake2s256.js
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
/*!
* blake2s256.js - BLAKE2s implementation for bcrypto
* Copyright (c) 2017-2019, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcrypto
*/
'use strict';
const BLAKE2s = require('./blake2s');
/**
* BLAKE2s256
*/
class BLAKE2s256 extends BLAKE2s {
constructor() {
super();
}
init(key) {
return super.init(32, key);
}
static hash() {
return new BLAKE2s256();
}
static hmac() {
return super.hmac(32);
}
static digest(data, key) {
return super.digest(data, 32, key);
}
static root(left, right, key) {
return super.root(left, right, 32, key);
}
static multi(x, y, z, key) {
return super.multi(x, y, z, 32, key);
}
static mac(data, key) {
return super.mac(data, key, 32);
}
}
/*
* Static
*/
BLAKE2s256.native = BLAKE2s.native;
BLAKE2s256.id = 'BLAKE2S256';
BLAKE2s256.size = 32;
BLAKE2s256.bits = 256;
BLAKE2s256.blockSize = 64;
BLAKE2s256.zero = Buffer.alloc(32, 0x00);
BLAKE2s256.ctx = new BLAKE2s256();
/*
* Expose
*/
module.exports = BLAKE2s256;