Skip to content

Commit

Permalink
libauth now using latest (3.x)
Browse files Browse the repository at this point in the history
  • Loading branch information
arietrouw committed Aug 27, 2024
1 parent 80bb502 commit a4bfc70
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/protocol/packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"module": "dist/neutral/index.mjs",
"types": "dist/neutral/index.d.ts",
"dependencies": {
"@bitauth/libauth-1-19-1": "npm:@bitauth/libauth@1.19.1",
"@bitauth/libauth": "^3.0.0",
"@scure/bip39": "^1.3.0",
"@xylabs/arraybuffer": "^4.0.5",
"@xylabs/assert": "^4.0.5",
Expand Down
10 changes: 5 additions & 5 deletions packages/protocol/packages/account/src/Elliptic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Secp256k1 } from '@bitauth/libauth-1-19-1'
import { instantiateSecp256k1 } from '@bitauth/libauth-1-19-1'
import type { Secp256k1 } from '@bitauth/libauth'
import { instantiateSecp256k1 } from '@bitauth/libauth'
import { toUint8Array } from '@xylabs/arraybuffer'
import { assertEx } from '@xylabs/assert'
import { Data } from '@xyo-network/data'
Expand Down Expand Up @@ -41,7 +41,7 @@ export class Elliptic {

static async publicKeyFromPrivateKey(privateKey: ArrayBuffer, prefix = false): Promise<ArrayBuffer> {
const { derivePublicKeyUncompressed } = await this.secp256k1()
const fullPublicKey = derivePublicKeyUncompressed(new Uint8Array(privateKey))
const fullPublicKey = toUint8Array(derivePublicKeyUncompressed(new Uint8Array(privateKey)))
return prefix ? fullPublicKey : fullPublicKey.slice(1)
}

Expand All @@ -62,15 +62,15 @@ export class Elliptic {

static async sign(hash: ArrayBuffer, key: ArrayBuffer) {
const { signMessageHashCompact } = await this.secp256k1()
return signMessageHashCompact(new Uint8Array(key), toUint8Array(hash))
return toUint8Array(signMessageHashCompact(new Uint8Array(key), toUint8Array(hash)))
}

static async verify(msg: ArrayBuffer, signature: ArrayBuffer, address: ArrayBuffer) {
const verifier = await this.secp256k1()
if (verifier && this.wasmSupport.canUseWasm) {
for (const recoveryId of recoveryIds) {
try {
const recoveredPublicKey = verifier.recoverPublicKeyUncompressed(toUint8Array(signature), recoveryId, toUint8Array(msg)).slice(1)
const recoveredPublicKey = toUint8Array(verifier.recoverPublicKeyUncompressed(toUint8Array(signature), recoveryId, toUint8Array(msg)).slice(1))
const recoveredAddress = this.addressFromPublicKey(recoveredPublicKey)
if (compareArrayBuffers(address, recoveredAddress)) {
return true
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -885,10 +885,10 @@ __metadata:
languageName: node
linkType: hard

"@bitauth/libauth-1-19-1@npm:@bitauth/libauth@1.19.1":
version: 1.19.1
resolution: "@bitauth/libauth@npm:1.19.1"
checksum: 10/325e396bdbed4af15861085db8b702a9a5083fea9f22c451598ca574d25edf1d344b22b7576b082da5bab8a46d9b31ea42f206e1ad4d5c1b02e877b62448c1aa
"@bitauth/libauth@npm:^3.0.0":
version: 3.0.0
resolution: "@bitauth/libauth@npm:3.0.0"
checksum: 10/3158091c462f16cc1e9df8b4bbf35e6fa3f85dde1d8f6337344d4c0102b4f0b55a0768472d6ef88c297a9050772b6ee0ff4bc65174f5c4e6af7721dd9d7eac1c
languageName: node
linkType: hard

Expand Down Expand Up @@ -4108,7 +4108,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@xyo-network/account@workspace:packages/protocol/packages/account"
dependencies:
"@bitauth/libauth-1-19-1": "npm:@bitauth/libauth@1.19.1"
"@bitauth/libauth": "npm:^3.0.0"
"@scure/bip39": "npm:^1.3.0"
"@xylabs/arraybuffer": "npm:^4.0.5"
"@xylabs/assert": "npm:^4.0.5"
Expand Down

0 comments on commit a4bfc70

Please sign in to comment.