I am having issues with validating a signature created using the elliptic JavaScript library and the ecdsa library from Golang. The elliptic curve in question is secp256k1.
Below are some snippets of code:
Here are the TypeScript utility functions:
import * as bigInt from 'big-integer';
declare const require: any;
var EC = require('elliptic').ec;
var ec = new EC('secp256k1');
const SHA256 = require("crypto-js/sha256");
// Utility functions for generating private key, public key, signing message, verifying message
...
class PublicKey {
constructor(
public x: string,
public y: string
) { }
}
class Signature {
constructor(
public r: string,
public s: string,
public recoveryParam: number
) { }
}
Example of a signature generated using the functions above:
// Private Key
...
// Go code used for signature verification:
...
hash := fmt.Sprintf(
...
)
pubKey := ecdsa.PublicKey{
Curve: secp256k1.S256(),
X: xVal,
Y: yVal,
}
fmt.Printf("SIG VERIFICATION: %v", ecdsa.Verify(&pubKey, []byte(hash), rVal, sVal))
The current output is:
SIG VERIFICATION: false
The expected output should be true. Kindly let me know if you need more information or have any questions.