Skip to content

Commit

Permalink
replace bin2num() with unpack()
Browse files Browse the repository at this point in the history
  • Loading branch information
xhliu committed Feb 14, 2020
1 parent b2f01f4 commit 3708a94
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/ackermann.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ nCrypt has devised a way to calculate the value of the Ackermann function using
loop (14) {
if (length(stk) > 0) {
bytes top = stk[0:1];
m = bin2num(top);
m = unpack(top);
// pop
stk = stk[1:length(stk)];
Expand Down
4 changes: 0 additions & 4 deletions docs/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ bytes Operations

Converts a number ``num`` into a byte array of certain size ``size``, including the sign bit. It fails if the number cannot be accommodated.

* ``int bin2num(bytes b)``

Converts a bytes array ``b`` to an integer, including minimal encoding in signed magnitude format.

* ``int length(bytes b)``

Returns the length of ``b``.
Expand Down
4 changes: 2 additions & 2 deletions docs/rabin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Rabin Signature
public function verifySig(int S, bytes U, bytes m, int lambda, bytes n) {
require(hash160(n) == this.nHash);
int h = bin2num(this.hash3072(m ++ U));
require(S * S == h + lambda * bin2num(n));
int h = unpack(this.hash3072(m ++ U));
require(S * S == h + lambda * unpack(n));
}
}
2 changes: 1 addition & 1 deletion docs/rpuzzle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ One crucial step in R-Puzzle is to extract ``r`` from `DER`_ encoded signature.
function getSigR(Sig sig) returns (bytes) {
bytes lenBytes = sig[3:4];
int len = bin2num(lenBytes);
int len = unpack(lenBytes);
bytes r = sig[4:4+len];
return r;
}
Expand Down

0 comments on commit 3708a94

Please sign in to comment.