Skip to content

Commit

Permalink
chore: use hashes-grs 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Jan 26, 2024
1 parent 9915cda commit 4dd1331
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"src"
],
"dependencies": {
"@noble/hashes": "^1.2.0",
"hashes-grs": "^1.2.0",
"bech32": "^2.0.0",
"bip174": "^2.1.1",
"bs58grscheck": "^3.0.1",
Expand Down
15 changes: 12 additions & 3 deletions src/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
exports.taggedHash =
exports.TAGGED_HASH_PREFIXES =
exports.TAGS =
exports.groestl =
exports.hash256 =
exports.hash160 =
exports.sha256 =
exports.sha1 =
exports.ripemd160 =
void 0;
const ripemd160_1 = require('@noble/hashes/ripemd160');
const sha1_1 = require('@noble/hashes/sha1');
const sha256_1 = require('@noble/hashes/sha256');
const ripemd160_1 = require('hashes-grs/ripemd160');
const sha1_1 = require('hashes-grs/sha1');
const sha256_1 = require('hashes-grs/sha256');
const groestl512_1 = require('hashes-grs/groestl512');
const groestl256_1 = require('hashes-grs/groestl256');
function ripemd160(buffer) {
return Buffer.from((0, ripemd160_1.ripemd160)(Uint8Array.from(buffer)));
}
Expand All @@ -36,6 +39,12 @@ function hash256(buffer) {
);
}
exports.hash256 = hash256;
function groestl(buffer) {
return Buffer.from(
(0, groestl256_1.groestl256)((0, groestl512_1.groestl512)(buffer)),
);
}
exports.groestl = groestl;
exports.TAGS = [
'BIP0340/challenge',
'BIP0340/aux',
Expand Down
10 changes: 6 additions & 4 deletions ts_src/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ripemd160 as _ripemd160 } from '@noble/hashes/ripemd160';
import { sha1 as _sha1 } from '@noble/hashes/sha1';
import { sha256 as _sha256 } from '@noble/hashes/sha256';
import { ripemd160 as _ripemd160 } from 'hashes-grs/ripemd160';
import { sha1 as _sha1 } from 'hashes-grs/sha1';
import { sha256 as _sha256 } from 'hashes-grs/sha256';
import { groestl512, groestl512 as _groest512 } from 'hashes-grs/groestl512';
import { groestl256 as _groest256 } from 'hashes-grs/groestl256';

export function ripemd160(buffer: Buffer): Buffer {
return Buffer.from(_ripemd160(Uint8Array.from(buffer)));
Expand All @@ -23,7 +25,7 @@ export function hash256(buffer: Buffer): Buffer {
}

export function groestl(buffer: Buffer): Buffer {
return new Buffer(groestlhash.groestl_2(buffer, 1, 1));
return Buffer.from(_groest256(groestl512(buffer)));
}

export const TAGS = [
Expand Down

0 comments on commit 4dd1331

Please sign in to comment.