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

Signature verification #16

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e540365
Implements a demo of the path selection in client
Oct 27, 2018
bcf2310
Implements the path selectio in the client
Oct 30, 2018
11273a6
Implements the parsing of the headers of the consensus
Nov 6, 2018
e55e0a0
Rewrite the code of the parser for the headers
Nov 10, 2018
3adb0b7
Implement the parsing of the authority section of the consensus
Nov 10, 2018
2b6b576
Implement the parser for the consensus
Nov 11, 2018
4947d92
Reorder files
Nov 12, 2018
fe9c9e4
Remove not working files
Nov 12, 2018
4b2aaaa
Merge branch 'master' of https://github.com/spring-epfl/lighttor into…
Nov 12, 2018
87b9f1c
Speed up the parsing by replacing the splicing of each line by an index
Nov 15, 2018
29f930e
Add a demo script for the signature verification
Dec 2, 2018
b1bf438
Add a demo script for the signature verification
Dec 2, 2018
240b43b
Crude signature verification, mimicking stem
wouterl Dec 3, 2018
4ff26dd
Merge branch 'signatureVerification' of https://github.com/spring-epf…
Dec 3, 2018
32e444e
Finish the demo of the signature verification
Dec 3, 2018
08122ee
TODO
Dec 4, 2018
fa83ba3
Delete get_JSON_of_descriptors.py
Dec 6, 2018
b5c8835
Delete consensusParser.js
Dec 6, 2018
b54ae82
Delete beautify_cons.txt
Dec 6, 2018
cf4281c
Delete test.consensus.txt
Dec 6, 2018
bbb62f9
Delete parser.html
Dec 6, 2018
f11db0a
Merge branch 'signatureVerification' of https://github.com/spring-epf…
Dec 6, 2018
1a7ac3b
Merge branch 'master' of https://github.com/spring-epfl/lighttor into…
Dec 6, 2018
b59ed70
Move keys to tool and add new function to it
Dec 6, 2018
caa28ac
Move keys.py to tools and add a new function to it
Dec 6, 2018
c44cc74
Fix small issue in keys
Dec 6, 2018
5473884
Implement the signature verification in JavaScript
Dec 8, 2018
bf84c15
Move the signature code to its own file in lnn
Dec 15, 2018
4395792
Implement a tool to download the chutney's key
Dec 15, 2018
d3cea67
Move the js signature code to its own file
Dec 15, 2018
77e9bc2
Delete path_selection.html
Dec 20, 2018
497c30c
Fix keys download for chutney
Dec 26, 2018
f88e527
Merge branch 'signatureVerification' of https://github.com/spring-epf…
Dec 26, 2018
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ local-relay-*
ubuntu-bionic-18.04-cloudimg-console.log
.vscode/
.idea/*
descriptors.json
37 changes: 37 additions & 0 deletions examples/signature_verification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import requests
from tools.keys import get_signing_keys_info
import os
import json
from lightnion import signature

if __name__ == "__main__":
# The url of one of the TOR's authority node to download a consensus
url = "http://193.23.244.244/tor/status-vote/current/consensus"

# HTTP request
print("Request for consensus")
request = requests.get(url)

if request.status_code == 200:
raw_cons = request.text
else:
raise Exception("Consensus could not be downloaded")

# Get the keys
print("Get the signing keys")
path = "./tools/authority_signing_keys.json"
if not os.path.exists(path):
print("Download keys")
get_signing_keys_info(path)

with open(path, "r") as file:
print("Get keys from disk")
keys_json = file.read()
keys = json.loads(keys_json)

print("Stat verification")
# Verify consensus
if signature.verify(raw_cons, keys):
print("The consensus has been verified!")
else:
print("The consensus has not been verified")
1 change: 1 addition & 0 deletions install-vagrant.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ if ! [ -d "chutney" ]; then
cd /home/vagrant
git clone https://github.com/torproject/chutney.git
cp /vagrant/tools/chutney/small-chut chutney
sudo chown -R vagrant:vagrant chutney/
cd chutney
git apply /vagrant/tools/chutney/sandbox_patch
else
Expand Down
3 changes: 2 additions & 1 deletion js-client/config.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SOURCES=\
src/header.js src/endpoint.js src/get.js src/ntor.js src/relay.js src/onion.js\
src/io.js src/post.js src/stream.js src/util.js src/api.js src/export.js
src/io.js src/post.js src/stream.js src/util.js src/api.js src/export.js\
src/signature.js

BUNDLELICENSE=LICENSE.bundle.txt
BUNDLES=\
Expand Down
47 changes: 47 additions & 0 deletions js-client/demo/authority_signing_keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"27102BC123E7AF1D4741AE047E160C91ADC76B21": {
"pem": "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAp/+6CgR/ptxWIt6uLCLt0t4e+yCq9i7MOcmcZlWHzIsP+sJxsPJO\njqg5MycQsWt4wMUGCWj5ag+cozTGClfZ7dSxEzee5DoLa65RFK9ymFAnhUNs97sx\nF5CionrnUdjMO4MShALJgr7tXZ7I2/mwAG8foszEcl+dWhcaQio3WaT5rK/hLpiT\nURgYmieXaZWm1kLraI5DWnRY7GdFyWdBJKboStYpoJuYexUL7lbG7u7wqEG25N4+\nyFt8fiS7yjdlCf0WJRZlwmTLz87nn4Sqb/nYeqXKmT88LBs9D1csd8KgwOgyTkfb\ne7v+dTZSkqZYd0QXsqqxynZVKk63vWSXHwIDAQAB\n-----END RSA PUBLIC KEY-----",
"modulus": "21207900472617270540291090462634510776478759476008921875436024570091185685857370141779427850344369292401765230842451466054682268246131672256547641845952822811975082225102572224073211324909709492589760695577403844759076364561735398977349177172414228552576770873237722810617419132994872064079794571898305875963806989099723938100428541324408007233130220033277352943944968311792939088620429125218571674914891933690546975034757477728185646893290446899022846628749848710338146862197061535769736327360349510863827468525448117272947043596280500831295709824889886168034041872063600595333450323037034017676951268469804085057311",
"exponent": "65537"
},
"ED03BB616EB2F60BEC80151114BB25CEF515B226": {
"pem": "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAxtiD0MuGDfRBqibc06jZXSPoF5s0ToVSrVfNO75dYvfM9zabW+1q\nEP18KUFxeShMqd2mmj685XbGnGX49I5gjzezjaIMcszpiPHQNmr9McnX97yR62YJ\nXKy0i6lvKXLUb5y8V5HmdqKQ8HyCqsRcYFTFrHNCWC+oIhRrqpeQ5kSIdWiO2HCt\nrzx9mAgGLRNFTy+EsxAFzuHaJVV5U7g/G4RMYXMP514aSpJVNgd2kdkXWsSIQ4HX\na/vRNECuBQyJ1YpHySqqpdOogJxFot8oW/WkmFTGh/amJjMrTUNGgDMD5mpwMCRV\nifA4hQzvJljkmfGMwgU8kYraMLDHvKzu4wIDAQAB\n-----END RSA PUBLIC KEY-----",
"modulus": "25101951862070083571886329690165580667903430631498488389553987848052827386538420920307075237020485734439515013054583549895893070240169193022361980001685958741762208735824248159989953186762287968479911624133436303763691345917339411513859435865155233131515966334208717187592268766897878310977654703655400652795672949647015931435663525963924621262685764458523556134922131041004678006208280108491224809292815540658088971370812404554391016937147532021985934004788780120801499573343453129912529422962747042141175965773185912452224881688186035674671567061836600201067935463484628836185831010587912521456713960787800765558499",
"exponent": "65537"
},
"49015F787433103580E3B66A1707A00E60F2D15B": {
"pem": "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAxkBC67odE7xGJSA8ZvDFMDVXwYN79Uu3NUqSnW4/PwQyuNAYlPRE\n0pJotIb91Gg4mBTAYoZdWAeLLUpZSpoRXe9tNibDn9iP9gWPn10CNpMAuzdFDrDK\n34P4I8T8aNPe0GhNKx2UjWrZ7r84O/loU1AdxYlPsPIwmZTe94HRgR/A7u/i+QXy\nU9A+y/DLhJwA5T2baAuT931HfLRJ7pQuJB7JbRheCChbsFD3JKQRUV44fZuLtU0k\n3v7l0JyTMvi7/44oD7upPL0xicHZJLqbjQmVoPTHt3HtCLB9NagrtQt6emN0bMT5\n+mNIqHPcahaHk81PGxUBdVfFDkyHnS6SZQIDAQAB\n-----END RSA PUBLIC KEY-----",
"modulus": "25026872865304918268460350539495681847399937565249397284249245543567155399752699347611496745632536945217651612682841022863287917924683790500569769667922363883104620973664632072995797202091223460694090829967451290434007948049772940550636924954142646297320418129999055073346390745210312098996805002038277543160260805921630711453237636334195090649275716796084062833827071634563027087850474896704428616194816770068463891527487263850473447254513161232194490702621845738589053216747985323438819744393877671537064062612051147641330215180998800226471259596882768279882420454439719685917472447128100836571550430481703198691941",
"exponent": "65537"
},
"EFCBE720AB3A82B99F9E953CD5BF50F7EEFC7B97": {
"pem": "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEA5KK/zS8zPPinA7QGbcPEPH90hoagF9EmvvgYjQ8m2L2g15/3WrdQ\nJ8Ue0n0JaOb2crZEJ+d1IwbvX9mFpFx4xNsGA3CPg1/RAHwvmB7HctGOO39Y+I4h\nKLyV4AWVPXb7uvWr8Stec9sW6QLwkz2bhW61DvBlCapBzQPPqm2R+dNCUXE6ATQv\nse8jzggu1YHKk5GSLrXUvuWKbZFBb5WKaZjRXAXt3I9jSS61SG6rxJmM7uujfrkF\nUOmb5T83oWCU1zgjyz5bs0j39A7K+FxQPlMUYUe8eyo0dNu6bwSwnm0C6JGmEZXn\nee+KeQd6Kai8++uOiPWxfqIpSD8XkF0PkwIDAQAB\n-----END RSA PUBLIC KEY-----",
"modulus": "28862588166050238210985553338886213502050511859372313324373840636794954665490432029718068829301801225013424063150836448922568767488636215824260130301460582265654061387600567187155612741175412837265808733428607846525681255527979612582580516118682572598274952922789012046258158072294201480216138759979366240772150171487186878129858403354154154287873615461566844028340306392744718046302332527366047550317202766340414423011389087984062969440301662157912584278917033003712298729764207267207960991246872361168884197038755365560064819816571777977857427171761584324046262702146304470895968803594005048503853105285991510118291",
"exponent": "65537"
},
"0232AF901C31A04EE9848595AF9BB7620D4C5B2E": {
"pem": "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAwRiTWBRdFfg4vHcfyac9UAIB+V6EILMiOS1NgAK5OozV7QzZGgZF\nKJrghP4Pk9W6+KSQr/YRXmf+sMh/6SP9FfUxqp/JXb/HMYqVLW+r3KXdaOy/WDuc\nEIxpGU5gr9Tc1MxvtcumwtB579Su9QPclTQNc2ch3WaG5Aa4ktHd5PC0m9NT6ASP\nZju1ckXny39AIqCrqtARy5VeJiu04W/e7Efq43+Gf/YwPNPJcqqipnyjNFpwaej2\nyuSas1YJVEtEj65YTA4jQfl5EMHAxu4HSsWAqlkWfEkHgxfHuS5TWFLT1Pf0j8xM\nSV77/nMpt+TniqcpsCpyeXTfvo/E5Hbi8wIDAQAB\n-----END RSA PUBLIC KEY-----",
"modulus": "24376111520103734479859725747003821222774463555435402912758694254087811382586570367348482673322101677314310375877378130981125388519492011500743993047003022235493876585232971758259843135852820821861846073657232195054734041548624051150015853570309683252647182578473831757242931283795856985204637900123692583292614955000328855266561871015740369227045680778200681802921785208577088639652198213091843101913066201251926901841650340132506187307738835637348991601556426493939612202643228962391539239689707773543003647252952142496489794601781392350148076884319247608982666284618771011668982876606740977624112110628253394723571",
"exponent": "65537"
},
"E8A9C45EDE6D711294FADF8E7951F4DE6CA56B58": {
"pem": "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAysk7LzdL18q6bpMBI+2di41VKxwOJZ+eAr/B/OsOHlf1A6I2knhX\nj6P5+7GTUdYF6kCO0eP690t0EczPUnDdKoLkPUIXgkI9cNq6dsbSgL7fjLLK+EGT\n59uFm9pcZHQPA/Nq10Wecli8+AiGmBiIVfShXDXHGSwU7KwTkDQSdIA5DRBMJYLD\nPtve4IASn620vUCn9MWRblTra/W8Vh5Nz7T90jOa+iHIRQqHgwnh+/sVScDYzXdW\nX9cogPZttaGR8nwFXPBW4TkkiU4KvV1DlqoiEpgIQTz1UPwFOMgbERL0y1lav3/+\nwlEC/AhenWrxwywMhkkd7HdkKey48tZp4wIDAQAB\n-----END RSA PUBLIC KEY-----",
"modulus": "25599368400925280689990935444677883212032737425067709254519411772234200759530391361641312412663511545511712177041939245107708295229389565102356151077539927594284421457775384677778173390483018547684379757960190095004903204195874124580470103687040270761548098849424172121812119134463272086227439078241716455586082121903407441950704760647809019432428431493918980568140286778546441284928067306073319018484435635103483559899790271118247381492275108309740402003227921645129967761153928725280647048162745961922290878371807683414883880758458136192932276108330213409578155784568096214434547146827779775057827275507873455958499",
"exponent": "65537"
},
"D586D18309DED4CD6D57C18FDB97EFA96D330566": {
"pem": "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEA6jmbwb05+rNQFnFbK5zEhxAgomIXpDWcqGhuuEKxDhoLPb5LqqgN\nUcsSOpNYnS2ijCzVmQFwWOp7BNgj3mebV75X5bbGxZtCRZ2Krr6vyIAJuKTPkR/l\n8pE80aH5L+YeOGplVNO1R0IA5IN0VtFlcEkkgaWPbf1y7dYUvF/e9jI3Bp0Vw4ab\niydboYMKvCMhzBpybMZzWwyAnhkZiLQcbZKgn3W/lC5cz6X0y5Q3Ckm7NWMkQPl1\nHGSOBMJREax94VbvCz/DW0hMRpe3+d8gOYuVocc8ko1RiBnELsU1/B1Zjj0dNZMI\nxtGHSKpHqz5Z68AXEEErk7HQDgCbbd6JkQIDAQAB\n-----END RSA PUBLIC KEY-----",
"modulus": "29568171135185126694590032987868190193920793152896823772905546519789716916735365915466121830421468909482547769227885491015184496277627540133447037693021243239690708697355437143999552506982938024345738719432989519174410866008340247218379629211076384823361173362020808538390115071263842383605584684569901183652784648242481470688723447071498283452543445568201564480007648569579777594018518157664710720604305588067523546346291912020254312633817279198770197086260238655205459505535315952208050453004417168557103788306075443679204955794553985784872701610339051425729813812228752876816974632144821024418155177751243564943761",
"exponent": "65537"
},
"23D15D965BC35114467363C165C4F724B64B4F66": {
"pem": "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAptMtMuzYJdgDZ56PvGTT0wYHrNn5zzB26ZTletfxkJ6yj5QKdYTp\nh5DuXSlsQrrmy7Gu3rLlwJVfBEu9YlHZD2h8FZg6s+L3Zuyaoj7ZmQdeXLmMbIFr\nc2S3wi34MY1tgowBrCzHhMMWkuD7jicEV4oU+jDggyq1GR/+Gs1tKIIvG4oYMHHe\nI10JSHO4gW1L9uVep3iZ5d6yBVYL+AnIfNfiv5V2Q17Xj93rShJ2ybIdA72gP0h4\nV1prG6y2MZyYgSxcuW/fwvuhzJYDen/GOpB3roh6LSmJ6OUIAang6d8gwp+lLxI3\n5ix4tUDnAi8BWD+HE0OSBCCuPrQ1m0OjlQIDAQAB\n-----END RSA PUBLIC KEY-----",
"modulus": "21059693666432822966759918477847160606008910392631349307288771956263175126610232316683703071401054109210860832686976681943998338957304682507200080538027182474990360368766256316217132561932495292305994846361704557863115268806219869100933897338153820086451607776959532827436197181045155932147225439044314816871529705011551233770726720931069288063069672095585027523435549204774486556319888475374563529846791894281349723758567591012063856588917047800168953979784813121918354143683329717484479340824896926682177756500290834416788650765527164386009134451971189074841563202708186658189057567842380676625970184360435317449621",
"exponent": "65537"
},
"14C131DFC5C6F93646BE72FA1401C02A8DF2E8B4": {
"pem": "-----BEGIN RSA PUBLIC KEY-----\nMIIBigKCAYEA5z6RtHOU337fww+Va7hVwVpYlo8pAQ+ABybFz+WpKi2IiPbfhlxZ\nVRewVZdj/sjux3Xtw+Q62lSEajtXBZy1qvUprAV0Cb/2L85Upei8qRwpyhGH5WiQ\npoIPoERUzULU2ybmhP3ADejv0GgrvBuIMFISwm4zAYFeWDUJij/OqSDwwcf5ZplK\nwL+9RmEj8xGLYz2bvI1h/7B5anFBHMxj7VcWHG8gfQQiXPYKHojHgOSZqaPZnUJm\ncTplPcRW+LTTgNmxs76Sj200RVVpvLWQfhfAbaOMp4qTyIm6abj156webkf0DC4Y\nNtnomsvKMesqp9llRPASj+KmyGPz32RXjCACE5l11yMvVlFnhQuZ8H2gJHfOZBOz\n5GUQK4QY0eel3EgonmbhGLqC4U2x0yzyaHT2+BJvc9njhty16alGqnENmeMVXeIn\nJHydMtZRPDwivdkchd2/hkyLH63G8OleVqrcmnQ+Q8Sy8EoYofsnj6JDdGMBL+lA\n/tZArSK7O+JhAgMBAAE=\n-----END RSA PUBLIC KEY-----",
"modulus": "5247808262750847539956779729950289898853421932815908545401532015282281382981777807851264832411975000018697005047750203895504198253593749706517758191292544569963386053993375573545749117764935244607990769053912904780472987456361669803168251111963300553113537162327273039988435975982367234321291046077731777976256743308986548075196009041612061252099582016785017745746859395670509511408543271530965628365870383307187939760651626727087025438306848763511151494867247827547147642107613437248551207317694857369033160629708782130357533746256928109947709214803803198883127341032333625708222443490158919617574810401411186543610393593632088156683797640729138594987003331050754483919424537243839478204265822752374392319284715951560204397935057166979515980942605198353638000257059353849900886111058368384088134748864907802954718613612270874850635175382624802758013239637861803579529822913926525524619664688240652515661605859934652121997921",
"exponent": "65537"
}
}
33 changes: 33 additions & 0 deletions js-client/demo/descriptors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<html>
<head>
<script src="lightnion.bundle.js"></script>
<meta charset="UTF-8">
</head>
<body>
<pre id='loaded'>Nothing to see here!</pre>
<pre id='log'></pre>

<script>
lnn.open('localhost', 4990,
function success(endpoint)
{
lnn.get.consensus(endpoint, endpoint => {

if (endpoint.state != lnn.state.success)
return
document.getElementById('loaded').innerHTML = '(channel opened)'

lnn.get.descriptors(endpoint, endpoint => {
console.log(endpoint.consensus)
console.log(endpoint.descriptors)
})
})
},
function error(endpoint)
{
document.getElementById('loaded').innerHTML = '(unable to open)'
})

</script>
</body>
</html>
15 changes: 13 additions & 2 deletions js-client/src/endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ lnn.endpoint = function(host, port)
guard: http + "/guard",
socket: ws + "/channels",
channels: http + "/channels",
consensus: http + "/consensus"}
consensus: http + "/consensus",
descriptors: http + "/descriptors"
}

/**
* Captures the state of a channel, returned by {@link lnn.open}.
Expand Down Expand Up @@ -149,7 +151,16 @@ lnn.endpoint = function(host, port)
* @readonly
* @default null
*/
consensus: null}
consensus: null,

/**
* Consensus obtained by {@link lnn.get.descriptors} upon request
* @name endpoint_t#descriptors
* @readonly
* @default null
*/
descriptors: null
}

return endpoint
}
22 changes: 22 additions & 0 deletions js-client/src/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,25 @@ lnn.get.consensus = function(endpoint, success, error)
rq.open("GET", endpoint.urls.consensus, true)
rq.send()
}

/**
* Perform GET /descriptors
*/
lnn.get.descriptors = function(endpoint, success, error){
var rq = new XMLHttpRequest()
rq.onreadystatechange = function(){
if(rq.readyState == 4 && rq.status == 200){
endpoint.descriptors = JSON.parse(rq.responseText)

if(success !== undefined) success(endpoint)
}
else if (rq.readyState == 4 && error !== undefined){
error(endpoint, rq.status)
}
}

rq.open("GET", endpoint.urls.descriptors, true)
rq.send()
}


1 change: 0 additions & 1 deletion js-client/src/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ lnn.post.create = function(endpoint, success, error)
{
info = lnn.ntor.auth(endpoint, info["auth"], info["data"])
}

endpoint.id = info["id"]
endpoint.url = endpoint.urls.channels + "/" + info["id"]
endpoint.path = info["path"]
Expand Down
Loading