Skip to content

Commit

Permalink
fix: MVC security issues in signMessage and verifySignature APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
AricRedemption committed Mar 14, 2024
1 parent d3a908b commit 9d85813
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const signMessage = (
privateKey: mvc.PrivateKey,
encoding?: 'utf-8' | 'base64' | 'hex' | 'utf8'
) => {
const messageHash = mvc.crypto.Hash.sha256(Buffer.from(message))
const messageHash = mvc.crypto.Hash.sha256(Buffer.from('MVC Signed Message:\n' + message))

let sigBuf = mvc.crypto.ECDSA.sign(messageHash, privateKey).toBuffer()

Expand Down Expand Up @@ -61,7 +61,7 @@ export const verifySignature = (
publicKey: mvc.PublicKey,
encoding?: 'utf-8' | 'base64' | 'hex' | 'utf8'
) => {
const messageHash = mvc.crypto.Hash.sha256(Buffer.from(message))
const messageHash = mvc.crypto.Hash.sha256(Buffer.from('MVC Signed Message:\n' + message))

const sigDER = Buffer.from(signature, encoding || 'hex')
const sigObj = mvc.crypto.Signature.fromDER(sigDER)
Expand Down

0 comments on commit 9d85813

Please sign in to comment.