Skip to content

Commit d665d3c

Browse files
authored
Merge pull request #210 from fleet-sdk/arobsn/bump-crypto
feat: bump @noble & @Scure crypto dependencies
2 parents 4dad6d9 + 482fe12 commit d665d3c

17 files changed

+102
-67
lines changed

.changeset/brave-walls-sneeze.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@fleet-sdk/wallet": patch
3+
---
4+
5+
Bump `@scure/bip32` to `v2`

.changeset/dry-heads-dream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@fleet-sdk/wallet": patch
3+
---
4+
5+
Bump `@scure/bip39` to `v2`

.changeset/eight-bugs-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@fleet-sdk/crypto": patch
3+
---
4+
5+
Bump `@scure/base` to `v2`

.changeset/shiny-taxes-cry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@fleet-sdk/wallet": patch
3+
---
4+
5+
Bump `@noble/curves` to `v2`

.changeset/wacky-towns-stick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@fleet-sdk/crypto": patch
3+
---
4+
5+
Bump `@noble/hashes` to `v2`

packages/crypto/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
},
3838
"dependencies": {
3939
"@fleet-sdk/common": "workspace:^",
40-
"@noble/hashes": "^1.8.0",
41-
"@scure/base": "^1.2.6"
40+
"@noble/hashes": "^2.0.1",
41+
"@scure/base": "^2.0.0"
4242
},
4343
"files": [
4444
"dist",

packages/crypto/src/coders/hex.bench.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { bytesToHex, hexToBytes } from "@noble/hashes/utils";
1+
import { bytesToHex, hexToBytes } from "@noble/hashes/utils.js";
22
import { hex as scureHex } from "@scure/base";
33
import { bench, describe } from "vitest";
44
import { regularBoxes, validBoxes } from "../../../_test-vectors/mockedBoxes";

packages/crypto/src/hashes.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { randomBytes } from "@noble/hashes/utils";
1+
import { randomBytes } from "@noble/hashes/utils.js";
22
import { describe, expect, it } from "vitest";
33
import { hex, utf8 } from "./coders";
44
import { blake2b, blake2b256, sha256 } from "./hashes";

packages/crypto/src/hashes.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { blake2b as _blake2b } from "@noble/hashes/blake2b";
2-
import { sha256 as _sha256 } from "@noble/hashes/sha256";
1+
import { type Blake2Opts, blake2b as _blake2b } from "@noble/hashes/blake2.js";
2+
import { sha256 as _sha256 } from "@noble/hashes/sha2.js";
33
import { hex } from "./coders";
44
import type { ByteInput } from "./types";
55

@@ -22,11 +22,17 @@ export function blake2b(message: ByteInput, options?: Blake2bOptions): Uint8Arra
2222
if (options?.salt) options.salt = ensureBytes(options.salt);
2323
if (options?.personalization) options.personalization = ensureBytes(options.personalization);
2424

25-
return _blake2b(ensureBytes(message), options);
25+
const opts: Blake2Opts = {
26+
key: options?.key ? ensureBytes(options?.key) : undefined,
27+
salt: options?.salt ? ensureBytes(options?.salt) : undefined,
28+
personalization: options?.personalization ? ensureBytes(options?.personalization) : undefined,
29+
dkLen: options?.dkLen
30+
};
31+
return _blake2b(ensureBytes(message), opts);
2632
}
2733

2834
export function blake2b256(message: ByteInput, options?: Blake2b256Options): Uint8Array {
29-
return blake2b(ensureBytes(message), { dkLen: 32, ...options });
35+
return blake2b(message, { dkLen: 32, ...options });
3036
}
3137

3238
export function sha256(message: ByteInput): Uint8Array {

packages/crypto/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { randomBytes as nobleRandomBytes } from "@noble/hashes/utils";
1+
import { randomBytes as nobleRandomBytes } from "@noble/hashes/utils.js";
22

33
/**
44
* Secure PRNG from "@noble/hashes". Uses crypto.getRandomValues, which defers to OS.

0 commit comments

Comments
 (0)