136
Technical Support / Re: [BitShares 2.0 Technologies] Collateralized Bond Market (Discussion)
« on: June 09, 2015, 04:21:54 pm »
We will have an options market also?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
You need the withdraw conditions on the blockchain to have a timestamp condition built into them to "lock up the funds" and the structure of these transactions is not compatible with what we have planned for Monday.
That said, the value of this kind of micropayment channel is not lost on me and we are looking into options.
Without the "valid_from" system, after a session has been broken and all settling transactions expired, the two parties are forced to come to a mutually acceptable agreement, or neither gets anything.
Using the "valid_from" field, once the "valid_from" date passes, the client can claim the entire pot, or whatever percentage was pre-arranged before the session took place.
This approach will not work with BTS.
I think the risk is pretty low without "valid_from", and as I said periodic settling keeps it low. Even with "valid_from", you're giving one party disproportional leverage over the other for settling, not actually solving the problem.
I don't think low delegate participation is a serious risk factor in this, and it could be managed by decreasing the update frequency a bit.
If the client loses connectivity, the server will still want to be paid, and should therefore settle using the last transaction. Thus connectivity loss is only an issue if both lose connectivity, or if the remaining connected party refuses to settle. This risk can be mitigated by periodic settling when the stakes reach uncomfortable levels.
With transaction expiration. Ideally, both parties should first sign a transaction distributing the funds back to the client expiring in say a minute, then with that in hand, the client funds the multisig. After 30 seconds (and every minute thereafter), the settling transaction is updated. If one party fails to update, the other settles by broadcasting the last settling transaction before it expires.
The update frequency can increase and decrease depending on value of payments and trust between parties. The initial settling transaction could also include a connect fee to the server to prevent theft of the first 30 seconds service.
I agree this is a great idea. People can always spam the network with invalid transactions with or without this, but they shouldn't be propagated, and the sender should be disconnected when this happens.
I don't think we need "valid_from" for this, just transaction expiration. After funding the multisig, the parties just need to keep updating signed settling transactions shared between them. If the previous settling transaction is about to expire and you don't have a new one yet, broadcast the last one.
Micropayment channels like this are also perfect for mesh networking.
Same situation that we already have with the expired field treatment in the evaluation state.Xeroc, there is no need to store the transaction. The node can validate it (in the transaction validation state) and reject it if the condition is not met without storing anything.That would allow spamming/ddosing of the network, wouldn’t it?
would this work for recurring payments too?Favdesu, I can't see it working for recurring payments.
struct transaction
{
fc::time_point_sec expiration;
optional<fc::time_point_sec> valid_from;
optional<uint64_t> reserved;
vector<operation> operations
....
#!/usr/bin/python
import sys,os
sys.path[0:0] = [os.path.join(os.path.dirname(os.path.abspath(__file__)), '../lib')]
from hashlib import sha512
import bitcoin as b
from helper import *
if len(sys.argv) < 4:
print 'memo_enc.py message from_pub to_pub'
sys.exit(0)
_message = sys.argv[1]
_from_pub = sys.argv[2]
_to_pub = sys.argv[3]
def compute_encrypted_memo(message, from_pub, to_pub):
print 'Compute encrypted memo'
print message
print from_pub
print to_pub
print hack_info
# Compute shared secret
def compute_shared_secret(pub, priv):
Xk = b.encode_pubkey(b.multiply(pub, priv), 'hex_compressed')[2:]
return sha512(Xk.decode('hex')).digest()
#TODO: remove
priv_key = b.random_key()
ss = compute_shared_secret(decode_pub(to_pub), priv_key)
fpub = decode_pub(from_pub).decode('hex')
if len(message) < 19:
message = message + chr(0)*(19-len(message))
message = message[:51]
memo_data = fpub + chr(0)*8 + message[:19] + '\0'
if len(message) > 19:
memo_data += message[19:19+32]
print 'voy aca'
length = 16 - (len(memo_data) % 16)
memo_data += chr(length)*length
from Crypto.Cipher import AES
obj = AES.new(ss[0:32], AES.MODE_CBC, ss[32:48])
cipher = obj.encrypt(memo_data)
res = {
'shared_secret' : ss.encode('hex'),
'memo_data' : memo_data.encode('hex'),
'one_time_key' : encode_pub(b.encode_pubkey(b.privtopub(priv_key),'hex_compressed')),
'encrypted_memo_data' : cipher.encode('hex')
}
return res
#res = compute_encrypted_memo(_message, _from_pub, _to_pub)
#import simplejson as json
#print json.dumps(res)
#!/usr/bin/python
import sys,os
sys.path[0:0] = [os.path.join(os.path.dirname(os.path.abspath(__file__)), '../lib')]
from hashlib import sha512
import bitcoin as b
from helper import *
if len(sys.argv) < 4:
print 'memo_dec.py one_time_key encripted_memo_data priv_key'
sys.exit(0)
one_time_key = sys.argv[1]
encripted_memo_data = sys.argv[2]
priv_key = sys.argv[3]
# Compute shared secret
def compute_shared_secret(pub, priv):
Xk = b.encode_pubkey(b.multiply(pub, priv), 'hex_compressed')[2:]
return sha512(Xk.decode('hex')).digest()
ss = compute_shared_secret(decode_pub(one_time_key), priv_key)
from Crypto.Cipher import AES
obj = AES.new(ss[0:32], AES.MODE_CBC, ss[32:48])
plain = obj.decrypt(encripted_memo_data.decode('hex'))
inx=0
def extract(_len):
global inx
tmp = plain[inx:inx+_len]
inx += _len
return tmp
_from = plain[inx:inx+33]; inx+=33
_from_sig = plain[inx:inx+8]; inx+=8
_message = plain[inx:inx+19]; inx+=19
_type = plain[inx:inx+1]; inx+=1
if len(plain) > 33+8+19+1:
_message = _message + plain[inx:inx+32]
import string
_message = filter(lambda x: x in string.printable, _message)
res = {
'shared_secret' : ss.encode('hex'),
'memo_data' : plain.encode('hex'),
'from' : encode_pub(_from.encode('hex')),
'from_sig' : _from_sig.encode('hex'),
'message' : _message,
'type' : _type.encode('hex')
}
import simplejson as json
print json.dumps(res)
import bitcoin as b
import base64
from config import *
import binascii
PROD_PREFIX = 'BTS'
DEV_PREFIX = 'DVS'
prefix = DEV_PREFIX if is_test() else PROD_PREFIX
def is_valid_address(addy):
try:
address_to_hash(addy)
return True
except:
return False
def is_valid_pubkey(pubkey):
try:
decode_pub(pubkey)
return True
except:
return False
def address_to_hash(addy):
assert(addy[0:3] == prefix), 'Invalid prefix'
data = b.changebase(addy[3:], 58, 256)
assert(len(data) == 24), 'Invalid length'
hval = data[:-4]
assert(data[-4:] == b.ripemd.new(hval).digest()[:4]), 'Invalid checksum'
return hval.encode('hex')
def pub_to_address(pub):
r = b.ripemd.new(b.hashlib.sha512(pub.decode('hex')).digest()).digest()
c = b.ripemd.new(r).digest()
return prefix+b.changebase(r+c[0:4], 256, 58)
def decode_pub(epub):
print 'EPUB %s'%epub
assert(epub[0:3] == prefix), 'Invalid prefix'
data = b.changebase(epub[3:], 58, 256)
assert(len(data) == 37), 'Invalid length'
hval = data[:-4]
assert(data[-4:] == b.ripemd.new(hval).digest()[:4]), 'Invalid checksum'
return hval.encode('hex')
def encode_pub(hexpub):
h = binascii.unhexlify(hexpub)
return prefix + b.changebase(h + b.ripemd.new(h).digest()[0:4], 256, 58)
def recover_pubkey(msghash, signature):
sig = base64.b64encode(signature.decode('hex'))
return encode_pub(b.encode_pubkey(b.ecdsa_raw_recover(msghash,b.decode_sig(sig)),'hex_compressed'))
Any word on publishing the apk to f-droid ? I could test the app if it lands there too and begin spreading the gospel around here as well.