Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 38 additions & 10 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 @@ -55,7 +55,7 @@
},
"homepage": "https://github.com/solidos/solid-ui",
"dependencies": {
"@noble/curves": "^1.9.6",
"@noble/curves": "^2.0.1",
"acorn": "^8.15.0",
"escape-html": "^1.0.3",
"i": "^0.3.7",
Expand Down
8 changes: 4 additions & 4 deletions src/chat/keys.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as debug from '../debug'
import { schnorr } from '@noble/curves/secp256k1'
import { bytesToHex } from '@noble/hashes/utils'
import { secp256k1 } from '@noble/curves/secp256k1.js'
import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js'
import * as ns from '../ns'
import { store } from 'solid-logic'
import { NamedNode } from 'rdflib'
Expand All @@ -9,11 +9,11 @@
import { setAcl, keyContainerAclBody, keyAclBody } from '../utils/keyHelpers/acl'

export function generatePrivateKey (): string {
return bytesToHex(schnorr.utils.randomPrivateKey())
return bytesToHex(secp256k1.utils.randomSecretKey())
}

export function generatePublicKey (privateKey: string): string {
return bytesToHex(schnorr.getPublicKey(privateKey))
return bytesToHex(secp256k1.getPublicKey(hexToBytes(privateKey)))
}

/**
Expand All @@ -30,7 +30,7 @@
await store.fetcher.load(publicKeyDoc) // url.href)
const key = store.any(webId, ns.solid('publicKey'))
return key?.value // as NamedNode
} catch (err) {

Check warning on line 33 in src/chat/keys.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

'err' is defined but never used

Check warning on line 33 in src/chat/keys.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'err' is defined but never used

Check warning on line 33 in src/chat/keys.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'err' is defined but never used

Check warning on line 33 in src/chat/keys.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

'err' is defined but never used

Check warning on line 33 in src/chat/keys.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'err' is defined but never used

Check warning on line 33 in src/chat/keys.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'err' is defined but never used
return undefined
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/chat/signature.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { schnorr } from '@noble/curves/secp256k1'
import { bytesToHex } from '@noble/hashes/utils'
import { sha256 } from '@noble/hashes/sha256'
import { schnorr } from '@noble/curves/secp256k1.js'
import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js'
import { sha256 } from '@noble/hashes/sha2.js'

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

export function verifySignature (sig: string, message: Message, pubKey: string): boolean {
return schnorr.verify(
sig,
getMsgHash(message),
pubKey
hexToBytes(sig),
hexToBytes(getMsgHash(message)),
hexToBytes(pubKey)
)
}

export function signMsg (message: UnsignedMsg, key: string): string {
return bytesToHex(
schnorr.sign(getMsgHash(message), key)
schnorr.sign(hexToBytes(getMsgHash(message)), hexToBytes(key))
)
}
Loading