Skip to content
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

Open
wants to merge 113 commits into
base: tx-creation
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
0927949
Rename "OneOfTwo" to "OneOfThree"
OrfeasLitos Sep 5, 2017
977df8d
Add provisional tag
OrfeasLitos Sep 5, 2017
f815dc0
Check trustisrisk tag in trust increasing MTX
OrfeasLitos Sep 5, 2017
e36468c
Add provisional tag
OrfeasLitos Sep 5, 2017
3a7eea6
Add tag to trust increasing MTX
OrfeasLitos Sep 5, 2017
6efd6fe
Turn tag from String to Buffer
OrfeasLitos Sep 7, 2017
f568294
Comment out "trustisrisk" tag creation commands
OrfeasLitos Sep 7, 2017
89b25a0
Random change
OrfeasLitos Sep 7, 2017
81e7df4
Comment out "trustisrisk" tag in test
OrfeasLitos Sep 7, 2017
f0b1880
Replace "equal" with "deepEqual"
OrfeasLitos Sep 7, 2017
826cd8e
Add tag to getTrustDecreasingMTX()
OrfeasLitos Sep 7, 2017
8c369e5
Add provisional "trustisrisk" tag
OrfeasLitos Sep 7, 2017
e6ec7f0
Add tag to getOneOfThreeMultisigOutput()
OrfeasLitos Sep 7, 2017
5d35bc8
Add publicKeyArray which contains "Trust is Risk"
OrfeasLitos Sep 8, 2017
f498dd8
Add public key to addres conversion
OrfeasLitos Sep 9, 2017
ac64cfc
Replace buffer.Buffer with Buffer
OrfeasLitos Sep 9, 2017
b2f2b31
Require crypto and base58 from bcoin
OrfeasLitos Sep 9, 2017
247dc43
Set i in {crypto,base58} as bcoin.$i
OrfeasLitos Sep 9, 2017
274ec2a
Use hash160/256 instead of ripemd/sha
OrfeasLitos Sep 9, 2017
ca938c3
Rename publicKey to pubKey
OrfeasLitos Sep 9, 2017
f695312
Convert step2 string to buffer
OrfeasLitos Sep 9, 2017
bfba382
Replace hash256 with two sha256
OrfeasLitos Sep 10, 2017
e07ad9d
Remove "bcoin." before "crypto"
OrfeasLitos Sep 10, 2017
439581e
Use "bcoin.crypto.hash256()"
OrfeasLitos Sep 10, 2017
d955c4f
Add "hash256()" type
OrfeasLitos Sep 10, 2017
13bee49
Add missing comma (,)
OrfeasLitos Sep 10, 2017
3b0a699
Add "base58()" type
OrfeasLitos Sep 10, 2017
0f75dd2
Make all steps' types buffers
OrfeasLitos Sep 10, 2017
3fc5f18
Replace "Address" with "bcoin$Address"
OrfeasLitos Sep 10, 2017
58aa495
Replace "bcoin$Address" with "Buffer"
OrfeasLitos Sep 10, 2017
6e925ef
Use tag creation from src/trust_is_risk.js
OrfeasLitos Sep 10, 2017
619274a
Remove commented out lines
OrfeasLitos Sep 10, 2017
821feaf
Rename "publicKeyArray" to "pubKeyArray"
OrfeasLitos Sep 10, 2017
73ec9ca
Rename "pubKey" to "fakePubKey"
OrfeasLitos Sep 10, 2017
9fb9eaa
Make fakePubKeyArray preetier
OrfeasLitos Sep 10, 2017
e4e9b9d
Add TODO comment to check tag
OrfeasLitos Sep 10, 2017
764dcc4
Replace tabs with spaces
OrfeasLitos Sep 11, 2017
33387a8
Turn tag from string to Buffer
OrfeasLitos Sep 11, 2017
fa7d3b8
Indent
OrfeasLitos Sep 11, 2017
95896bb
Add tag validity and content tests
OrfeasLitos Sep 11, 2017
152302d
Accept small identation
OrfeasLitos Sep 11, 2017
1ffb083
Use should instead of assert()
OrfeasLitos Sep 11, 2017
ba456d8
Use wallet.getKey instead of httpWallet.getKey
OrfeasLitos Sep 11, 2017
7675547
Replace equal with exist
OrfeasLitos Sep 11, 2017
c536458
Make fake public key preetier
OrfeasLitos Sep 11, 2017
d1a761a
Remove unneeded crypto and base58 vars
OrfeasLitos Sep 11, 2017
f0b0c69
Add "HDPublicKey" type
OrfeasLitos Sep 11, 2017
15d2500
Require "assert"
OrfeasLitos Sep 11, 2017
a2680bb
Replace "should" with "assert"
OrfeasLitos Sep 11, 2017
35ab49a
Play with Address to Public Key function
OrfeasLitos Sep 11, 2017
8fbcd6f
Add package-lock.json
OrfeasLitos Sep 12, 2017
037189b
Remove unneeded requires
OrfeasLitos Sep 12, 2017
3a9c031
Prepend "Address" with "bcoin.primitives."
OrfeasLitos Sep 12, 2017
88a190a
Remove HDPublicKey
OrfeasLitos Sep 12, 2017
78fed48
Add secp256k1
OrfeasLitos Sep 12, 2017
7f76659
Add fakePubKey verification test
OrfeasLitos Sep 12, 2017
86ea4bc
Remove ".ok" from "assert"
OrfeasLitos Sep 12, 2017
5457bda
Replace "fromString" with "fromBase58", comment
OrfeasLitos Sep 12, 2017
32085a9
Verify fake public key correctly
OrfeasLitos Sep 13, 2017
52cf7d6
Remove old fake public key
OrfeasLitos Sep 13, 2017
db912b5
Add tag generator
OrfeasLitos Sep 13, 2017
d96f244
Use valid fake public key
OrfeasLitos Sep 13, 2017
8235022
Remove TODO
OrfeasLitos Sep 15, 2017
caab3be
Use "should" syntax instead of "assert"
OrfeasLitos Sep 15, 2017
fb6b246
Add test that fakePubKey is a buffer
OrfeasLitos Sep 15, 2017
bb09e21
Simplify tag creation from key
OrfeasLitos Sep 15, 2017
d13061e
Add getAddress() type
OrfeasLitos Sep 15, 2017
2c60c69
Remove last test in tag
OrfeasLitos Sep 15, 2017
907170d
Add spv_node.js
OrfeasLitos Sep 17, 2017
37fb6f4
Add SPVNode types and refs to relevant files
OrfeasLitos Sep 17, 2017
6b0112b
Add pool.watchAddress() function type
OrfeasLitos Sep 18, 2017
63cc3b8
Add tag
OrfeasLitos Sep 18, 2017
1704b56
Add tag to Bloom filter
OrfeasLitos Sep 18, 2017
6cd6779
Add SPV node test file
OrfeasLitos Sep 18, 2017
8a89d63
Put tag in TrustIsRisk constructor
OrfeasLitos Sep 19, 2017
5aeb1fc
Separate type declarations and assignments
OrfeasLitos Sep 19, 2017
d572b77
Use tag from TrustIsRisk class
OrfeasLitos Sep 19, 2017
14f7cb7
Add console capability
OrfeasLitos Sep 20, 2017
a932ed3
Run npm install
OrfeasLitos Sep 20, 2017
df25421
Create short tag and public key
OrfeasLitos Sep 20, 2017
e393d85
Use short tag and public key
OrfeasLitos Sep 20, 2017
c93bcf3
Break down commands into smaller pieces
OrfeasLitos Sep 20, 2017
b814796
Rename tag vars for clarity
OrfeasLitos Sep 20, 2017
fb33b3a
Use tag instead of shortTag
OrfeasLitos Sep 20, 2017
3fe3c7e
Use public key instead of tag
OrfeasLitos Sep 20, 2017
3ebc94b
Reorder commands for ease of use
OrfeasLitos Sep 20, 2017
9488f7f
Replace public keys with tags
OrfeasLitos Sep 20, 2017
3c7517b
Group uncompressed together
OrfeasLitos Sep 20, 2017
1ed0e59
Hide spv_node.js temporarily
OrfeasLitos Sep 22, 2017
c291ec9
Use uncompressedFakePubKey instead of tag
OrfeasLitos Sep 22, 2017
e7cb2fd
Replace tag with fakePubKey
OrfeasLitos Sep 22, 2017
14efb8a
Remove "uncompressed" from fakePubKey*
OrfeasLitos Sep 22, 2017
16ef72c
Bring back spv_node.js test from hiding
OrfeasLitos Sep 22, 2017
7216d41
Replace "new Buffer" with "Buffer.from"
OrfeasLitos Sep 23, 2017
4f59609
Remove spv_node.js files
OrfeasLitos Sep 23, 2017
8639115
Remove commented out lines
OrfeasLitos Sep 25, 2017
f0eb7ca
Define bcoin, inherit full and spv
OrfeasLitos Sep 27, 2017
013c706
Align with other comments
OrfeasLitos Sep 27, 2017
3869c2b
Remove compressed version of tag
OrfeasLitos Sep 27, 2017
6fa62ab
Put comments in their own lines
OrfeasLitos Sep 27, 2017
d271530
Replace tag with fakePubKey
OrfeasLitos Sep 27, 2017
fc20631
Move to etc
OrfeasLitos Sep 27, 2017
14fdf56
Refer to etc/tag-generator.py
OrfeasLitos Sep 27, 2017
ed5f986
Stop using assert()
OrfeasLitos Sep 27, 2017
9f01cf9
Add tag stuff out of class
OrfeasLitos Sep 27, 2017
1e436e5
Use fakePubKey outside class
OrfeasLitos Sep 27, 2017
a079369
Export fakePubKey and tag
OrfeasLitos Sep 27, 2017
f41b005
Use ".Tir" to refer to TrustIsRisk
OrfeasLitos Sep 27, 2017
5cfacdc
Use exported fakePubKey and tag
OrfeasLitos Sep 27, 2017
b2bc8b6
Remove tag definitions from TrustIsRisk class
OrfeasLitos Sep 27, 2017
67b294c
Rename "Tir" to "TIR"
OrfeasLitos Sep 29, 2017
43a5e69
Remove redundant "NodeWatcher" definition
OrfeasLitos Oct 1, 2017
247c8b1
Fix comment appearance and typo
OrfeasLitos Oct 1, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
],
"flowtype/space-before-type-colon": 0,
"no-undef": 0,
"no-unused-vars": 0
"no-unused-vars": 0,
"no-console": 0
},
"settings": {
"flowtype": {
Expand Down
27 changes: 27 additions & 0 deletions etc/tag-generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Thanks to http://code.activestate.com/recipes/577821-integer-square-root-function/ for isqrt()
def isqrt(x):
if x < 0:
raise ValueError('square root not defined for negative numbers')
n = int(x)
if n == 0:
return 0
a, b = divmod(n.bit_length(), 2)
x = 2**(a+b)
while True:
y = (x + n//x)//2
if y >= x:
return x
x = y

x = 0x5472757374206973205269736b00000000000000000000000000000000000000
# 54:72:75:73:74:20:69:73:20:52:69:73:6b is the ASCII representation of "Trust is Risk"
p = 2**256 - 2**32 - 977
y = pow((x**3 + 7), (p+1)//4, p)

while ((y**2) % p) != (x**3 + 7) % p:
x=x+1
y = pow((x**3 + 7), (p+1)//4, p)

print("Found it!")
print("x is " + hex(x))
print("y is " + hex(y))
24 changes: 21 additions & 3 deletions flow-typed/npm/bcoin_vx.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@
type Hash = (string | Buffer);
type Network = any;

declare class bcoin$FullNode {
declare class bcoin$Node {
on(eventName : string, eventHandler : Function) : void;
getTX(hash : Hash) : Promise<bcoin$TX>;
getCoin(hash : Hash, index : number) : bcoin$Coin;
}

declare class bcoin$FullNode extends bcoin$Node {}

declare class bcoin$SPVNode extends bcoin$Node {
pool : bcoin$Pool;
//TODO Check if changes/additions are needed
}

declare class bcoin$Pool {
watchAddress(address : Buffer) : void;
}

declare class bcoin$Address {
toBase58() : string;
hash : Buffer;
Expand Down Expand Up @@ -73,6 +84,7 @@ declare class bcoin$KeyRing {

getPublicKey() : Buffer;
getPrivateKey() : Buffer;
getAddress() : Buffer;
}

declare class bcoin$Coin extends bcoin$Output {
Expand All @@ -83,7 +95,9 @@ declare class bcoin$Coin extends bcoin$Output {
declare module 'bcoin' {
declare module.exports: {
fullnode : Class<bcoin$FullNode>,
spvnode : Class<bcoin$SPVNode>,
script : Class<bcoin$Script>,
pool : Class<bcoin$Pool>,
primitives : {
Address : Class<bcoin$Address>,
TX : Class<bcoin$TX>,
Expand All @@ -95,8 +109,12 @@ declare module 'bcoin' {
Coin : Class<bcoin$Coin>
},
crypto : {
hash160(str : (string | Buffer)) : Hash
}
hash160(str : (string | Buffer)) : Hash,
hash256(str : (string | Buffer)) : Hash
},
base58 : {
encode(str : (string | Buffer)) : Buffer
},
}
}

Expand Down
Loading