Skip to content

Commit

Permalink
enabled Hash.from
Browse files Browse the repository at this point in the history
  • Loading branch information
calidion committed Dec 17, 2019
1 parent b5e8ecf commit 96e59c4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export declare class Hash {
static fast(buffer: Buffer): Buffer;
static slow(buffer: Buffer, variant: number): Buffer;
static check(buffer: Buffer, difficulty: number): Buffer;
static from(buffer: Buffer): Buffer;
}

export declare class Amount {
Expand Down
8 changes: 6 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ Signature.generateRing = (

Signature.checkRing = (
prefixHash, image, pubsv, pubsCount, signatures
) => {
) => {
return addon.checkRingSignature(
prefixHash, image, pubsv, pubsCount, signatures
);
);
}

Hash.fast = (buffer) => {
Expand All @@ -118,6 +118,10 @@ Hash.check = (buffer, difficulty) => {
return addon.checkHash(buffer, difficulty);
}

Hash.from = (buffer) => {
return Buffer.from(Hash.fast(buffer), "hex");
};

Amount.getPenalized = (amount, medianSize, currentBlockSize) => {
return addon.getPenalized(amount, medianSize, currentBlockSize);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vigcoin/neon",
"version": "0.2.6",
"version": "0.2.7",
"description": "",
"main": "lib/index.js",
"author": "calidion <[email protected]>",
Expand Down
7 changes: 7 additions & 0 deletions test/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@ describe("Test Hash", () => {
199, 175, 49, 254, 177, 181, 91, 56, 9, 98, 1, 0, 0
]), 10343869));
});

it("should test check hash", function () {
assert(Hash.from(Buffer.from([
0, 223, 74, 253, 65, 221, 188, 172, 253, 50, 122, 246, 173, 212, 162, 103, 13, 174, 254,
199, 175, 49, 254, 177, 181, 91, 56, 9, 98, 1, 0, 0
])).length === 32);
});
});

0 comments on commit 96e59c4

Please sign in to comment.