Adds recoverPubKey simple test
This commit is contained in:
parent
d7eb87433c
commit
e82ffa5028
1 changed files with 20 additions and 0 deletions
20
test/ecdsa.js
Normal file
20
test/ecdsa.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
var assert = require('assert')
|
||||
var convert = require('../').convert
|
||||
var ecdsa = require('../').ecdsa
|
||||
var Message = require('../').Message
|
||||
|
||||
describe('ecdsa', function() {
|
||||
describe('recoverPubKey', function() {
|
||||
it('succesfully recovers a public key', function() {
|
||||
var addr = 'mgQK8S6CfSXKjPmnujArSmVxafeJfrZsa3'
|
||||
var signature = convert.base64ToBytes('H0PG6+PUo96UPTJ/DVj8aBU5it+Nuli4YdsLuTMvfJxoHH9Jb7jYTQXCCOX2jrTChD5S1ic3vCrUQHdmB5/sEQY=')
|
||||
var sighex = convert.bytesToHex(signature)
|
||||
|
||||
var hash = Message.getHash('1111')
|
||||
var obj = ecdsa.parseSigCompact(signature)
|
||||
var pubKey = ecdsa.recoverPubKey(obj.r, obj.s, hash, obj.i)
|
||||
|
||||
assert.equal(pubKey.toHex(true), '02e8fcf4d749b35879bc1f3b14b49e67ab7301da3558c5a9b74a54f1e6339c334c')
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue