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

Function crypto_sign_open

vmm/src/x25519.js:1455–1484  ·  view source on GitHub ↗
(m, sm, n, pk)

Source from the content-addressed store, hash-verified

1453 return 0;
1454 }
1455 function crypto_sign_open(m, sm, n, pk) {
1456 var i, mlen;
1457 var t = new Uint8Array(32), h = new Uint8Array(64);
1458 var p = [gf(), gf(), gf(), gf()], q = [gf(), gf(), gf(), gf()];
1459 mlen = -1;
1460 if (n < 64)
1461 return -1;
1462 if (unpackneg(q, pk))
1463 return -1;
1464 for (i = 0; i < n; i++)
1465 m[i] = sm[i];
1466 for (i = 0; i < 32; i++)
1467 m[i + 32] = pk[i];
1468 crypto_hash(h, m, n);
1469 reduce(h);
1470 scalarmult(p, q, h);
1471 scalarbase(q, sm.subarray(32));
1472 add(p, q);
1473 pack(t, p);
1474 n -= 64;
1475 if (crypto_verify_32(sm, 0, t, 0)) {
1476 for (i = 0; i < n; i++)
1477 m[i] = 0;
1478 return -1;
1479 }
1480 for (i = 0; i < n; i++)
1481 m[i] = sm[i + 64];
1482 mlen = n;
1483 return mlen;
1484 }
1485 // Converts Curve25519 public key back to Ed25519 public key.
1486 // edwardsY = (montgomeryX - 1) / (montgomeryX + 1)
1487 function convertPublicKey(pk) {

Callers 1

curve25519_sign_openFunction · 0.70

Calls 9

gfFunction · 0.70
unpacknegFunction · 0.70
crypto_hashFunction · 0.70
reduceFunction · 0.70
scalarmultFunction · 0.70
scalarbaseFunction · 0.70
addFunction · 0.70
packFunction · 0.70
crypto_verify_32Function · 0.70

Tested by

no test coverage detected