vestauth 0.1.9 → 0.1.11
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 +3 -3
- package/src/lib/helpers/verify.js +17 -0
- package/src/lib/main.js +4 -2
package/package.json
CHANGED
package/src/lib/helpers/sign.js
CHANGED
|
@@ -12,10 +12,10 @@ const hash = require('./hash')
|
|
|
12
12
|
// // verifier side (server or client)
|
|
13
13
|
// const ok = verify(signature, hash, publicKey)
|
|
14
14
|
|
|
15
|
-
function sign (message,
|
|
15
|
+
function sign (message, privateKeyHex) {
|
|
16
16
|
const hashMessage = hash(message)
|
|
17
|
-
const
|
|
18
|
-
const signature = secp.sign(hashMessage,
|
|
17
|
+
const privateKeyBytes = Buffer.from(privateKeyHex, 'hex')
|
|
18
|
+
const signature = secp.sign(hashMessage, privateKeyBytes)
|
|
19
19
|
|
|
20
20
|
return Buffer.from(signature).toString('base64url') // base64 returned
|
|
21
21
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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)
|
|
7
|
+
|
|
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)
|
|
13
|
+
|
|
14
|
+
// return Buffer.from(signature).toString('base64url') // base64 returned
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = verify
|
package/src/lib/main.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
const hash = require('./helpers/hash')
|
|
1
2
|
const keypair = require('./helpers/keypair')
|
|
2
3
|
const sign = require('./helpers/sign')
|
|
3
|
-
const
|
|
4
|
+
const verify = require('./helpers/verify')
|
|
4
5
|
|
|
5
6
|
module.exports = {
|
|
6
7
|
hash,
|
|
7
8
|
keypair,
|
|
8
|
-
sign
|
|
9
|
+
sign,
|
|
10
|
+
verify
|
|
9
11
|
}
|