Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun authored Apr 19, 2024
1 parent 2f52907 commit c82d587
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/sm2.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function adaptSM2 (ecdsa) {
* @param {String|Uint8Array|Buffer} data The data to be encrypted
* @param {EncrypterOptions} opts options for ciphertext format, default is C1C3C2
* @returns hex string of ciphertext
*/
*/
ecdsa.encrypt = function (data, opts = DEFAULT_SM2_ENCRYPT_OPTIONS) {
const Q = rs.ECPointFp.decodeFromHex(this.ecparams.curve, this.pubKeyHex)
return this.encryptRaw(data, Q, opts)
Expand All @@ -106,7 +106,7 @@ function adaptSM2 (ecdsa) {
* @param {String} data The hex data to be encrypted
* @param {EncrypterOptions} opts options for ciphertext format, default is C1C3C2
* @returns hex string of ciphertext
*/
*/
ecdsa.encryptHex = function (dataHex, opts = DEFAULT_SM2_ENCRYPT_OPTIONS) {
return this.encrypt(new Uint8Array(Buffer.from(dataHex, 'hex')), opts)
}
Expand All @@ -117,7 +117,7 @@ function adaptSM2 (ecdsa) {
* @param {ECPointFp} Q The ecc point of the public key
* @param {EncrypterOptions} opts options for ciphertext format, default is C1C3C2
* @returns hex string of ciphertext
*/
*/
ecdsa.encryptRaw = function (data, Q, opts = DEFAULT_SM2_ENCRYPT_OPTIONS) {
if (!opts || !(opts instanceof EncrypterOptions)) {
opts = DEFAULT_SM2_ENCRYPT_OPTIONS
Expand Down Expand Up @@ -175,7 +175,7 @@ function adaptSM2 (ecdsa) {
* SM2 decryption
* @param {String} dataHex The hex data to be decrypted
* @return {String} decrypted hex content
*/
*/
ecdsa.decryptHex = function (dataHex) {
return this.decrypt(new Uint8Array(Buffer.from(dataHex, 'hex')))
}
Expand All @@ -185,7 +185,7 @@ function adaptSM2 (ecdsa) {
* @param {Uint8Array} data The hex data to be decrypted
* @param {BigInteger} d The SM2 private key
* @return {String} decrypted hex content
*/
*/
ecdsa.decryptRaw = function (data, d) {
data = util.normalizeInput(data)
const dataLen = data.length
Expand Down Expand Up @@ -229,7 +229,7 @@ function adaptSM2 (ecdsa) {
* @param {String} hashHex the hex string of hash
* @param {String} privHex the hex string of the private key
* @returns the hex string of the signature with asn1 format
*/
*/
ecdsa.signHex = function (hashHex, privHex) {
const d = new rs.BigInteger(privHex, 16)
return this._signHexInternal(hashHex, d)
Expand All @@ -239,7 +239,7 @@ function adaptSM2 (ecdsa) {
* Sign the hash of message
* @param {String} hashHex the hex string of hash
* @returns the hex string of the signature with asn1 format
*/
*/
ecdsa.signWithMessageHash = function (hashHex) {
if (!this._d) {
this._d = new rs.BigInteger(this.prvKeyHex, 16)
Expand Down Expand Up @@ -279,7 +279,7 @@ function adaptSM2 (ecdsa) {
* @param {BigInteger} s The big integer from signature s
* @param {ECPointFp} Q The ecc point of the public key
* @returns ture or false
*/
*/
ecdsa.verifyRaw = function (e, r, s, Q) {
const n = this.ecparams.n
const G = this.ecparams.G
Expand Down

0 comments on commit c82d587

Please sign in to comment.