diff --git a/benchmarking/ra10/proof.json b/benchmarking/ra10/proof.json index c3cc89c..538b52a 100644 --- a/benchmarking/ra10/proof.json +++ b/benchmarking/ra10/proof.json @@ -1,17 +1,17 @@ { "pi_a": [ - "17228876828919574829438799102869894773011111154969244509887868327044158780946", - "21758568114629408107198938504609106574570675463989508538869526945277270998932", + "5727805743988453341286884700815777634879357362746234643052568149377105629942", + "16320573579051572457261605111278227689097889341517737400249728412025160386815", "1" ], "pi_b": [ [ - "12614279160736410160576768836569916911390856908238804267453777736607081325690", - "7029353617311896433921039339173828782058621326151714998179451765363589900855" + "9169805673240458480790837490178375806216066893611450600344817151588132331961", + "8333795443847002904461915286611230568086513773772341928955113762419814295108" ], [ - "5792767715800974118790398348804168381602469788741716935689503749551648724751", - "4781454321088671971869812490956267918025191953604927888827573755376118596905" + "20752730528448574161660454871537467184030925191388240715923665865966818254696", + "5085316710749045196005379541247316998281425103229459003619761784883314532789" ], [ "1", @@ -19,8 +19,8 @@ ] ], "pi_c": [ - "9796359066323792651968777901022624414937276012721898609914231320528689235155", - "95800235700704741082513786677815396309062832346553022980425467987759153047", + "9916583713193673430540628997273325336161065139301616115519385524028132469721", + "18591456102625579970423622657333993452146745764607815478014652701410442382103", "1" ], "protocol": "groth16", diff --git a/benchmarking/ra20/proof.json b/benchmarking/ra20/proof.json index e279765..cfc6074 100644 --- a/benchmarking/ra20/proof.json +++ b/benchmarking/ra20/proof.json @@ -1,17 +1,17 @@ { "pi_a": [ - "16972632277055369433112523986755369651059879055309433255877949132015636746658", - "2512431761594702729953083137918743283070816727042456886650973852178604147653", + "3648906573109475049211886778622074794229416385986302579764328066580376354248", + "10192454873588443755132042844232973812987034799196034025604004619797455170777", "1" ], "pi_b": [ [ - "17151922106362008212897295892319732403661273934441694225022471281821591549617", - "4537027704515736841761011474349644706199598810226613348909212522735201591609" + "8702352296565210937233992726662302062243091792944816292091865601792647201930", + "14368585138376817649265943166406947682394643346525116377451816171662125409468" ], [ - "15508952596825539878287790507816321364682114335142921696224263688201846859689", - "4414795242754564412534879227402517542786074461816097638508902942772282632305" + "14732292628870829583467416625360758133257839966582446329366737347838462445620", + "2774403313160324743354719170072085678802361169287436003669157889533734383004" ], [ "1", @@ -19,8 +19,8 @@ ] ], "pi_c": [ - "12517265622017668893004787717344747179636634138653424774476208895770039694312", - "16383402685859551676917256373840976358755782435140170439213581804425294653482", + "3794587231409424378850416667027390389354557067984472788915353464038608025605", + "7129011366676536989883100128910608361058606373709568711045535356120983123368", "1" ], "protocol": "groth16", diff --git a/benchmarking/ra30/proof.json b/benchmarking/ra30/proof.json index f119417..3f7c5ec 100644 --- a/benchmarking/ra30/proof.json +++ b/benchmarking/ra30/proof.json @@ -1,17 +1,17 @@ { "pi_a": [ - "2445277169474121390587695025720874569194536116667791178387221452498635799471", - "14187753347536361336571499722550684483808393135663317810011655135140553552319", + "14492268565168785215266289285873590910912159126155322091342758778770752717591", + "14885468205732514541312181443244583551335118133427914549323280940701030137632", "1" ], "pi_b": [ [ - "1301113732742093549156057507139591395601130193103547834311793157909969559620", - "16498446146598758283548629471523977268447102713619753658917726670441070049887" + "10525069931530228920442315479002644611373894180555902351212433137618674429615", + "16480222841305170712186391122555820724913200276964784394234677935759232497865" ], [ - "328251175707870540010716424689922246037646223463627364686037242332566418524", - "3163667262430054653243784346383282024160193589104154135650001710744291069279" + "8396811532955055197775250592662545447851986637262288466747846805929056418895", + "11230465570970488524152882717597788082092091883066137011509654366474097395364" ], [ "1", @@ -19,8 +19,8 @@ ] ], "pi_c": [ - "9952755127562044669487710618660614768534186497398015650269374215374035112395", - "12473556255075617737920299452804741903844625485906779982500041175297236342996", + "7860257892377405475762533109964157085974360559237267678247965037229114754988", + "18984921230164734345606082072207612069810942285910271425033125869989169225526", "1" ], "protocol": "groth16", diff --git a/benchmarking/ra40/proof.json b/benchmarking/ra40/proof.json index befca21..6668b28 100644 --- a/benchmarking/ra40/proof.json +++ b/benchmarking/ra40/proof.json @@ -1,17 +1,17 @@ { "pi_a": [ - "17859754854564389715674499690127909152096957817409823559009169238140478950958", - "21341401571049151217451491017343154674113549485633085505315394133660921001124", + "20897420353460983481459087704908180756415136349116453593058101268801703314184", + "12761043260054557586397027271189453403460199033797603736920368105763337253463", "1" ], "pi_b": [ [ - "19897014892840041013226483827870622842682992322424516302683223854849635469581", - "16042752155181569387245524376635758872679660282349202182535285486501265809396" + "19053032984973615542905342837275863425016813040209699820199963530680869778370", + "21791898598531655851378016877153758703487326458719462723886717303686190538708" ], [ - "5416298749398061060742703055657232019704304187649356430242327642869117251072", - "3437197167843574564968568902811676898307326434096825603703198937975345349684" + "20658077585629228345201001823276067789881731833582811786177669326937320564924", + "1605807686962199178433705287577046804257716994882254137928902459467072401654" ], [ "1", @@ -19,8 +19,8 @@ ] ], "pi_c": [ - "17003634749451650054376271195121089211519989452801036451513318715794125938577", - "5578270956798957036515201737786192809747301532728327388799869866934026916479", + "10848825758904465089691299356832675612554951807468950642622907830014167204895", + "19773181803135611408096102815358516286775123373711359384881277801675968017972", "1" ], "protocol": "groth16", diff --git a/js/device.js b/js/device.js new file mode 100644 index 0000000..ddab894 --- /dev/null +++ b/js/device.js @@ -0,0 +1,28 @@ + +const Tx = require('ethereumjs-tx').Transaction +const Web3 = require('web3') +const web3 = new Web3('') +const account1 = '
' +const account2 = '
' +const privateKey1 = Buffer.from('', 'hex') +const privateKey2 = Buffer.from('', 'hex') +web3.eth.getTransactionCount(account1, (err, txCount) => { +// Build a transaction +const txObject = { + nonce: web3.utils.toHex(txCount), + to: account2, + value: web3.utils.toHex(web3.utils.toWei('1', 'ether')), + gasLimit: web3.utils.toHex(21000), + gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')) +} +// Sign the transaction +const tx = new Tx(txObject, { chain: 'ropsten' }) +tx.sign(privateKey1) +const serializedTransaction = tx.serialize() +const raw = '0x' + serializedTransaction.toString('hex') +// Broadcast the transaction +web3.eth.sendSignedTransaction(raw, (err, txHash) => { + console.log('txHash: ', txHash) + console.log(err) + }) +}) diff --git a/js/merkle_tree.js b/js/setup_phase.js similarity index 100% rename from js/merkle_tree.js rename to js/setup_phase.js diff --git a/js/tool.js b/js/tool.js new file mode 100644 index 0000000..a5af874 --- /dev/null +++ b/js/tool.js @@ -0,0 +1,70 @@ +let dict = { + "root": "", + "devAddr": "0xe572eD5cD7004C0D04C731AEfF1Eac70F531CE93", + "response": "0x913d9500593d099452fa9e0f9a515a13211a0f424e3b2188d68985f31e925577", + "challenge": "0x1bb6d29e97bf1bac8f5f7492fcfd4f45af982f6f0c8d1edd783c14d81ffffffe", + "pathElements": [ + "0x1a59a5e11a71af1231b640914e0b610fccb8e2948f56dc6d9d78edd04cb2d9ab", + "0x22b6a8e311a84f944887a78ef3697466a4bc6cb7b33642cc9cac0067301fd32f", + "0x1b4f49afca3bd11dbb0dd43540c71d73d28bafc49589bb4b8677c386cf836681", + "0x19d2c0c60ef4ce1a0b315c842e155771a6bfac50ccdc087a5d955e0bf5f6fcf2", + "0x187c570799c364d7294caac1394a5b6be0825a32970c13d6fd41985c5d726afa", + "0x2efdaed9e8a0bf1beb2fd4fd23dd3289f6743b90f73d477084c8bfb969a95575", + "0x2c423f4e6a8039adae5b1dffa40de96d9ec5e32599cb40032c12f40253d8d480", + "0x2046488fdd6f40fe2e6939e908c2972e81b5e8cbd2c4f96862c3e1b8e8b49719", + "0xc51866133a77982508401a23a30709bbf045719f11140aa658afb3d85199440", + "0x223294ffc43b18c42c1a74670e92201964375849083cc7d7a643972202d86b56", + "0xf22d5a8739fe642523e200bd9878717757888d156ad48dcdd57b7add9e64716", + "0x20ff9c2e44ca0b09ec165eb3c94aa83e3bc086d08e4eb3310cb125f937a0347c", + "0xd044d4cfb0f7f9afab8c551e22e5698b95b29b1177246a4c1683bc2a978266a", + "0x782cad65d67c4b70ca77949af7660fde7ba99769827bdb676143b9fb60a052d", + "0x135dfd87bbedbec9a4fa43442d13282f264abfcf9db9d5a6c605a420538c6d92", + "0x20a23e637f25f6f89af532633833fdd0e520d95341e8cd21572a03b1cec89277", + "0xf197e54e3b96838b92a3e7e06c795447f40477424ae34d3089c869f46c9f93d", + "0xe6cb82f00d3820677eb210db5817ba1f5c2d10317f9cd00d64a84eec2dd088e", + "0x2d7ae41cb7c186d0849ccbeef32b29d347ccad42e0cfe6d85319d5950141b4f5", + "0x2dc38b29ed7800b9a320efef795d7e762fdeffcf4405fb70c13ec1bce68407f7", + "0x9ac552a79ce3fab2d33fa826bd62c9e9bc134dc387e964c1ceedaa85f9de334", + "0x11a0f0d4386ff677fc795bdc061a6abd14ce5331cc4d3ea804bd77068db016b6", + "0x2fc705cf93ac7a858acec8f0c96bbd011a3a78b42555bab5127a7757b9c77b13", + "0x2f29c1e609c8e785d64d546c1d3a5567157f3faa3c97bc2aa554c0307e2e4fcd", + "0x249d324a14d45dd18fd60d0ccb6e0f74b97626c2e3b946e758684e99bba3e9fa", + "0x255339ebec8d859e7093eaa5889722f41206e6cd3d99e6d40800c3ae7bb798f0", + "0x2e32807d242c8d994fbcfd75d7cd1b9aedab34ffad1f9c61f89a88f41f8ca97a", + "0xa38388b7956cdb5f79c90621c6358a66e9a4d3ac294491ba1057990a657b805", + "0x2317fca60fea9ba034fd3b3a91e0e94794f525d1676a994976eb9fb4d7d65826", + "0x6bba869dae37a78c74b29dacc34e5e769ffbcfcc12c3a729776c96270c470ea" + ], + "pathIndices": [ + "1", "0", "0", "1", "1", "0", "1", "1", "0", "0", + "1", "0", "0", "1", "1", "0", "0", "1", "1", "1", + "0", "0", "0", "1", "1", "0", "1", "0", "1", "0" + ] +} +let left, right; +let hashes = []; +console.log([dict['devAddr'], dict['challenge'], dict['response']]); +let tmp = poseidon([dict['devAddr'], dict['challenge'], dict['response']]); +hashes.push('0x' + tmp.toString(16)); +for (let i = 0; i < 30; i++) { + if(dict['pathIndices'][i] == "0") { + left = hashes[i]; + right = dict['pathElements'][i]; + } else { + right = hashes[i]; + left = dict['pathElements'][i]; + } + // console.log([left, right]); + hashes.push((poseidon([left, right]))); + console.log(BigInt(hashes[i]).toString(10)); +} +console.log(BigInt(hashes[30]).toString(10)); +dict["root"] = "0x" + (hashes[30]).toString(16).padStart(64, '0'); +// console.log(dict); +// console.log(hashes); + +fs.writeFile(`input_sample_30.json`, JSON.stringify(dict, null, 4), err => { + if (err) { + throw err + } + })