Skip to content

Commit 9fd45e5

Browse files
committed
updated noble/curves dep
1 parent e046e2c commit 9fd45e5

File tree

4 files changed

+50
-22
lines changed

4 files changed

+50
-22
lines changed

package-lock.json

Lines changed: 38 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
},
5656
"homepage": "https://github.com/solidos/solid-ui",
5757
"dependencies": {
58-
"@noble/curves": "^1.9.6",
58+
"@noble/curves": "^2.0.1",
5959
"acorn": "^8.15.0",
6060
"escape-html": "^1.0.3",
6161
"i": "^0.3.7",

src/chat/keys.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as debug from '../debug'
2-
import { schnorr } from '@noble/curves/secp256k1'
3-
import { bytesToHex } from '@noble/hashes/utils'
2+
import { secp256k1 } from '@noble/curves/secp256k1.js'
3+
import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js'
44
import * as ns from '../ns'
55
import { store } from 'solid-logic'
66
import { NamedNode } from 'rdflib'
@@ -9,11 +9,11 @@ import { getExistingPublicKey, pubKeyUrl, privKeyUrl, getExistingPrivateKey } fr
99
import { setAcl, keyContainerAclBody, keyAclBody } from '../utils/keyHelpers/acl'
1010

1111
export function generatePrivateKey (): string {
12-
return bytesToHex(schnorr.utils.randomPrivateKey())
12+
return bytesToHex(secp256k1.utils.randomSecretKey())
1313
}
1414

1515
export function generatePublicKey (privateKey: string): string {
16-
return bytesToHex(schnorr.getPublicKey(privateKey))
16+
return bytesToHex(secp256k1.getPublicKey(hexToBytes(privateKey)))
1717
}
1818

1919
/**

src/chat/signature.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { schnorr } from '@noble/curves/secp256k1'
2-
import { bytesToHex } from '@noble/hashes/utils'
3-
import { sha256 } from '@noble/hashes/sha256'
1+
import { schnorr } from '@noble/curves/secp256k1.js'
2+
import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js'
3+
import { sha256 } from '@noble/hashes/sha2.js'
44

55
// import {utf8Encoder} from './utils'
66
// import { getPublicKey } from './keys'
@@ -110,14 +110,14 @@ export function getMsgHash (message: UnsignedMsg) {
110110

111111
export function verifySignature (sig: string, message: Message, pubKey: string): boolean {
112112
return schnorr.verify(
113-
sig,
114-
getMsgHash(message),
115-
pubKey
113+
hexToBytes(sig),
114+
hexToBytes(getMsgHash(message)),
115+
hexToBytes(pubKey)
116116
)
117117
}
118118

119119
export function signMsg (message: UnsignedMsg, key: string): string {
120120
return bytesToHex(
121-
schnorr.sign(getMsgHash(message), key)
121+
schnorr.sign(hexToBytes(getMsgHash(message)), hexToBytes(key))
122122
)
123123
}

0 commit comments

Comments
 (0)