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

Function signMessage

vmm/ui/src/lib/x25519.js:1545–1562  ·  view source on GitHub ↗

* Signs the given message using the private key and returns a signed message (signature concatenated with the message copy). * * Optional random data argument (which must have 64 random bytes) turns on hash separation and randomization to make signatures non-deterministic. * * @e

(secretKey, msg, opt_random)

Source from the content-addressed store, hash-verified

1543 * @returns
1544 */
1545 function signMessage(secretKey, msg, opt_random) {
1546 checkArrayTypes(msg, secretKey);
1547 if (secretKey.length !== 32)
1548 throw new Error('wrong secret key length');
1549 if (opt_random) {
1550 checkArrayTypes(opt_random);
1551 if (opt_random.length !== 64)
1552 throw new Error('wrong random data length');
1553 var buf = new Uint8Array(128 + msg.length);
1554 curve25519_sign(buf, msg, msg.length, secretKey, opt_random);
1555 return new Uint8Array(buf.subarray(0, 64 + msg.length));
1556 }
1557 else {
1558 var signedMsg = new Uint8Array(64 + msg.length);
1559 curve25519_sign(signedMsg, msg, msg.length, secretKey);
1560 return signedMsg;
1561 }
1562 }
1563 /**
1564 * Verifies signed message with the public key and returns the original message without signature if it's correct or null if verification fails.
1565 *

Callers

nothing calls this directly

Calls 2

checkArrayTypesFunction · 0.70
curve25519_signFunction · 0.70

Tested by

no test coverage detected