https://github.com/dchest/gimli-js
Gimli permutation and hash implementation in JavaScript
https://github.com/dchest/gimli-js
Last synced: about 1 year ago
JSON representation
Gimli permutation and hash implementation in JavaScript
- Host: GitHub
- URL: https://github.com/dchest/gimli-js
- Owner: dchest
- License: unlicense
- Created: 2017-09-27T23:44:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-19T13:25:46.000Z (over 8 years ago)
- Last Synced: 2025-03-25T02:43:35.158Z (about 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Gimli in JavaScript
===================
"Gimli is a 384-bit permutation designed to achieve high security with high
performance across a broad range of platforms."
https://gimli.cr.yp.to/
This is a JavaScript implementation of the permutation
and a sponge-based hash function (XOF).
Installation
------------
```
npm install gimli-crypto
```
But it's really small, maybe just copy and paste?
Usage
-----
### Permutation
```js
var gimli = require('gimli-crypto').gimli;
var state = new Uint8Array(48);
// state is 000000....0000
gimli(state);
// state is c4d867....302e
```
### Hash (eXtended Output Function)
```js
var hash = require('gimli-crypto').hash;
// 32-byte digest of [1,2,3,4,5,6] calculated in two steps.
var digest = hash()
.write(new Uint8Array([1,2,3]))
.write(new Uint8Array([4,5,6]))
.read();
// 111-byte digest of [1,2,3]
var longDigest = new Uint8Array(111);
var data = new Uint8Array([1,2,3]);
hash().write(data).read(longDigest);
// XORing with output of XOF
var key = new Uint8Array([1,2,3]);
var text = new Uint8Array([4,5,6]);
hash().write(key).read(text, true);
// outputs Uint8Array [ 81, 10, 158 ]
```