vestauth 0.1.10 → 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 +1 -1
- package/src/lib/helpers/sign.js +1 -7
- package/src/lib/helpers/verify.js +7 -12
package/package.json
CHANGED
package/src/lib/helpers/sign.js
CHANGED
|
@@ -6,13 +6,7 @@ secp.hashes.sha256 = sha256
|
|
|
6
6
|
secp.hashes.hmacSha256 = (key, msg) => hmac(sha256, key, msg)
|
|
7
7
|
const hash = require('./hash')
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
// const publicKey = getPublicKey(privateKey, true)
|
|
11
|
-
//
|
|
12
|
-
// // verifier side (server or client)
|
|
13
|
-
// const ok = verify(signature, hash, publicKey)
|
|
14
|
-
|
|
15
|
-
function sign (message, privateKey) {
|
|
9
|
+
function sign (message, privateKeyHex) {
|
|
16
10
|
const hashMessage = hash(message)
|
|
17
11
|
const privateKeyBytes = Buffer.from(privateKeyHex, 'hex')
|
|
18
12
|
const signature = secp.sign(hashMessage, privateKeyBytes)
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
9
|
+
return secp.verify(signature, hashMessage, publicKeyBytes)
|
|
15
10
|
}
|
|
16
11
|
|
|
17
12
|
module.exports = verify
|