-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spv implementation #17
base: tx-creation
Are you sure you want to change the base?
Spv implementation #17
Conversation
A provisional tag is currently used, the correct tag creation procedure will be implemented later.
Done to check if Travis CI sees the commented out lines
src/trust_is_risk.js
Outdated
@@ -14,10 +14,46 @@ var TrustDB = require("./trust_db"); | |||
var DirectTrust = require("./direct_trust"); | |||
|
|||
class TrustIsRisk { | |||
node : bcoin$FullNode | |||
node : (bcoin$FullNode | bcoin$SPVNode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node : bcoin$Node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/trust_is_risk.js
Outdated
@@ -14,10 +14,46 @@ var TrustDB = require("./trust_db"); | |||
var DirectTrust = require("./direct_trust"); | |||
|
|||
class TrustIsRisk { | |||
node : bcoin$FullNode | |||
node : (bcoin$FullNode | bcoin$SPVNode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if you can type this with the superclass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/trust_is_risk.js
Outdated
// secp256k1 curve: y^2 = x^3 + 7 | ||
0x05, 0x5d, 0x5f, 0x28, 0x5e, 0xd7, 0x9d, 0x0c, | ||
0x6f, 0x61, 0xc3, 0x0e, 0xfc, 0x9d, 0x21, 0x91, | ||
0x65, 0x82, 0x80, 0x59, 0xa6, 0x01, 0x25, 0x0c, // 32 bytes with the y coordinate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep lines short, move comments above the lines they're describing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/trust_is_risk.js
Outdated
0x54, 0x72, 0x75, 0x73, 0x74, 0x20, 0x69, 0x73, | ||
0x20, 0x52, 0x69, 0x73, 0x6b, 0x00, 0x00, 0x00, // only x is given in short version | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DRY, compress using above constants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed compressed version entirely
src/trust_is_risk.js
Outdated
this.fakePubKeyArray = [0x04, // constant 0x04 prefix | ||
0x54, 0x72, 0x75, 0x73, 0x74, 0x20, 0x69, 0x73, | ||
0x20, 0x52, 0x69, 0x73, 0x6b, 0x00, 0x00, 0x00, // 32 bytes with the x coordinate | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // containing ASCII "Trust is Risk" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deduce this from the string 'Trust is Risk' instead of typing it out fully; at least the x part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed compressed versions completely
src/trust_is_risk.js
Outdated
this.tag = Buffer.from(this.fakeKeyRing.getAddress("base58")); | ||
|
||
|
||
this.compressedFakePubKeyArray = [0x02, // 0x02 prefix for even y values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove compressed vars
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/trust_is_risk.js
Outdated
compressedTag : Buffer | ||
|
||
constructor(node : (bcoin$FullNode | bcoin$SPVNode)) { | ||
this.fakePubKeyArray = [0x04, // constant 0x04 prefix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent comment correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/trust_is_risk.js
Outdated
compressedTag : Buffer | ||
|
||
constructor(node : (bcoin$FullNode | bcoin$SPVNode)) { | ||
this.fakePubKeyArray = [0x04, // constant 0x04 prefix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the constants out of the class. Use corresponding --harmony
flags in the package.json
file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dionyziz There's a million flags, I went one time through them all but they seem to do something else entirely. I read a bit about ESnext and I understood that's a completely separate transpiler (?) that we're currently not using. Can you give me a pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Managed to do it without new flags. Check if the result is OK.
test/helpers.js
Outdated
@@ -82,9 +81,10 @@ var testHelpers = { | |||
}); | |||
}, | |||
|
|||
getOneOfTwoMultisigOutput: (originPubKey, destPubKey, value) => { | |||
getOneOfThreeMultisigOutput: (originPubKey, destPubKey, value) => { | |||
tag = (new TrustIsRisk.TrustIsRisk(new bcoin.fullnode({}))).fakePubKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the const
that is outside the TrustIsRisk
class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
test/helpers.js
Outdated
@@ -82,9 +81,10 @@ var testHelpers = { | |||
}); | |||
}, | |||
|
|||
getOneOfTwoMultisigOutput: (originPubKey, destPubKey, value) => { | |||
getOneOfThreeMultisigOutput: (originPubKey, destPubKey, value) => { | |||
tag = (new TrustIsRisk.TrustIsRisk(new bcoin.fullnode({}))).fakePubKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tag
-> fakePubKey
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
test/helpers.js
Outdated
return new bcoin.primitives.Output({ | ||
script: bcoin.script.fromMultisig(1, 2, [originPubKey, destPubKey]), | ||
script: bcoin.script.fromMultisig(1, 3, [originPubKey, destPubKey, tag]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tag
-> fakePubKey
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
test/tag-generator.py
Outdated
@@ -0,0 +1,27 @@ | |||
# Thanks to http://code.activestate.com/recipes/577821-integer-square-root-function/ for isqrt() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to new directory etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
test/trust_is_risk.js
Outdated
}); | ||
|
||
it("is a valid bitcoin address", () => { | ||
assert(bcoin.primitives.Address.fromBase58(tir.tag.toString("ascii"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bcoin.primitives.Address.fromBase58(tir.tag.toString("ascii")).should.be.ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
test/trust_is_risk.js
Outdated
var sinon = require("sinon"); | ||
var should = require("should"); | ||
var fixtures = require("./fixtures"); | ||
var assert = require("assert"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
No description provided.