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

Function sign

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

* Signs the given message using the private key and returns signature. * * Optional random data argument (which must have 64 random bytes) turns on hash separation and randomization to make signatures non-deterministic. * * @export * @param {Uint8Array} secretKey * @par

(secretKey, msg, opt_random)

Source from the content-addressed store, hash-verified

1593 * @returns
1594 */
1595 function sign(secretKey, msg, opt_random) {
1596 checkArrayTypes(secretKey, msg);
1597 if (secretKey.length !== 32)
1598 throw new Error('wrong secret key length');
1599 if (opt_random) {
1600 checkArrayTypes(opt_random);
1601 if (opt_random.length !== 64)
1602 throw new Error('wrong random data length');
1603 }
1604 var buf = new Uint8Array((opt_random ? 128 : 64) + msg.length);
1605 curve25519_sign(buf, msg, msg.length, secretKey, opt_random);
1606 var signature = new Uint8Array(64);
1607 for (var i = 0; i < signature.length; i++)
1608 signature[i] = buf[i];
1609 return signature;
1610 }
1611 /**
1612 * Verifies the given signature for the message using the given private key. Returns true if the signature is valid, false otherwise.
1613 *

Callers

nothing calls this directly

Calls 2

checkArrayTypesFunction · 0.70
curve25519_signFunction · 0.70

Tested by

no test coverage detected