From 07e6584cf40156d20c8a9f9b43097d589195105a Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Tue, 20 Jun 2017 10:45:12 +0200 Subject: [PATCH] cc2 ed25519 condition creation --- package.json | 2 +- src/transaction/makeEd25519Condition.js | 2 +- test/test.js | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 43ca2c6..061cc31 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "decamelize": "^1.2.0", "es6-promise": "^4.0.5", "fetch-ponyfill": "^4.0.0", - "five-bells-condition": "3.3.1", + "five-bells-condition": "^5.0.1", "isomorphic-fetch": "^2.2.1", "js-sha3": "^0.5.7", "js-utility-belt": "^1.5.0", diff --git a/src/transaction/makeEd25519Condition.js b/src/transaction/makeEd25519Condition.js index 1bdd0e3..3f0ff57 100644 --- a/src/transaction/makeEd25519Condition.js +++ b/src/transaction/makeEd25519Condition.js @@ -16,7 +16,7 @@ import ccJsonify from './utils/ccJsonify' export default function makeEd25519Condition(publicKey, json = true) { const publicKeyBuffer = new Buffer(base58.decode(publicKey)) - const ed25519Fulfillment = new cc.Ed25519() + const ed25519Fulfillment = new cc.Ed25519Sha256() ed25519Fulfillment.setPublicKey(publicKeyBuffer) if (json) { diff --git a/test/test.js b/test/test.js index 5a1e216..d6d6ccc 100644 --- a/test/test.js +++ b/test/test.js @@ -28,3 +28,18 @@ test('Valid CREATE transaction is evaluated by BigchainDB', t => { .then(resTx => t.truthy(resTx)) }) +test('Ed25519 condition correctly formed', t => { + const publicKey = '4zvwRjXUKGfvwnParsHAS3HuSVzV5cA4McphgmoCtajS' + const output = Transaction.makeOutput(Transaction.makeEd25519Condition(publicKey)) + const target = { + details: { + type_id: 4, + bitmask: 32, + signature: null, + public_key: publicKey, + type: 'fulfillment' + }, + uri: 'ni:///sha-256;uLdVX7FEjLWVDkAkfMAkEqPPwFqZj7qfiGE152t_x5c?fpt=ed25519-sha-256&cost=131072' + } + t.deepEqual(target, output.condition) +})