* Verifies signed message with the public key and returns the original message without signature if it's correct or null if verification fails. * * @export * @param {Uint8Array} publicKey * @param {*} signedMsg * @returns Message
(publicKey, signedMsg)
| 1570 | * @returns Message |
| 1571 | */ |
| 1572 | function openMessage(publicKey, signedMsg) { |
| 1573 | checkArrayTypes(signedMsg, publicKey); |
| 1574 | if (publicKey.length !== 32) |
| 1575 | throw new Error('wrong public key length'); |
| 1576 | var tmp = new Uint8Array(signedMsg.length); |
| 1577 | var mlen = curve25519_sign_open(tmp, signedMsg, signedMsg.length, publicKey); |
| 1578 | if (mlen < 0) |
| 1579 | return null; |
| 1580 | var m = new Uint8Array(mlen); |
| 1581 | for (var i = 0; i < m.length; i++) |
| 1582 | m[i] = tmp[i]; |
| 1583 | return m; |
| 1584 | } |
| 1585 | /** |
| 1586 | * Signs the given message using the private key and returns signature. |
| 1587 | * |
nothing calls this directly
no test coverage detected