Skip to content
This repository was archived by the owner on Jun 17, 2021. It is now read-only.

Commit 28d1354

Browse files
committed
Adds missing keccak tests.
1 parent 6a6af8e commit 28d1354

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

test/hash.spec.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,32 @@ import {
1616
} from '../src'
1717

1818
describe('keccak', function() {
19-
it('should produce a hash', function() {
19+
it('should produce a keccak224 hash', function() {
20+
const msg = '0x3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1'
21+
const r = '9e66938bd8f32c8610444bb524630db496bd58b689f9733182df63ba'
22+
const hash = keccak(toBuffer(msg), 224)
23+
assert.equal(hash.toString('hex'), r)
24+
})
25+
it('should produce a keccak256 hash', function() {
2026
const msg = '0x3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1'
2127
const r = '82ff40c0a986c6a5cfad4ddf4c3aa6996f1a7837f9c398e17e5de5cbd5a12b28'
2228
const hash = keccak(toBuffer(msg))
2329
assert.equal(hash.toString('hex'), r)
2430
})
31+
it('should produce a keccak384 hash', function() {
32+
const msg = '0x3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1'
33+
const r =
34+
'923e0f6a1c324a698139c3f3abbe88ac70bf2e7c02b26192c6124732555a32cef18e81ac91d5d97ce969745409c5bbc6'
35+
const hash = keccak(toBuffer(msg), 384)
36+
assert.equal(hash.toString('hex'), r)
37+
})
38+
it('should produce a keccak512 hash', function() {
39+
const msg = '0x3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1'
40+
const r =
41+
'36fdacd0339307068e9ed191773a6f11f6f9f99016bd50f87fd529ab7c87e1385f2b7ef1ac257cc78a12dcb3e5804254c6a7b404a6484966b831eadc721c3d24'
42+
const hash = keccak(toBuffer(msg), 512)
43+
assert.equal(hash.toString('hex'), r)
44+
})
2545
it('should error if input is not Buffer', function() {
2646
const msg = '0x3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1'
2747
assert.throws(function() {

0 commit comments

Comments
 (0)