vestauth 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vestauth",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "vestauth",
5
5
  "keywords": [
6
6
  "vestauth"
@@ -6,12 +6,6 @@ secp.hashes.sha256 = sha256
6
6
  secp.hashes.hmacSha256 = (key, msg) => hmac(sha256, key, msg)
7
7
  const hash = require('./hash')
8
8
 
9
- // // publicKey (compressed): Uint8Array
10
- // const publicKey = getPublicKey(privateKey, true)
11
- //
12
- // // verifier side (server or client)
13
- // const ok = verify(signature, hash, publicKey)
14
-
15
9
  function sign (message, privateKeyHex) {
16
10
  const hashMessage = hash(message)
17
11
  const privateKeyBytes = Buffer.from(privateKeyHex, 'hex')
@@ -1,17 +1,12 @@
1
- // import { sign, verify, getPublicKey } from '@noble/secp256k1'
2
- // // publicKey (compressed): Uint8Array
3
- // const publicKey = getPublicKey(privateKey, true)
4
- //
5
- // // verifier side (server or client)
6
- // const ok = verify(signature, hash, publicKey)
1
+ const secp = require('@noble/secp256k1')
2
+ const hash = require('./hash')
7
3
 
8
- function verify () {
9
- console.log('verify todo')
10
- // const hashMessage = hash(message)
11
- // const hashPrivateKey = hash(privateKey)
12
- // const signature = secp.sign(hashMessage, hashPrivateKey)
4
+ function verify (message, signatureBase64, publicKeyHex) {
5
+ const hashMessage = hash(message)
6
+ const signature = Buffer.from(signatureBase64, 'base64url')
7
+ const publicKeyBytes = Buffer.from(publicKeyHex, 'hex')
13
8
 
14
- // return Buffer.from(signature).toString('base64url') // base64 returned
9
+ return secp.verify(signature, hashMessage, publicKeyBytes)
15
10
  }
16
11
 
17
12
  module.exports = verify