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

Function verify

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

* Verifies the given signature for the message using the given private key. Returns true if the signature is valid, false otherwise. * * @export * @param {Uint8Array} publicKey * @param {*} msg * @param {*} signature * @returns

(publicKey, msg, signature)

Source from the content-addressed store, hash-verified

1618 * @returns
1619 */
1620 function verify(publicKey, msg, signature) {
1621 checkArrayTypes(msg, signature, publicKey);
1622 if (signature.length !== 64)
1623 throw new Error('wrong signature length');
1624 if (publicKey.length !== 32)
1625 throw new Error('wrong public key length');
1626 var sm = new Uint8Array(64 + msg.length);
1627 var m = new Uint8Array(64 + msg.length);
1628 var i;
1629 for (i = 0; i < 64; i++)
1630 sm[i] = signature[i];
1631 for (i = 0; i < msg.length; i++)
1632 sm[i + 64] = msg[i];
1633 return curve25519_sign_open(m, sm, sm.length, publicKey) >= 0;
1634 }
1635 /**
1636 * Generates a new key pair from the given 32-byte secret seed (which should be generated with a CSPRNG) and returns it as object.
1637 *

Callers

nothing calls this directly

Calls 2

checkArrayTypesFunction · 0.70
curve25519_sign_openFunction · 0.70

Tested by

no test coverage detected