Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
test(metadata): more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sha49 committed Nov 25, 2016
1 parent 4d8928d commit 240ca38
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 551 deletions.
6 changes: 4 additions & 2 deletions src/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Metadata.BufferToB64 = (buff) => buff.toString('base64');
Metadata.StringToBuffer = (base64) => Buffer.from(base64);
Metadata.BufferToString = (buff) => buff.toString();

// Buffer -> Buffer -> Base64String
// Metadata.message :: Buffer -> Buffer -> Base64String
Metadata.message = R.curry(
function (payload, prevMagic) {
if (prevMagic) {
Expand All @@ -80,7 +80,7 @@ Metadata.message = R.curry(
}
);

// Buffer -> Buffer -> Buffer
// Metadata.magic :: Buffer -> Buffer -> Buffer
Metadata.magic = R.curry(
function (payload, prevMagic) {
const msg = this.message(payload, prevMagic);
Expand All @@ -93,6 +93,8 @@ Metadata.verify = (address, signature, hash) =>

// Metadata.sign :: keyPair -> msg -> Buffer
Metadata.sign = (keyPair, msg) => Bitcoin.message.sign(keyPair, msg, Bitcoin.networks.bitcoin);

// Metadata.computeSignature :: keypair -> buffer -> buffer -> base64
Metadata.computeSignature = (key, payloadBuff, magicHash) =>
Metadata.sign(key, Metadata.message(payloadBuff, magicHash));

Expand Down

0 comments on commit 240ca38

Please sign in to comment.