MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / openMessage

Function openMessage

vmm/src/x25519.js:1572–1584  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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 *

Callers

nothing calls this directly

Calls 2

checkArrayTypesFunction · 0.70
curve25519_sign_openFunction · 0.70

Tested by

no test coverage detected