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

Function openMessage

vmm/ui/src/lib/x25519.js:1571–1583  ·  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

1569 * @returns Message
1570 */
1571 function openMessage(publicKey, signedMsg) {
1572 checkArrayTypes(signedMsg, publicKey);
1573 if (publicKey.length !== 32)
1574 throw new Error('wrong public key length');
1575 var tmp = new Uint8Array(signedMsg.length);
1576 var mlen = curve25519_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
1577 if (mlen < 0)
1578 return null;
1579 var m = new Uint8Array(mlen);
1580 for (var i = 0; i < m.length; i++)
1581 m[i] = tmp[i];
1582 return m;
1583 }
1584 /**
1585 * Signs the given message using the private key and returns signature.
1586 *

Callers

nothing calls this directly

Calls 2

checkArrayTypesFunction · 0.70
curve25519_sign_openFunction · 0.70

Tested by

no test coverage detected