Dr. habil. Radu State Radu.state@uni · Presentation of the tensors •A tensor is a...
Transcript of Dr. habil. Radu State Radu.state@uni · Presentation of the tensors •A tensor is a...
• MasterofScience,JohnsHopkinsUniversity,USA(ComputationalBiology),1998
• Ph.D,INRIA,France(NetworkSecurityandManagement),2001
• Habilitation,Université deLorraine,France,2008• SeniorResearcheratINRIA,France• ProfessorofComputerScience,TelecomNancy,
France• SeniorScientistatSnT,UniversityofLuxembourg
RaduState,SeniorResearchScientist
Overview
• Smartcontractsandblockchain 101• Programmingframeworksanddeployment• Differentviewpointsforlookingatsmartcontracts
• Graphmodeling• Tensormodeling• Holographicvisualizations
• Security• Conclusions
NickSzabo’sdefinitionfrom1994
• “A smart contract is a computerized transaction protocol thatexecutes the terms of a contract.
• The general objectives are to satisfy common contractual conditions(such as payment terms, liens, confidentiality, and even enforcement),minimize exceptions both malicious and accidental, and minimize theneed for trusted intermediaries.
• Related economic goals include lowering fraud loss, arbitrations andenforcement costs, and other transaction costs”
Whatisconsensusandwhydoweneedblockchain(s)?
• StateMachineandtransactions
• Trustbydistributedanddecentralizedcomputing
• Consensusshoulddealwith• Failures• Censorship
PermissionedNonPermissionedDL
Encodingstateontheblockchain
• thestatelessUTXOmodel,accountbalancesareencodedintopasttransactionrecords
• accountmodel,whereaccountbalancesarekeptinstatestoragespaceontheledger.
Whatdoyouneedtowriteasmartcontract?
• Aprogramminglanguage inwhichtowriteyourcode• Acompilerwhichtranslatesasmartcontractintobytecode• Avirtualmachinethatexecutesthesmartcontract• Atrustedinfrastructurewhichexecutesthevirtualmachine
WritingasmartcontractinGolang (HyperLedger)
• Asimpleprogramthatreceivesthreeinputnumbersa,b,xandupdateswitha=a-xandb=b+x
• Example:Ifa=10,b=7,x=4thenaftertheexecutionweget:a=6,b=11• InPythonthislookslike:
1. a=input('Enterfirstnumber:')2. b =input('Entersecondnumber:')3. x=input('Enterthirdnumber:')4. new_a=a-x5. new_b=b+x6. print('Thestatusof{0}and{1}is{4}and{5}'.format(a,b,new_a,new_b))
Initializingthechain…..
1. a=input('Enterfirstnumber:')2. b=input('Entersecondnumber:')
Initializingthechain…..
Writingdatatotheblockchain
Doingtwoarithmeticoperations…
Readingdatafromtheblockchain
Doingtwoarithmeticoperations…
new_a=a-xnew_b=b+x
print('Thestatusof{0}and{1}is{4}and{5}'.format(a,b,new_a,new_b))
Callingafunction….
Andstartingthechain….
Additionalcodenotshownbutcompleteexamplecanbefoundathttps://github.com/IBM-Blockchain/example02/blob/v2.0/chaincode/chaincode_example02.go
WhatisDocker?
git clonehttps://github.com/yeasy/docker-compose-filescddocker-compose-files/hyperledgerdocker-composeup
Cloudreadyservices(IBMBluemix)
ResearchatSEDAN@SnT onSmartContracts
• Canwemodelcomplexfinancialprocesseswithsmartcontracts?
• Howcanweanalyzedeployedsmartcontracts?• AMLusage• Eco-environmentinsights?
• Canwepredictactivitiesforsmartcontracts?
• Canwesecuredeployedsmartcontracts• Withoutchangingtheconsensusalgorithm
Sender ReceiverBlockchain
Database
SmartContract
Zakaah App
DistributeZakaah
Register
BuyZakaahCoins
RegisterManual
Automatic
SupportforEthereum andHyperledger
EthicalFinanceandfulltraceability
Canwelabelasmartcontractjustbylookingatitbytecode?
0x6060604052361561003d576000357c010000000000000000000000000000000000000000000000000000000090048063a2e620451461013d5761003d565b61013b5b600060149054906101000a900460ff1615156100605761005f610151565b5b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051809050600060405180830381858888f1935050505015610133577f23919512b2162ddc59b67a65e3b03c419d4105366f7d4a632f5d3c3bee9b1cff600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1610138565b610002565b5b565b005b346100025761014f6004805050610151565b005b6000600060006000732bd2326c993dfaef84f696526064ff22eba5b36273ffffffffffffffffffffffffffffffffffffffff166316c72721600060405160200152604051817c0100000000000000000000000000000000000000000000000000000000028152600401809050602060405180830381600087803b156100025760325a03f11561000257505050604051805190602001509350839250600060149054906101000a900460ff1615801561020c5750622595184310155b156102455760009150600090505a9150315a9050601b8183031415925082506001600060146101000a81548160ff021916908302179055505b83156102da578215610295577332be343b94f860124dc4fee278fdcbd38c102d88600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055506102d5565b733b5c1ad02d408d7752ec589be440582c79c4a527600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b610365565b82156103245773029a6b91931c768a3762ac9b2f0b25212d13d37a600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff02191690830217905550610364565b73c0d332838f14ef42fcde1cf2518c427ddb676729600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b5b5b5050505056
Canwelabelasmartcontractjustbylookingatitopcode?PUSH10x60PUSH10x40MSTORECALLDATASIZEISZEROPUSH20x003dJUMPIPUSH10x00CALLDATALOAD……DDMSTOREPUSH10x40MLOADDUP2PUSH290x0100000000000000000000000000000000000000000000000000000000MULDUP2MSTOREPUSH10x04ADDDUP1SWAP1
Canwelabelasmartcontractjustbycommentsforums?
Usingcodesimilarityandsomelabelstolabelunknown1470609smartcontracts
Extracted998verifiedcontractsfrometherscan.io
Work/TokenextractionBytecodehashingusing
contexttriggeredpiecewisehash
ClusteringusingK-medoids andaffinity
propagation
Whatlabelsdoweget?
ManualinspectionoftheclustersContract ClusterCenter
label1 label2 label3
Presale presale tokenContest contest votingWithdrawDAO dao withdrawfairandeasy dice pyramid simpleProtectTheCastle dice tokenDouble dice
andadvancedvisualization
Aloveforgraphs….
WemapEthereum accountstonodes
Transactionaremappedtoedges
Metricsongraphs
Long,mediumandshorthistorygraphs
Centrality
Address Comments Additional Information
0x32be343b94f860124dc4fee278fdcbd38c102d88 Poloniex HotWallet Poloniex isapurecryptotocryptoexchangebasedintheUnitedStatesandthelargesttraderofEther.
0x9e6316f44baeeee5d41a1070516cc5fa47baf227 shapeshift.io, platformthatallowsuserstoexchangedigitalcurrencieswithoutanyregistration.
0xaa1a6e3e6ef20068f7f8d8c835d2d22fd5116444 ReplaySafeSpolit transitiontothehardfork. Currency dividedbetweenETH(chainfollowedbytheFoundation)andtheETC(thecommunityefforttocontinuetheno-forkchain). Itisthe4thintermsofnumberoftransactionswithatotalof184743edges.
0x120a270bbc009644e35f0bb6ab13f95b8199c4ad: shapeshift.io, shapeshiftexchangeasanintermediateaddressfortradingBitcoinswithEther.
0xbfc39b6f805a9e40e77291aff27aee3c96915bdd Poloniex syncanyaccountsthatwouldhavelostETHduringthehardfork.
0xbb9bc244d798123fde783fcc1c72d3bb8c189413 TheDAO Initiallyraisingahugecapital and victimofanattackleading tothehardforkintheEthereumBlockchain.
0x18a672E11D637fffADccc99B152F4895Da06960 Rouleth Classicalcasinoroulette.
FindingCommunitiesontheEthereum ledger
Communitiesaregroupsofnodesthatareheavilyconnectedamongthemselves.
Sparselyconnectedtotherestofthenetwork.
PuttingAlgebratowork:tensormodeling
• RepresentingSmartContractsasTensors
• UseTensordecompositiontoidentifystructure
• Predictinteractionsamongcontracts
Presentationofthetensors• Atensorisamultidimensionalarray
• Canbeathreedimensionalcube• Orevena“cube”inhigherdimensionsuchas5,6,7,…
• Extensionofmulti-dimensionalarrayusinglinearalgebra• Differenttheoremsandmathematicaloperationsaredefinedfortensormanipulation
• Sumandmultiplicationbetweensamesizetensorcanbeachieved
• Matricization:transformationofatensorinamatrix(2dimensionstable)
• Multiplicationbetweenmatrixandtensors
• Allowsthemodelingofinteractionsbetweendifferentinputswithoutanysizelimitation
• Abilitytoperformlinearalgebraonlargescaledatatodiscoverlatentvariables
𝒳 ∈ ℝ$×&×' is athree-way tensor
Possibleslicesofathree-way tensor
CANDECOMP/PARAFAC(CP)Decomposition• Introducedin1970byHarshman andCarrollandChang• Factorizationoftheinitialtensorasasumofcomponentofrank-onetensors
• Arankofathree-waytensorisdefinedastheouterproductofthreedifferentvectors
• ResolutionusingAlternatingLeastSquaresmethod• Notoocomplextoimplement• Goodcompromisebetweenspeedandresultsaccuracy
• Eachrank-onetensorisassociatedtoacommunitywithinthedataset
• Eachdimensionoftherank-onetensorscanbetreatedseparately
• Visualizationtool• Seriessimulation
• Onetensordimensionisveryoftenrelatedtotimedimensiontoobserveevolutionovertime
Three-waytensordecomposedinRcomponentsUsingCPdecomposition
SmartContractsActivitiesModeling• DatasetextractedfromEthereum,• Identificationcodeforsenderandreceiversmartcontracts
• AmountofEtherexchanged• Blockheight convertedtotimeperiods
• Objective:estimateaprobabilityofEtherexchangebetweentwospecifiedsmartcontractsfordifferenttimehorizon
• Factorizationoftheinitialtensorasasumofcomponentofrank-onetensorsusingCPdecomposition
• ResolutionusingAlternatingLeastSquaresmethod• Notoocomplextoimplement• Goodcompromisebetweenspeedandresultsaccuracy• Scalabilityforhighertensordimensions
• Eachrank-onetensorisassociatedtoacommunitywithinthedataset• Eachrank-onetensorisusedasinputofalog-normal-mean-reverting
stochasticprocessforactivitiesmodelingandprobabilitiesestimation Descriptionofthedimensionsrelatedtotensordecomposition.Theresultsofthetensordecompositionaretheinputsofthe
stochasticmodel.
ResultsofSmartContractsActivitiesPrediction• Objective:estimateaprobabilityofEtherexchangebetweentwosmartcontractsfora
timehorizon• Betterunderstandingoftheactivitiesbetweenthesmartcontracts• Abilitytoestimateprobabilityoffutureexchangeswhichcouldbeusedforsmartcontractspricingor
forinvestmentstrategy
• Threedifferenttimehorizonhavebeendefinedfortheexperiments• 5timesteps• 10timesteps• 26timesteps
• Forthestochasticsimulation,randomselectionon1%mostactivecontracts• Processforprobabilitiescalculation
• Parameterscalibration• Historicalcalibrationofthelog-normalparameters• HistoricalcalibrationofthemeanrevertingprocessusingEonia ratesduetoshorttimehorizonofthesimulation• EWMAhistoricalcorrelation
• 1,000,000Monte-Carlosimulation• Estimationoftheprobabilitiesusingadigitalfunction
• 𝑆) isthesimulatedprocess• 𝐾 istheamplitudeoftheEtherexchange
• Resultsdiscussion• Digitalvalue(exchangeprobability)offersappropriateguidanceforfutureEtherexchangesevenfor
longertimestephorizons
• Outcomes• AccurateprobabilitiespredictionofEtherexchangeforsmartcontracts• Openthepossibilitytoconsidersmartcontractforinvestmentstrategy• Innovativeapproach usingtensordecompositionandstochasticprocesses
AmplitudeofExchangeamountforonesendertoallreceiversamongtime
DigitalvalueinrelationwiththeseriesevolutionandEtheramplitudeexchangelevelK
RelationbetweentimepaymentmagnitudeandEtherexchangeprobability
Protecting Smart Contracts – BlockchainDefender
• Protectthenetworkandserviceplatform
• FlexibleSoftwareDefinedNetworkcomponentforthe
InfraChain project
• OpenSource Codedevelopment
• Supportformultiplepermissionedblockchains
– Multichain,Hyperledger
• Nomodificationofblockchain nodes andnocensoring
– Useblockchain nodesastheyare
SDNnetworkandcomponents
Controllercomponents
Controllercomponents
Lists
Demo- SystemSetup
Demo- AuthorizedUser
Demo- AuthorizedUser
Demo- UnauthorizedUser
Demo- UnauthorizedUser
AdditionalReadings
Acknowledgments
• JeremyCharlier,PhDstudentinpartnershipprojectwiththeBCEEandco-supervided byDr.JeanHilger
• MathisSteichen,BeltranPontiveros andthepartnershipprojectwithTelindus
• NidaKhan,PhDcandidateinSnT partnershipwithEEthiq
• RobertNorvill,UniversityofBrandford.• Sofiane Lagraa,INRIAFrance