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

Function crypto_sign_direct

vmm/src/x25519.js:1328–1355  ·  view source on GitHub ↗
(sm, m, n, sk)

Source from the content-addressed store, hash-verified

1326 }
1327 // Like crypto_sign, but uses secret key directly in hash.
1328 function crypto_sign_direct(sm, m, n, sk) {
1329 var h = new Uint8Array(64), r = new Uint8Array(64);
1330 var i, j, x = new Float64Array(64);
1331 var p = [gf(), gf(), gf(), gf()];
1332 for (i = 0; i < n; i++)
1333 sm[64 + i] = m[i];
1334 for (i = 0; i < 32; i++)
1335 sm[32 + i] = sk[i];
1336 crypto_hash(r, sm.subarray(32), n + 32);
1337 reduce(r);
1338 scalarbase(p, r);
1339 pack(sm, p);
1340 for (i = 0; i < 32; i++)
1341 sm[i + 32] = sk[32 + i];
1342 crypto_hash(h, sm, n + 64);
1343 reduce(h);
1344 for (i = 0; i < 64; i++)
1345 x[i] = 0;
1346 for (i = 0; i < 32; i++)
1347 x[i] = r[i];
1348 for (i = 0; i < 32; i++) {
1349 for (j = 0; j < 32; j++) {
1350 x[i + j] += h[i] * sk[j];
1351 }
1352 }
1353 modL(sm.subarray(32), x);
1354 return n + 64;
1355 }
1356 // Note: sm must be n+128.
1357 function crypto_sign_direct_rnd(sm, m, n, sk, rnd) {
1358 var h = new Uint8Array(64), r = new Uint8Array(64);

Callers 1

curve25519_signFunction · 0.70

Calls 6

gfFunction · 0.70
crypto_hashFunction · 0.70
reduceFunction · 0.70
scalarbaseFunction · 0.70
packFunction · 0.70
modLFunction · 0.70

Tested by

no test coverage detected