Skip to content

Commit

Permalink
update rpuzzle
Browse files Browse the repository at this point in the history
  • Loading branch information
xhliu committed Mar 19, 2022
1 parent dfa09b7 commit 1649f73
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions docs/rpuzzle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,14 @@ More information can be found in the `R-Puzzle`_ talk.
contract RPuzzle {
Ripemd160 rhash;
constructor(Ripemd160 rhash) {
this.rhash = rhash;
}
function getSigR(Sig sigr): bytes {
bytes lenBytes = sigr[3:4];
int len = unpack(lenBytes);
bytes r = sigr[4:4+len];
return r;
// extract r from DER-encoded signature
static function extractRFromSig(Sig sig) : bytes {
int rlen = unpack(sig[3 : 4]);
return sig[4 : 4 + rlen];
}
public function unlock(Sig sig, PubKey pubKey, Sig sigr) {
require(this.rhash == hash160(this.getSigR(sigr)));
require(this.rhash == hash160(extractRFromSig(sigr)));
require(checkSig(sigr, pubKey));
require(checkSig(sig, pubKey));
}
Expand Down

0 comments on commit 1649f73

Please sign in to comment.