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

Function verify

vmm/src/x25519.js:1621–1635  ·  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

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

Callers

nothing calls this directly

Calls 2

checkArrayTypesFunction · 0.70
curve25519_sign_openFunction · 0.70

Tested by

no test coverage detected