signing-key.d.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /**
  2. * Add details about signing here.
  3. *
  4. * @_subsection: api/crypto:Signing [about-signing]
  5. */
  6. import { Signature } from "./signature.js";
  7. import type { BytesLike } from "../utils/index.js";
  8. import type { SignatureLike } from "./index.js";
  9. /**
  10. * A **SigningKey** provides high-level access to the elliptic curve
  11. * cryptography (ECC) operations and key management.
  12. */
  13. export declare class SigningKey {
  14. #private;
  15. /**
  16. * Creates a new **SigningKey** for %%privateKey%%.
  17. */
  18. constructor(privateKey: BytesLike);
  19. /**
  20. * The private key.
  21. */
  22. get privateKey(): string;
  23. /**
  24. * The uncompressed public key.
  25. *
  26. * This will always begin with the prefix ``0x04`` and be 132
  27. * characters long (the ``0x`` prefix and 130 hexadecimal nibbles).
  28. */
  29. get publicKey(): string;
  30. /**
  31. * The compressed public key.
  32. *
  33. * This will always begin with either the prefix ``0x02`` or ``0x03``
  34. * and be 68 characters long (the ``0x`` prefix and 33 hexadecimal
  35. * nibbles)
  36. */
  37. get compressedPublicKey(): string;
  38. /**
  39. * Return the signature of the signed %%digest%%.
  40. */
  41. sign(digest: BytesLike): Signature;
  42. /**
  43. * Returns the [[link-wiki-ecdh]] shared secret between this
  44. * private key and the %%other%% key.
  45. *
  46. * The %%other%% key may be any type of key, a raw public key,
  47. * a compressed/uncompressed pubic key or aprivate key.
  48. *
  49. * Best practice is usually to use a cryptographic hash on the
  50. * returned value before using it as a symetric secret.
  51. *
  52. * @example:
  53. * sign1 = new SigningKey(id("some-secret-1"))
  54. * sign2 = new SigningKey(id("some-secret-2"))
  55. *
  56. * // Notice that privA.computeSharedSecret(pubB)...
  57. * sign1.computeSharedSecret(sign2.publicKey)
  58. * //_result:
  59. *
  60. * // ...is equal to privB.computeSharedSecret(pubA).
  61. * sign2.computeSharedSecret(sign1.publicKey)
  62. * //_result:
  63. */
  64. computeSharedSecret(other: BytesLike): string;
  65. /**
  66. * Compute the public key for %%key%%, optionally %%compressed%%.
  67. *
  68. * The %%key%% may be any type of key, a raw public key, a
  69. * compressed/uncompressed public key or private key.
  70. *
  71. * @example:
  72. * sign = new SigningKey(id("some-secret"));
  73. *
  74. * // Compute the uncompressed public key for a private key
  75. * SigningKey.computePublicKey(sign.privateKey)
  76. * //_result:
  77. *
  78. * // Compute the compressed public key for a private key
  79. * SigningKey.computePublicKey(sign.privateKey, true)
  80. * //_result:
  81. *
  82. * // Compute the uncompressed public key
  83. * SigningKey.computePublicKey(sign.publicKey, false);
  84. * //_result:
  85. *
  86. * // Compute the Compressed a public key
  87. * SigningKey.computePublicKey(sign.publicKey, true);
  88. * //_result:
  89. */
  90. static computePublicKey(key: BytesLike, compressed?: boolean): string;
  91. /**
  92. * Returns the public key for the private key which produced the
  93. * %%signature%% for the given %%digest%%.
  94. *
  95. * @example:
  96. * key = new SigningKey(id("some-secret"))
  97. * digest = id("hello world")
  98. * sig = key.sign(digest)
  99. *
  100. * // Notice the signer public key...
  101. * key.publicKey
  102. * //_result:
  103. *
  104. * // ...is equal to the recovered public key
  105. * SigningKey.recoverPublicKey(digest, sig)
  106. * //_result:
  107. *
  108. */
  109. static recoverPublicKey(digest: BytesLike, signature: SignatureLike): string;
  110. /**
  111. * Returns the point resulting from adding the ellipic curve points
  112. * %%p0%% and %%p1%%.
  113. *
  114. * This is not a common function most developers should require, but
  115. * can be useful for certain privacy-specific techniques.
  116. *
  117. * For example, it is used by [[HDNodeWallet]] to compute child
  118. * addresses from parent public keys and chain codes.
  119. */
  120. static addPoints(p0: BytesLike, p1: BytesLike, compressed?: boolean): string;
  121. }
  122. //# sourceMappingURL=signing-key.d.ts.map