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

Function sign_message

kms/src/crypto.rs:32–43  ·  view source on GitHub ↗
(
    key: &SigningKey,
    prefix: &[u8],
    appid: &[u8],
    message: &[u8],
)

Source from the content-addressed store, hash-verified

30}
31
32pub(crate) fn sign_message(
33 key: &SigningKey,
34 prefix: &[u8],
35 appid: &[u8],
36 message: &[u8],
37) -> Result<Vec<u8>> {
38 let digest = Keccak256::new_with_prefix([prefix, b":", appid, message].concat());
39 let (signature, recid) = key.sign_digest_recoverable(digest)?;
40 let mut signature_bytes = signature.to_vec();
41 signature_bytes.push(recid.to_byte());
42 Ok(signature_bytes)
43}
44
45/// Sign a message with a timestamp to prevent replay attacks.
46/// The signature covers: prefix + ":" + appid + timestamp_be_bytes + message

Callers 2

derive_k256_keyFunction · 0.85

Calls 1

to_vecMethod · 0.80

Tested by

no test coverage detected